mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 02:54:26 +00:00
Only test-unit-python went through the container dispatcher; the javascript, php and ruby targets called their runner directly and so executed against the host, where the toolchain may be absent and the sandbox blocks the install. The dispatcher was never python-specific, it just hardcoded run.sh. It now takes the runner as an argument, and the host-side install prerequisites drop out with it.
67 lines
2.6 KiB
Bash
Executable File
67 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Chooses where to execute a test runner based on INFINITO_TEST_RUNNER:
|
|
# docker (default) -- inside the already-running infinito compose
|
|
# container (requires `make compose-up`).
|
|
# host -- directly against the host shell/Python.
|
|
#
|
|
# Param $1: repo-relative path of the runner script to execute.
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(cd "${SCRIPT_DIR}/../../.." && pwd)"
|
|
RUNNER_REL="${1:?usage: wrapper.sh <repo-relative-runner-script>}"
|
|
RUN_SCRIPT="${REPO_ROOT}/${RUNNER_REL}"
|
|
|
|
cd "${REPO_ROOT}"
|
|
# shellcheck source=scripts/meta/env/load.sh
|
|
source scripts/meta/env/load.sh
|
|
|
|
: "${INFINITO_TEST_PATTERN:?INFINITO_TEST_PATTERN must be set}"
|
|
: "${INFINITO_TEST_RUNNER:?INFINITO_TEST_RUNNER must be set}"
|
|
: "${INFINITO_TEST_TYPE:?INFINITO_TEST_TYPE must be set}" # nocheck: makefile-supplied
|
|
|
|
RUN_SCRIPT_IN_CONTAINER="${INFINITO_SRC_DIR}/${RUNNER_REL}"
|
|
|
|
case "${INFINITO_TEST_RUNNER}" in
|
|
docker)
|
|
echo "============================================================"
|
|
echo ">>> Running ${INFINITO_TEST_TYPE^^} tests in ${INFINITO_DISTRO} container (compose stack)" # nocheck: makefile-supplied
|
|
echo "============================================================"
|
|
|
|
if ! docker compose ps -q infinito 2>/dev/null | grep -q .; then
|
|
echo ">>> 'infinito' container not running; starting the stack via 'make compose-up'..."
|
|
exec {lockfd}>"${REPO_ROOT}/.compose-up.lock"
|
|
flock "${lockfd}"
|
|
docker compose ps -q infinito 2>/dev/null | grep -q . || "${MAKE:-make}" compose-up
|
|
exec {lockfd}>&-
|
|
fi
|
|
|
|
exec_env_args=(
|
|
-e ACT="${ACT:-}"
|
|
-e BASH_ENV="${INFINITO_SRC_DIR}/scripts/meta/env/load.sh"
|
|
-e GITHUB_ACTIONS="${GITHUB_ACTIONS:-}"
|
|
-e GITHUB_REPOSITORY="${GITHUB_REPOSITORY:-}"
|
|
-e GITHUB_REPOSITORY_OWNER="${GITHUB_REPOSITORY_OWNER:-}"
|
|
-e GITHUB_SHA="${GITHUB_SHA:-}"
|
|
-e INFINITO_TEST_PATTERN="${INFINITO_TEST_PATTERN}"
|
|
-e INFINITO_TEST_TYPE="${INFINITO_TEST_TYPE}" # nocheck: makefile-supplied
|
|
)
|
|
INFINITO_DISTRO="${INFINITO_DISTRO}" \
|
|
docker compose exec -T \
|
|
"${exec_env_args[@]}" \
|
|
--workdir "${INFINITO_SRC_DIR}" \
|
|
infinito \
|
|
bash --login "${RUN_SCRIPT_IN_CONTAINER}"
|
|
;;
|
|
host)
|
|
echo "============================================================"
|
|
echo ">>> Running ${INFINITO_TEST_TYPE^^} tests on host" # nocheck: makefile-supplied
|
|
echo "============================================================"
|
|
exec bash --login "${RUN_SCRIPT}"
|
|
;;
|
|
*)
|
|
echo "scripts/tests/code/wrapper.sh: unknown INFINITO_TEST_RUNNER='${INFINITO_TEST_RUNNER}' (expected: docker|host)" >&2 # nocheck: self-path-reference
|
|
exit 2
|
|
;;
|
|
esac
|