diff --git a/.github/workflows/python-check-requirements.yml b/.github/workflows/python-check-requirements.yml index 49c992b4a..cc97ee810 100644 --- a/.github/workflows/python-check-requirements.yml +++ b/.github/workflows/python-check-requirements.yml @@ -24,4 +24,4 @@ jobs: with: python-version: "3.11" - name: Run check-requirements.sh script - run: bash check-requirements.sh + run: bash check-requirements.sh nocleanup diff --git a/check-requirements.sh b/check-requirements.sh index 881b8f190..ac6beb604 100755 --- a/check-requirements.sh +++ b/check-requirements.sh @@ -6,9 +6,18 @@ # WARNING: This is quite IO intensive, because a fresh venv is set up for every # python script. # +# usage: ./check-requirements.sh [] +# ./check-requirements.sh 'nocleanup' [] +# +# where: +# - is a directory that can be used as the base for +# setting up the venvs. Defaults to `/tmp`. +# - 'nocleanup' as the first argument will disable automatic cleanup +# of the files created by this script. +# # requires: -# * bash >= 3.2.57 -# * shellcheck +# - bash >= 3.2.57 +# - shellcheck # # For each script, it creates a fresh venv, `pip install -r` the # requirements, and finally executes the python script with no arguments to @@ -54,8 +63,12 @@ abort() { exit 1 } -trap abort SIGINT SIGTERM SIGQUIT SIGABRT -trap cleanup EXIT +if [[ $1 == nocleanup ]]; then + shift # discard nocleanup arg +else + trap abort SIGINT SIGTERM SIGQUIT SIGABRT + trap cleanup EXIT +fi set -eu -o pipefail this="$(realpath "$0")" @@ -107,6 +120,10 @@ check_convert_script() { info "$py: beginning check" local reqs="requirements-$pyname.txt" + if [[ ! -r "$reqs" ]]; then + fatal "$py missing requirements. Expected: $reqs" + fi + local venv="$workdir/$pyname-venv" python3 -m venv "$venv"