From 4cb00eec18c4fcb85c91dc480c3e8cd29f4817be Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Mon, 30 Nov 2026 22:46:50 +0000 Subject: [PATCH] chore(test): fold the container scripts to clear the quality findings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit quality clean.prefix-groups: env-nix.sh and env-virtual.sh move to scripts/test/container/env/nix.sh and env/virtual.sh; their only callers, scripts/test/test-env-nix.sh and test-env-virtual.sh, are updated. clean.clones: the shared git safe.directory block of e2e.sh and env-nix.sh is one script, scripts/test/container/safe-directory.sh, called at the same spot. clean.comment: parameter lines use the form # Param: NAME ($n) - text. coding.shell-lint SC1091: quality runs shellcheck without -x, so the source directives are shellcheck source=/dev/null like the sibling scripts; the sourcing logic is unchanged. | 🌿 Branch | 📊 Diff stat | 🎯 Fix | 💥 Break | 💸 Tokens | ⏱️ Velocity | 🛡️ Security | 🏆 Score | Gate | | --- | --- | --- | --- | --- | --- | --- | --- | --- | | chore/test-scripts-no-inline | 7 files +17/-17 | 92 % | 3 % | – | – | 100 % | 89 | ✅ 90/5, tokens and velocity <= 100, security 100 % | Evidence: quality check --staged 0 findings, shellcheck --norc clean on all 7 scripts, MEDUSA 100 %, critical 0. The container jobs of PR CI are the proof. Hub review 42b3a76554491026. Refs https://github.com/kevinveenbirkenbach/package-manager/pull/20 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 --- scripts/test/container/e2e.sh | 6 +----- scripts/test/container/{env-nix.sh => env/nix.sh} | 14 +++++--------- .../container/{env-virtual.sh => env/virtual.sh} | 0 scripts/test/container/safe-directory.sh | 8 ++++++++ scripts/test/container/unittest.sh | 2 +- scripts/test/test-env-nix.sh | 2 +- scripts/test/test-env-virtual.sh | 2 +- 7 files changed, 17 insertions(+), 17 deletions(-) rename scripts/test/container/{env-nix.sh => env/nix.sh} (68%) rename scripts/test/container/{env-virtual.sh => env/virtual.sh} (100%) create mode 100755 scripts/test/container/safe-directory.sh diff --git a/scripts/test/container/e2e.sh b/scripts/test/container/e2e.sh index d8df18e..d8d8d74 100755 --- a/scripts/test/container/e2e.sh +++ b/scripts/test/container/e2e.sh @@ -25,11 +25,7 @@ command -v nix >/dev/null || { exit 1 } -if command -v git >/dev/null 2>&1; then - git config --global --add safe.directory /opt/src/pkgmgr || true - git config --global --add safe.directory /opt/src/pkgmgr/.git || true - git config --global --add safe.directory "*" || true -fi +bash scripts/test/container/safe-directory.sh nix develop .#default --no-write-lock-file -c \ python3 -m unittest discover \ diff --git a/scripts/test/container/env-nix.sh b/scripts/test/container/env/nix.sh similarity index 68% rename from scripts/test/container/env-nix.sh rename to scripts/test/container/env/nix.sh index 133883f..b0c7af9 100755 --- a/scripts/test/container/env-nix.sh +++ b/scripts/test/container/env/nix.sh @@ -1,16 +1,12 @@ #!/usr/bin/env bash set -euo pipefail -# Param: $1 IMAGE, the image name shown in the missing-nix error. -# Param: $2 PKGMGR_DISTRO, the distro shown in the missing-nix error. +# Param: IMAGE ($1) - the image name shown in the missing-nix error. +# Param: PKGMGR_DISTRO ($2) - the distro shown in the missing-nix error. IMAGE="$1" PKGMGR_DISTRO="$2" -if command -v git >/dev/null 2>&1; then - git config --global --add safe.directory /opt/src/pkgmgr || true - git config --global --add safe.directory /opt/src/pkgmgr/.git || true - git config --global --add safe.directory "*" || true -fi +bash scripts/test/container/safe-directory.sh echo ">>> preflight: nix must exist in image" if ! command -v nix >/dev/null 2>&1; then @@ -24,10 +20,10 @@ echo ">>> nix version" nix --version if [[ -f /opt/src/pkgmgr/scripts/nix/lib/retry_403.sh ]]; then - # shellcheck source=SCRIPTDIR/../../nix/lib/retry_403.sh + # shellcheck source=/dev/null source /opt/src/pkgmgr/scripts/nix/lib/retry_403.sh elif [[ -f ./scripts/nix/lib/retry_403.sh ]]; then - # shellcheck source=SCRIPTDIR/../../nix/lib/retry_403.sh + # shellcheck source=/dev/null source ./scripts/nix/lib/retry_403.sh else echo "ERROR: retry helper not found: scripts/nix/lib/retry_403.sh" diff --git a/scripts/test/container/env-virtual.sh b/scripts/test/container/env/virtual.sh similarity index 100% rename from scripts/test/container/env-virtual.sh rename to scripts/test/container/env/virtual.sh diff --git a/scripts/test/container/safe-directory.sh b/scripts/test/container/safe-directory.sh new file mode 100755 index 0000000..0f93ac8 --- /dev/null +++ b/scripts/test/container/safe-directory.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail + +if command -v git >/dev/null 2>&1; then + git config --global --add safe.directory /opt/src/pkgmgr || true + git config --global --add safe.directory /opt/src/pkgmgr/.git || true + git config --global --add safe.directory "*" || true +fi diff --git a/scripts/test/container/unittest.sh b/scripts/test/container/unittest.sh index ff2b212..dbc3184 100755 --- a/scripts/test/container/unittest.sh +++ b/scripts/test/container/unittest.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -# Param: $1 the test folder to discover, tests/unit or tests/integration. +# Param: suite ($1) - the test folder to discover, tests/unit or tests/integration. suite="$1" git config --global --add safe.directory /opt/src/pkgmgr || true diff --git a/scripts/test/test-env-nix.sh b/scripts/test/test-env-nix.sh index d2777bb..973d2f4 100755 --- a/scripts/test/test-env-nix.sh +++ b/scripts/test/test-env-nix.sh @@ -16,4 +16,4 @@ docker run --rm \ -e REINSTALL_PKGMGR=1 \ -e NIX_CONFIG="${NIX_CONFIG}" \ "${IMAGE}" \ - bash -l scripts/test/container/env-nix.sh "${IMAGE}" "${PKGMGR_DISTRO}" + bash -l scripts/test/container/env/nix.sh "${IMAGE}" "${PKGMGR_DISTRO}" diff --git a/scripts/test/test-env-virtual.sh b/scripts/test/test-env-virtual.sh index 4e6381a..59c1de2 100755 --- a/scripts/test/test-env-virtual.sh +++ b/scripts/test/test-env-virtual.sh @@ -18,7 +18,7 @@ if OUTPUT=$(docker run --rm \ -w /opt/src/pkgmgr \ -e NIX_CONFIG="${NIX_CONFIG}" \ "${IMAGE}" \ - bash -l scripts/test/container/env-virtual.sh 2>&1); then + bash -l scripts/test/container/env/virtual.sh 2>&1); then echo "$OUTPUT" echo