Add nocleanup special arg

This commit is contained in:
crasm 2023-12-21 04:55:28 -05:00
parent e86b8cd93a
commit bdfe4ba85c
2 changed files with 22 additions and 5 deletions

View file

@ -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

View file

@ -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 [<working_dir>]
# ./check-requirements.sh 'nocleanup' [<working_dir>]
#
# where:
# - <working_dir> 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
}
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"