From 37ac22e0b4f10cd58cede7c1be639acd14358d9f Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 10 Dec 2025 20:07:41 +0100 Subject: [PATCH] test: isolate Nix store/cache per distro to fix cross-distro manifest conflicts - Replace shared Nix volumes with distro-specific volumes (pkgmgr_nix_store_, pkgmgr_nix_cache_) - Prevent incompatible profile manifest versions between Ubuntu and Debian - Update all test scripts (unit, integration, container, e2e) - Remove unused global Nix volume variables from Makefile - Improve consistency of test-e2e.sh formatting and environment handling - Add Git safe.directory configuration for mounted /src to avoid ownership warnings --- Makefile | 6 ------ scripts/test/test-container.sh | 4 ++-- scripts/test/test-e2e.sh | 31 +++++++++++++++++-------------- scripts/test/test-integration.sh | 4 ++-- scripts/test/test-unit.sh | 4 ++-- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 5849669..06edc1e 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,6 @@ test build build-no-cache test-unit test-e2e test-integration \ test-container -# ------------------------------------------------------------ -# Local Nix cache directories in the repo -# ------------------------------------------------------------ -NIX_STORE_VOLUME := pkgmgr_nix_store -NIX_CACHE_VOLUME := pkgmgr_nix_cache - # ------------------------------------------------------------ # Distro list and base images # (kept for documentation/reference; actual build logic is in scripts/build) diff --git a/scripts/test/test-container.sh b/scripts/test/test-container.sh index 17c2acd..b5b7b03 100755 --- a/scripts/test/test-container.sh +++ b/scripts/test/test-container.sh @@ -19,9 +19,9 @@ for distro in $DISTROS; do # Run the command and capture the output if OUTPUT=$(docker run --rm \ -e PKGMGR_DEV=1 \ - -v pkgmgr_nix_store:/nix \ + -v pkgmgr_nix_store_${distro}:/nix \ -v "$(pwd):/src" \ - -v "pkgmgr_nix_cache:/root/.cache/nix" \ + -v "pkgmgr_nix_cache_${distro}:/root/.cache/nix" \ "$IMAGE" 2>&1); then echo "$OUTPUT" echo diff --git a/scripts/test/test-e2e.sh b/scripts/test/test-e2e.sh index 0559c65..4ebf79d 100755 --- a/scripts/test/test-e2e.sh +++ b/scripts/test/test-e2e.sh @@ -10,43 +10,46 @@ for distro in $DISTROS; do docker run --rm \ -v "$(pwd):/src" \ - -v pkgmgr_nix_store:/nix \ - -v "pkgmgr_nix_cache:/root/.cache/nix" \ + -v pkgmgr_nix_store_${distro}:/nix \ + -v "pkgmgr_nix_cache_${distro}:/root/.cache/nix" \ -e PKGMGR_DEV=1 \ -e TEST_PATTERN="${TEST_PATTERN}" \ --workdir /src \ --entrypoint bash \ "package-manager-test-$distro" \ -c ' - set -e; + set -e + # Load distro info if [ -f /etc/os-release ]; then - . /etc/os-release; - fi; + . /etc/os-release + fi - echo "Running tests inside distro: $ID"; + echo "Running tests inside distro: $ID" - # Try to load nix environment + # Load nix environment if available if [ -f "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh" ]; then - . "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh"; + . "/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh" fi if [ -f "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then - . "$HOME/.nix-profile/etc/profile.d/nix.sh"; + . "$HOME/.nix-profile/etc/profile.d/nix.sh" fi - PATH="/nix/var/nix/profiles/default/bin:$HOME/.nix-profile/bin:$PATH"; + PATH="/nix/var/nix/profiles/default/bin:$HOME/.nix-profile/bin:$PATH" command -v nix >/dev/null || { - echo "ERROR: nix not found."; - exit 1; + echo "ERROR: nix not found." + exit 1 } - git config --global --add safe.directory /src || true; + # Mark the mounted repository as safe to avoid Git ownership errors + git config --global --add safe.directory /src || true + # Run the E2E tests inside the Nix development shell nix develop .#default --no-write-lock-file -c \ python3 -m unittest discover \ -s /src/tests/e2e \ - -p "$TEST_PATTERN"; + -p "$TEST_PATTERN" ' done diff --git a/scripts/test/test-integration.sh b/scripts/test/test-integration.sh index a1caedd..639758e 100755 --- a/scripts/test/test-integration.sh +++ b/scripts/test/test-integration.sh @@ -7,8 +7,8 @@ echo "============================================================" docker run --rm \ -v "$(pwd):/src" \ - -v pkgmgr_nix_store:/nix \ - -v "pkgmgr_nix_cache:/root/.cache/nix" \ + -v pkgmgr_nix_store_${distro}:/nix \ + -v "pkgmgr_nix_cache_${distro}:/root/.cache/nix" \ --workdir /src \ -e PKGMGR_DEV=1 \ -e TEST_PATTERN="${TEST_PATTERN}" \ diff --git a/scripts/test/test-unit.sh b/scripts/test/test-unit.sh index b39f034..98af826 100755 --- a/scripts/test/test-unit.sh +++ b/scripts/test/test-unit.sh @@ -7,8 +7,8 @@ echo "============================================================" docker run --rm \ -v "$(pwd):/src" \ - -v "pkgmgr_nix_cache:/root/.cache/nix" \ - -v pkgmgr_nix_store:/nix \ + -v "pkgmgr_nix_cache_${distro}:/root/.cache/nix" \ + -v pkgmgr_nix_store_${distro}:/nix \ --workdir /src \ -e PKGMGR_DEV=1 \ -e TEST_PATTERN="${TEST_PATTERN}" \