Some checks failed
CI / test-unit (push) Has been cancelled
CI / test-integration (push) Has been cancelled
CI / test-env-virtual (push) Has been cancelled
CI / test-env-nix (push) Has been cancelled
CI / test-e2e (push) Has been cancelled
CI / test-virgin-user (push) Has been cancelled
CI / test-virgin-root (push) Has been cancelled
CI / codesniffer-shellcheck (push) Has been cancelled
CI / codesniffer-ruff (push) Has been cancelled
Mark stable commit / test-unit (push) Has been cancelled
Mark stable commit / test-integration (push) Has been cancelled
Mark stable commit / test-env-virtual (push) Has been cancelled
Mark stable commit / test-env-nix (push) Has been cancelled
Mark stable commit / test-e2e (push) Has been cancelled
Mark stable commit / test-virgin-user (push) Has been cancelled
Mark stable commit / test-virgin-root (push) Has been cancelled
Mark stable commit / codesniffer-shellcheck (push) Has been cancelled
Mark stable commit / codesniffer-ruff (push) Has been cancelled
Mark stable commit / mark-stable (push) Has been cancelled
Add a reusable retry helper that detects GitHub API 403 rate-limit errors during Nix flake evaluation and retries with exponential backoff. Apply the retry logic to flake-only CI tests so transient GitHub rate limits no longer cause random CI failures while preserving fast failure for real errors. https://chatgpt.com/share/693d7ec5-ac70-800f-a627-ef705c653ba1
63 lines
2.1 KiB
Bash
Executable File
63 lines
2.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
IMAGE="pkgmgr-${PKGMGR_DISTRO}"
|
|
|
|
echo "============================================================"
|
|
echo ">>> Running Nix flake-only test in ${PKGMGR_DISTRO} container"
|
|
echo ">>> Image: ${IMAGE}"
|
|
echo "============================================================"
|
|
|
|
docker run --rm \
|
|
-v "$(pwd):/src" \
|
|
-v "pkgmgr_nix_store_${PKGMGR_DISTRO}:/nix" \
|
|
-v "pkgmgr_nix_cache_${PKGMGR_DISTRO}:/root/.cache/nix" \
|
|
--workdir /src \
|
|
-e REINSTALL_PKGMGR=1 \
|
|
"${IMAGE}" \
|
|
bash -lc '
|
|
set -euo pipefail
|
|
|
|
if command -v git >/dev/null 2>&1; then
|
|
git config --global --add safe.directory /src || true
|
|
git config --global --add safe.directory /src/.git || true
|
|
git config --global --add safe.directory "*" || true
|
|
fi
|
|
|
|
echo ">>> preflight: nix must exist in image"
|
|
if ! command -v nix >/dev/null 2>&1; then
|
|
echo "NO_NIX"
|
|
echo "ERROR: nix not found in image '"${IMAGE}"' (PKGMGR_DISTRO='"${PKGMGR_DISTRO}"')"
|
|
echo "HINT: Ensure Nix is installed during image build for this distro."
|
|
exit 1
|
|
fi
|
|
|
|
echo ">>> nix version"
|
|
nix --version
|
|
|
|
# ------------------------------------------------------------
|
|
# Retry helper for GitHub API rate-limit (HTTP 403)
|
|
# ------------------------------------------------------------
|
|
if [[ -f /src/scripts/nix/lib/retry_403.sh ]]; then
|
|
# shellcheck source=./scripts/nix/lib/retry_403.sh
|
|
source /src/scripts/nix/lib/retry_403.sh
|
|
elif [[ -f ./scripts/nix/lib/retry_403.sh ]]; then
|
|
# shellcheck source=./scripts/nix/lib/retry_403.sh
|
|
source ./scripts/nix/lib/retry_403.sh
|
|
else
|
|
echo "ERROR: retry helper not found: scripts/nix/lib/retry_403.sh"
|
|
exit 1
|
|
fi
|
|
|
|
echo ">>> nix flake show"
|
|
run_with_github_403_retry nix flake show . --no-write-lock-file >/dev/null
|
|
|
|
echo ">>> nix build .#default"
|
|
run_with_github_403_retry nix build .#default --no-link --no-write-lock-file
|
|
|
|
echo ">>> nix run .#pkgmgr -- --help"
|
|
run_with_github_403_retry nix run .#pkgmgr -- --help --no-write-lock-file
|
|
|
|
echo ">>> OK: Nix flake-only test succeeded."
|
|
'
|