test: share persistent Nix store across all test containers

This commit adds the `pkgmgr_nix_store` volume mount (`/nix`) to all test
runners (unit, integration, container sanity checks, and E2E tests).

Previously only the Arch-based E2E container mounted a persistent `/nix`
store, causing all other distros (Debian, Ubuntu, Fedora, CentOS, etc.)
to download the entire Nix closure repeatedly during test runs.

Changes:
- Add `-v pkgmgr_nix_store:/nix` to:
  - scripts/test/test-container.sh
  - scripts/test/test-e2e.sh (remove Arch-only condition)
  - scripts/test/test-unit.sh
  - scripts/test/test-integration.sh
- Ensures all test containers reuse the same Nix store.

Benefits:
- Significantly faster test execution after the first run.
- Prevents redundant downloads from cache.nixos.org.
- Ensures consistent Nix environments across all test distros.

No functional changes to pkgmgr itself; only test infrastructure improved.

https://chatgpt.com/share/693890f5-2f54-800f-b47e-1925da85b434
This commit is contained in:
Kevin Veen-Birkenbach
2025-12-09 22:13:01 +01:00
parent ca08c84789
commit 78693225f1
4 changed files with 4 additions and 6 deletions

View File

@@ -19,6 +19,7 @@ for distro in $DISTROS; do
# Run the command and capture the output # Run the command and capture the output
if OUTPUT=$(docker run --rm \ if OUTPUT=$(docker run --rm \
-e PKGMGR_DEV=1 \ -e PKGMGR_DEV=1 \
-v pkgmgr_nix_store:/nix \
-v "$(pwd):/src" \ -v "$(pwd):/src" \
-v "pkgmgr_nix_cache:/root/.cache/nix" \ -v "pkgmgr_nix_cache:/root/.cache/nix" \
"$IMAGE" 2>&1); then "$IMAGE" 2>&1); then

View File

@@ -8,14 +8,9 @@ for distro in $DISTROS; do
echo ">>> Running E2E tests: $distro" echo ">>> Running E2E tests: $distro"
echo "============================================================" echo "============================================================"
MOUNT_NIX=""
if [[ "$distro" == "arch" ]]; then
MOUNT_NIX="-v pkgmgr_nix_store:/nix"
fi
docker run --rm \ docker run --rm \
-v "$(pwd):/src" \ -v "$(pwd):/src" \
$MOUNT_NIX \ -v pkgmgr_nix_store:/nix \
-v "pkgmgr_nix_cache:/root/.cache/nix" \ -v "pkgmgr_nix_cache:/root/.cache/nix" \
-e PKGMGR_DEV=1 \ -e PKGMGR_DEV=1 \
-e TEST_PATTERN="${TEST_PATTERN}" \ -e TEST_PATTERN="${TEST_PATTERN}" \

View File

@@ -7,6 +7,7 @@ echo "============================================================"
docker run --rm \ docker run --rm \
-v "$(pwd):/src" \ -v "$(pwd):/src" \
-v pkgmgr_nix_store:/nix \
-v "pkgmgr_nix_cache:/root/.cache/nix" \ -v "pkgmgr_nix_cache:/root/.cache/nix" \
--workdir /src \ --workdir /src \
-e PKGMGR_DEV=1 \ -e PKGMGR_DEV=1 \

View File

@@ -8,6 +8,7 @@ echo "============================================================"
docker run --rm \ docker run --rm \
-v "$(pwd):/src" \ -v "$(pwd):/src" \
-v "pkgmgr_nix_cache:/root/.cache/nix" \ -v "pkgmgr_nix_cache:/root/.cache/nix" \
-v pkgmgr_nix_store:/nix \
--workdir /src \ --workdir /src \
-e PKGMGR_DEV=1 \ -e PKGMGR_DEV=1 \
-e TEST_PATTERN="${TEST_PATTERN}" \ -e TEST_PATTERN="${TEST_PATTERN}" \