Skip to content

Commit d5f457e

Browse files
authored
Merge pull request #242 from creativecommons/test-help
Add Test Scripts' Help script and workflow
2 parents af6591b + e01fc18 commit d5f457e

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Test scripts' help
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
jobs:
8+
job:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
13+
# https://github.com/actions/setup-python
14+
- name: Install Python 3.11
15+
uses: actions/setup-python@v5
16+
with:
17+
python-version: '3.11'
18+
19+
- name: Install pipenv
20+
run: |
21+
pip install --upgrade pip
22+
pip install pipenv
23+
24+
# https://github.com/actions/checkout
25+
- name: Checkout quantifying
26+
uses: actions/checkout@v4
27+
28+
- name: Install Python dependencies
29+
run: |
30+
pipenv sync --system
31+
32+
- name: Test scripts' help
33+
run: |
34+
./dev/test_scripts_help.sh

dev/test_scripts_help.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Ensure each script can display help message to ensure basic execution.
4+
#
5+
# This script must be run from within the pipenv shell or a properly configured
6+
# environment. For example:
7+
#
8+
# 1. Using pipenv run
9+
# pipenv run ./dev/test_scripts_help.sh
10+
#
11+
# 2. Using pipenv shell
12+
# pipenv shell
13+
# ./dev/test_scripts_help.sh
14+
#
15+
# 3. A properly configured environment
16+
# (see .github/workflows/test_scripts_help.yml)
17+
#
18+
#### SETUP ####################################################################
19+
20+
set -o errexit
21+
set -o errtrace
22+
set -o nounset
23+
24+
# shellcheck disable=SC2154
25+
trap '_es=${?};
26+
printf "${0}: line ${LINENO}: \"${BASH_COMMAND}\"";
27+
printf " exited with a status of ${_es}\n";
28+
exit ${_es}' ERR
29+
30+
DIR_REPO="$(cd -P -- "${0%/*}/.." && pwd -P)"
31+
EXIT_STATUS=0
32+
33+
#### FUNCTIONS ################################################################
34+
35+
test_help() {
36+
local _es _script
37+
for _script in $(find scripts/?-* -type f -name '*.py' | sort)
38+
do
39+
_es=0
40+
./"${_script}" --help &>/dev/null || _es=${?}
41+
if (( _es == 0 ))
42+
then
43+
echo "${_script}"
44+
else
45+
echo "${_script}"
46+
EXIT_STATUS=${_es}
47+
fi
48+
done
49+
}
50+
51+
#### MAIN #####################################################################
52+
53+
cd "${DIR_REPO}"
54+
test_help
55+
echo "exit status: ${EXIT_STATUS}"
56+
exit ${EXIT_STATUS}

0 commit comments

Comments
 (0)