From 57a2b4ec6c30a289d99eba0af03852020984def2 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Wed, 17 Dec 2025 22:53:21 +0100 Subject: [PATCH] ci: pass NIX_CONFIG with GitHub token into all test containers - Add NIX_CONFIG with GitHub access token to all CI test workflows - Export NIX_CONFIG in Makefile for propagation to test scripts - Forward NIX_CONFIG explicitly into all docker run invocations - Prevent GitHub API rate limit errors during Nix-based tests https://chatgpt.com/share/69432655-a948-800f-8c0d-353921cdf644 --- .github/workflows/test-e2e.yml | 4 +++- .github/workflows/test-env-nix.yml | 4 +++- .github/workflows/test-env-virtual.yml | 4 +++- .github/workflows/test-integration.yml | 4 +++- .github/workflows/test-unit.yml | 4 +++- .github/workflows/test-virgin-root.yml | 7 ++++--- .github/workflows/test-virgin-user.yml | 7 ++++--- Makefile | 4 ++++ scripts/test/test-e2e.sh | 1 + scripts/test/test-env-nix.sh | 1 + scripts/test/test-env-virtual.sh | 1 + scripts/test/test-integration.sh | 1 + scripts/test/test-unit.sh | 1 + 13 files changed, 32 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test-e2e.yml b/.github/workflows/test-e2e.yml index 60b4da8..174425b 100644 --- a/.github/workflows/test-e2e.yml +++ b/.github/workflows/test-e2e.yml @@ -11,7 +11,9 @@ jobs: fail-fast: false matrix: distro: [arch, debian, ubuntu, fedora, centos] - + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/test-env-nix.yml b/.github/workflows/test-env-nix.yml index 4161fb6..968a180 100644 --- a/.github/workflows/test-env-nix.yml +++ b/.github/workflows/test-env-nix.yml @@ -12,7 +12,9 @@ jobs: fail-fast: false matrix: distro: [arch, debian, ubuntu, fedora, centos] - + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/test-env-virtual.yml b/.github/workflows/test-env-virtual.yml index f5f59d8..8052726 100644 --- a/.github/workflows/test-env-virtual.yml +++ b/.github/workflows/test-env-virtual.yml @@ -11,7 +11,9 @@ jobs: fail-fast: false matrix: distro: [arch, debian, ubuntu, fedora, centos] - + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/test-integration.yml b/.github/workflows/test-integration.yml index 2e44b67..2436d96 100644 --- a/.github/workflows/test-integration.yml +++ b/.github/workflows/test-integration.yml @@ -7,7 +7,9 @@ jobs: test-integration: runs-on: ubuntu-latest timeout-minutes: 30 - + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/test-unit.yml b/.github/workflows/test-unit.yml index 9dfc9f7..0b25f05 100644 --- a/.github/workflows/test-unit.yml +++ b/.github/workflows/test-unit.yml @@ -7,7 +7,9 @@ jobs: test-unit: runs-on: ubuntu-latest timeout-minutes: 30 - + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository uses: actions/checkout@v4 diff --git a/.github/workflows/test-virgin-root.yml b/.github/workflows/test-virgin-root.yml index e32da96..4399b76 100644 --- a/.github/workflows/test-virgin-root.yml +++ b/.github/workflows/test-virgin-root.yml @@ -11,7 +11,9 @@ jobs: fail-fast: false matrix: distro: [arch, debian, ubuntu, fedora, centos] - + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -19,13 +21,11 @@ jobs: - name: Show Docker version run: docker version - # 🔹 BUILD virgin image if missing - name: Build virgin container (${{ matrix.distro }}) run: | set -euo pipefail PKGMGR_DISTRO="${{ matrix.distro }}" make build-missing-virgin - # 🔹 RUN test inside virgin image - name: Virgin ${{ matrix.distro }} pkgmgr test (root) run: | set -euo pipefail @@ -34,6 +34,7 @@ jobs: -v "$PWD":/opt/src/pkgmgr \ -v pkgmgr_repos:/root/Repositories \ -v pkgmgr_pip_cache:/root/.cache/pip \ + -e NIX_CONFIG="${NIX_CONFIG}" \ -w /opt/src/pkgmgr \ "pkgmgr-${{ matrix.distro }}-virgin" \ bash -lc ' diff --git a/.github/workflows/test-virgin-user.yml b/.github/workflows/test-virgin-user.yml index 0a6c4af..d2ecd63 100644 --- a/.github/workflows/test-virgin-user.yml +++ b/.github/workflows/test-virgin-user.yml @@ -11,7 +11,9 @@ jobs: fail-fast: false matrix: distro: [arch, debian, ubuntu, fedora, centos] - + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository uses: actions/checkout@v4 @@ -19,19 +21,18 @@ jobs: - name: Show Docker version run: docker version - # 🔹 BUILD virgin image if missing - name: Build virgin container (${{ matrix.distro }}) run: | set -euo pipefail PKGMGR_DISTRO="${{ matrix.distro }}" make build-missing-virgin - # 🔹 RUN test inside virgin image as non-root - name: Virgin ${{ matrix.distro }} pkgmgr test (user) run: | set -euo pipefail docker run --rm \ -v "$PWD":/opt/src/pkgmgr \ + -e NIX_CONFIG="${NIX_CONFIG}" \ -w /opt/src/pkgmgr \ "pkgmgr-${{ matrix.distro }}-virgin" \ bash -lc ' diff --git a/Makefile b/Makefile index e9a6a4b..350199c 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,10 @@ DISTROS ?= arch debian ubuntu fedora centos PKGMGR_DISTRO ?= arch export PKGMGR_DISTRO +# Nix Config Variable (To avoid rate limit) +NIX_CONFIG ?= "" +export NIX_CONFIG + # ------------------------------------------------------------ # Base images # (kept for documentation/reference; actual build logic is in scripts/build) diff --git a/scripts/test/test-e2e.sh b/scripts/test/test-e2e.sh index 96b1c43..e387391 100755 --- a/scripts/test/test-e2e.sh +++ b/scripts/test/test-e2e.sh @@ -11,6 +11,7 @@ docker run --rm \ -v "pkgmgr_nix_cache_${PKGMGR_DISTRO}:/root/.cache/nix" \ -e REINSTALL_PKGMGR=1 \ -e TEST_PATTERN="${TEST_PATTERN}" \ + -e NIX_CONFIG="${NIX_CONFIG}" \ --workdir /opt/src/pkgmgr \ "pkgmgr-${PKGMGR_DISTRO}" \ bash -lc ' diff --git a/scripts/test/test-env-nix.sh b/scripts/test/test-env-nix.sh index ccd3f3f..0014d5d 100755 --- a/scripts/test/test-env-nix.sh +++ b/scripts/test/test-env-nix.sh @@ -14,6 +14,7 @@ docker run --rm \ -v "pkgmgr_nix_cache_${PKGMGR_DISTRO}:/root/.cache/nix" \ --workdir /opt/src/pkgmgr \ -e REINSTALL_PKGMGR=1 \ + -e NIX_CONFIG="${NIX_CONFIG}" \ "${IMAGE}" \ bash -lc ' set -euo pipefail diff --git a/scripts/test/test-env-virtual.sh b/scripts/test/test-env-virtual.sh index c7aafd0..0c8aefc 100755 --- a/scripts/test/test-env-virtual.sh +++ b/scripts/test/test-env-virtual.sh @@ -19,6 +19,7 @@ if OUTPUT=$(docker run --rm \ -e REINSTALL_PKGMGR=1 \ -v "$(pwd):/opt/src/pkgmgr" \ -w /opt/src/pkgmgr \ + -e NIX_CONFIG="${NIX_CONFIG}" \ "${IMAGE}" \ bash -lc ' set -euo pipefail diff --git a/scripts/test/test-integration.sh b/scripts/test/test-integration.sh index 7aeaf94..3cf4828 100755 --- a/scripts/test/test-integration.sh +++ b/scripts/test/test-integration.sh @@ -12,6 +12,7 @@ docker run --rm \ --workdir /opt/src/pkgmgr \ -e REINSTALL_PKGMGR=1 \ -e TEST_PATTERN="${TEST_PATTERN}" \ + -e NIX_CONFIG="${NIX_CONFIG}" \ "pkgmgr-${PKGMGR_DISTRO}" \ bash -lc ' set -e; diff --git a/scripts/test/test-unit.sh b/scripts/test/test-unit.sh index 03e339d..6cfedc6 100755 --- a/scripts/test/test-unit.sh +++ b/scripts/test/test-unit.sh @@ -12,6 +12,7 @@ docker run --rm \ --workdir /opt/src/pkgmgr \ -e REINSTALL_PKGMGR=1 \ -e TEST_PATTERN="${TEST_PATTERN}" \ + -e NIX_CONFIG="${NIX_CONFIG}" \ "pkgmgr-${PKGMGR_DISTRO}" \ bash -lc ' set -e;