diff --git a/.github/workflows/test_scripts_help.yml b/.github/workflows/test_scripts_help.yml new file mode 100644 index 00000000..ece0355f --- /dev/null +++ b/.github/workflows/test_scripts_help.yml @@ -0,0 +1,34 @@ +name: Test scripts' help + +on: + push: + workflow_dispatch: + +jobs: + job: + runs-on: ubuntu-latest + + steps: + + # https://github.com/actions/setup-python + - name: Install Python 3.11 + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install pipenv + run: | + pip install --upgrade pip + pip install pipenv + + # https://github.com/actions/checkout + - name: Checkout quantifying + uses: actions/checkout@v4 + + - name: Install Python dependencies + run: | + pipenv sync --system + + - name: Test scripts' help + run: | + ./dev/test_scripts_help.sh diff --git a/dev/test_scripts_help.sh b/dev/test_scripts_help.sh new file mode 100755 index 00000000..4dd90df4 --- /dev/null +++ b/dev/test_scripts_help.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# +# Ensure each script can display help message to ensure basic execution. +# +# This script must be run from within the pipenv shell or a properly configured +# environment. For example: +# +# 1. Using pipenv run +# pipenv run ./dev/test_scripts_help.sh +# +# 2. Using pipenv shell +# pipenv shell +# ./dev/test_scripts_help.sh +# +# 3. A properly configured environment +# (see .github/workflows/test_scripts_help.yml) +# +#### SETUP #################################################################### + +set -o errexit +set -o errtrace +set -o nounset + +# shellcheck disable=SC2154 +trap '_es=${?}; + printf "${0}: line ${LINENO}: \"${BASH_COMMAND}\""; + printf " exited with a status of ${_es}\n"; + exit ${_es}' ERR + +DIR_REPO="$(cd -P -- "${0%/*}/.." && pwd -P)" +EXIT_STATUS=0 + +#### FUNCTIONS ################################################################ + +test_help() { + local _es _script + for _script in $(find scripts/?-* -type f -name '*.py' | sort) + do + _es=0 + ./"${_script}" --help &>/dev/null || _es=${?} + if (( _es == 0 )) + then + echo "✅ ${_script}" + else + echo "❌ ${_script}" + EXIT_STATUS=${_es} + fi + done +} + +#### MAIN ##################################################################### + +cd "${DIR_REPO}" +test_help +echo "exit status: ${EXIT_STATUS}" +exit ${EXIT_STATUS}