Skip to content

Commit bdfe4ba

Browse files
committed
Add nocleanup special arg
1 parent e86b8cd commit bdfe4ba

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

.github/workflows/python-check-requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ jobs:
2424
with:
2525
python-version: "3.11"
2626
- name: Run check-requirements.sh script
27-
run: bash check-requirements.sh
27+
run: bash check-requirements.sh nocleanup

check-requirements.sh

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,18 @@
66
# WARNING: This is quite IO intensive, because a fresh venv is set up for every
77
# python script.
88
#
9+
# usage: ./check-requirements.sh [<working_dir>]
10+
# ./check-requirements.sh 'nocleanup' [<working_dir>]
11+
#
12+
# where:
13+
# - <working_dir> is a directory that can be used as the base for
14+
# setting up the venvs. Defaults to `/tmp`.
15+
# - 'nocleanup' as the first argument will disable automatic cleanup
16+
# of the files created by this script.
17+
#
918
# requires:
10-
# * bash >= 3.2.57
11-
# * shellcheck
19+
# - bash >= 3.2.57
20+
# - shellcheck
1221
#
1322
# For each script, it creates a fresh venv, `pip install -r` the
1423
# requirements, and finally executes the python script with no arguments to
@@ -54,8 +63,12 @@ abort() {
5463
exit 1
5564
}
5665

57-
trap abort SIGINT SIGTERM SIGQUIT SIGABRT
58-
trap cleanup EXIT
66+
if [[ $1 == nocleanup ]]; then
67+
shift # discard nocleanup arg
68+
else
69+
trap abort SIGINT SIGTERM SIGQUIT SIGABRT
70+
trap cleanup EXIT
71+
fi
5972

6073
set -eu -o pipefail
6174
this="$(realpath "$0")"
@@ -107,6 +120,10 @@ check_convert_script() {
107120
info "$py: beginning check"
108121

109122
local reqs="requirements-$pyname.txt"
123+
if [[ ! -r "$reqs" ]]; then
124+
fatal "$py missing requirements. Expected: $reqs"
125+
fi
126+
110127
local venv="$workdir/$pyname-venv"
111128
python3 -m venv "$venv"
112129

0 commit comments

Comments
 (0)