CI: Simplify running commands with several versions of Python
This commit is contained in:
parent
599da58070
commit
9538059f84
3 changed files with 54 additions and 19 deletions
|
@ -391,12 +391,7 @@ test_idf_monitor:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
script:
|
script:
|
||||||
- cd ${IDF_PATH}/tools/test_idf_monitor
|
- cd ${IDF_PATH}/tools/test_idf_monitor
|
||||||
- source /opt/pyenv/activate
|
- ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh ./run_test_idf_monitor.py
|
||||||
- pyenv global 2.7.15
|
|
||||||
- ./run_test_idf_monitor.py
|
|
||||||
- pyenv global 3.4.8
|
|
||||||
- ./run_test_idf_monitor.py
|
|
||||||
- pyenv global system
|
|
||||||
|
|
||||||
test_idf_size:
|
test_idf_size:
|
||||||
<<: *host_test_template
|
<<: *host_test_template
|
||||||
|
@ -408,12 +403,7 @@ test_idf_size:
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
script:
|
script:
|
||||||
- cd ${IDF_PATH}/tools/test_idf_size
|
- cd ${IDF_PATH}/tools/test_idf_size
|
||||||
- source /opt/pyenv/activate
|
- ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh ./test.sh
|
||||||
- pyenv global 2.7.15
|
|
||||||
- ./test.sh
|
|
||||||
- pyenv global 3.4.8
|
|
||||||
- ./test.sh
|
|
||||||
- pyenv global system
|
|
||||||
|
|
||||||
test_esp_err_to_name_on_host:
|
test_esp_err_to_name_on_host:
|
||||||
<<: *host_test_template
|
<<: *host_test_template
|
||||||
|
@ -423,15 +413,11 @@ test_esp_err_to_name_on_host:
|
||||||
- components/esp32/esp_err_to_name.c
|
- components/esp32/esp_err_to_name.c
|
||||||
expire_in: 1 week
|
expire_in: 1 week
|
||||||
script:
|
script:
|
||||||
- cd tools/
|
- cd ${IDF_PATH}/tools/
|
||||||
- source /opt/pyenv/activate
|
- ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh -p 2.7.15 ./gen_esp_err_to_name.py
|
||||||
- pyenv global 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)
|
- 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
|
- ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh -p 3.4.8 ./gen_esp_err_to_name.py
|
||||||
- ./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)
|
- 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:
|
push_to_github:
|
||||||
stage: deploy
|
stage: deploy
|
||||||
|
|
|
@ -44,3 +44,4 @@ tools/unit-test-app/unit_test.py
|
||||||
tools/test_idf_size/test.sh
|
tools/test_idf_size/test.sh
|
||||||
tools/check_python_dependencies.py
|
tools/check_python_dependencies.py
|
||||||
docs/gen-dxd.py
|
docs/gen-dxd.py
|
||||||
|
tools/ci/multirun_with_pyenv.sh
|
||||||
|
|
48
tools/ci/multirun_with_pyenv.sh
Executable file
48
tools/ci/multirun_with_pyenv.sh
Executable file
|
@ -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; }
|
Loading…
Reference in a new issue