kopia lustrzana https://github.com/espressif/esp-idf
CI: Simplify running commands with several versions of Python
rodzic
599da58070
commit
9538059f84
|
@ -391,12 +391,7 @@ test_idf_monitor:
|
|||
expire_in: 1 week
|
||||
script:
|
||||
- cd ${IDF_PATH}/tools/test_idf_monitor
|
||||
- source /opt/pyenv/activate
|
||||
- pyenv global 2.7.15
|
||||
- ./run_test_idf_monitor.py
|
||||
- pyenv global 3.4.8
|
||||
- ./run_test_idf_monitor.py
|
||||
- pyenv global system
|
||||
- ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh ./run_test_idf_monitor.py
|
||||
|
||||
test_idf_size:
|
||||
<<: *host_test_template
|
||||
|
@ -408,12 +403,7 @@ test_idf_size:
|
|||
expire_in: 1 week
|
||||
script:
|
||||
- cd ${IDF_PATH}/tools/test_idf_size
|
||||
- source /opt/pyenv/activate
|
||||
- pyenv global 2.7.15
|
||||
- ./test.sh
|
||||
- pyenv global 3.4.8
|
||||
- ./test.sh
|
||||
- pyenv global system
|
||||
- ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh ./test.sh
|
||||
|
||||
test_esp_err_to_name_on_host:
|
||||
<<: *host_test_template
|
||||
|
@ -423,15 +413,11 @@ test_esp_err_to_name_on_host:
|
|||
- components/esp32/esp_err_to_name.c
|
||||
expire_in: 1 week
|
||||
script:
|
||||
- cd tools/
|
||||
- source /opt/pyenv/activate
|
||||
- pyenv global 2.7.15
|
||||
- ./gen_esp_err_to_name.py
|
||||
- cd ${IDF_PATH}/tools/
|
||||
- ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh -p 2.7.15 ./gen_esp_err_to_name.py
|
||||
- git diff --exit-code -- ../components/esp32/esp_err_to_name.c || (echo 'Differences found. Please run gen_esp_err_to_name.py and commit the changes.'; exit 1)
|
||||
- pyenv global 3.4.8
|
||||
- ./gen_esp_err_to_name.py
|
||||
- ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh -p 3.4.8 ./gen_esp_err_to_name.py
|
||||
- git diff --exit-code -- ../components/esp32/esp_err_to_name.c || (echo 'Differences found between running under Python 2 and 3.'; exit 1)
|
||||
- pyenv global system
|
||||
|
||||
push_to_github:
|
||||
stage: deploy
|
||||
|
|
|
@ -44,3 +44,4 @@ tools/unit-test-app/unit_test.py
|
|||
tools/test_idf_size/test.sh
|
||||
tools/check_python_dependencies.py
|
||||
docs/gen-dxd.py
|
||||
tools/ci/multirun_with_pyenv.sh
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
#! /bin/bash
|
||||
#
|
||||
# Tool for running scripts with several versions of Python by the use of pyenv (versions must be installed before in
|
||||
# the docker image)
|
||||
#
|
||||
# Examples:
|
||||
# ./multirun_with_pyenv.sh ./exec.sh # Run ./exec.h with ALL installed versions of Python
|
||||
# ./multirun_with_pyenv.sh ./exec.sh arg1 arg2 # Run ./exec.h with arguments (and ALL installed versions of Python)
|
||||
# ./multirun_with_pyenv.sh -p 2.7.15 ./exec.sh # Run ./exec.h with Python 2.7.15 (-p must be the first argument)
|
||||
# ./multirun_with_pyenv.sh -p 3.4.8,2.7.15 ./exec.sh # Run ./exec.h with Python 3.4.8 and 2.7.15 (versions must be
|
||||
# # separated by coma and be without a space)
|
||||
|
||||
PY_VERSIONS=""
|
||||
|
||||
{ source /opt/pyenv/activate; } || { echo 'Pyenv activation has failed!' ; exit 1; }
|
||||
|
||||
if [ "$1" = "-p" ]; then
|
||||
if [ "$#" -ge 2 ]; then
|
||||
IFS=',' read -a PY_VERSIONS <<< "$2"
|
||||
shift #remove -p
|
||||
shift #remove argument after -p
|
||||
else
|
||||
echo 'No value (Python version) is given for argument -p!'
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
PY_VERSIONS=$(pyenv versions --bare)
|
||||
fi
|
||||
|
||||
if [ "$#" -lt 1 ]; then
|
||||
echo 'No executable was passed to the runner!'
|
||||
exit 1
|
||||
fi
|
||||
|
||||
for ver in ${PY_VERSIONS[@]}
|
||||
do
|
||||
echo 'Switching to Python' $ver
|
||||
$(pyenv global $ver) || exit 1
|
||||
echo 'Running' $@
|
||||
$@ || {
|
||||
echo 'Run failed! Switching back to the system version of the Python interpreter.';
|
||||
pyenv global system;
|
||||
exit 1;
|
||||
}
|
||||
done
|
||||
|
||||
echo 'Switching back to the system version of Python'
|
||||
{ pyenv global system; } || { echo 'Restoring the system version of the Python interpreter has failed!' ; exit 1; }
|
Ładowanie…
Reference in New Issue