refactor(ci,build,test): rename distro to PKGMGR_DISTRO for consistent environment handling
Some checks failed
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

https://chatgpt.com/share/693d6b63-12cc-800f-b55f-abc52ee7fb52
This commit is contained in:
Kevin Veen-Birkenbach
2025-12-13 14:34:15 +01:00
parent b8acd634f8
commit 4e28eba883
16 changed files with 42 additions and 42 deletions

View File

@@ -22,4 +22,4 @@ jobs:
- name: Run E2E tests via make (${{ matrix.distro }}) - name: Run E2E tests via make (${{ matrix.distro }})
run: | run: |
set -euo pipefail set -euo pipefail
distro="${{ matrix.distro }}" make test-e2e PKGMGR_DISTRO="${{ matrix.distro }}" make test-e2e

View File

@@ -23,4 +23,4 @@ jobs:
- name: Nix flake-only test (${{ matrix.distro }}) - name: Nix flake-only test (${{ matrix.distro }})
run: | run: |
set -euo pipefail set -euo pipefail
distro="${{ matrix.distro }}" make test-env-nix PKGMGR_DISTRO="${{ matrix.distro }}" make test-env-nix

View File

@@ -25,4 +25,4 @@ jobs:
- name: Run container tests (${{ matrix.distro }}) - name: Run container tests (${{ matrix.distro }})
run: | run: |
set -euo pipefail set -euo pipefail
distro="${{ matrix.distro }}" make test-env-virtual PKGMGR_DISTRO="${{ matrix.distro }}" make test-env-virtual

View File

@@ -16,4 +16,4 @@ jobs:
run: docker version run: docker version
- name: Run integration tests via make (Arch container) - name: Run integration tests via make (Arch container)
run: make test-integration distro="arch" run: make test-integration PKGMGR_DISTRO="arch"

View File

@@ -16,4 +16,4 @@ jobs:
run: docker version run: docker version
- name: Run unit tests via make (Arch container) - name: Run unit tests via make (Arch container)
run: make test-unit distro="arch" run: make test-unit PKGMGR_DISTRO="arch"

View File

@@ -23,7 +23,7 @@ jobs:
- name: Build virgin container (${{ matrix.distro }}) - name: Build virgin container (${{ matrix.distro }})
run: | run: |
set -euo pipefail set -euo pipefail
distro="${{ matrix.distro }}" make build-missing-virgin PKGMGR_DISTRO="${{ matrix.distro }}" make build-missing-virgin
# 🔹 RUN test inside virgin image # 🔹 RUN test inside virgin image
- name: Virgin ${{ matrix.distro }} pkgmgr test (root) - name: Virgin ${{ matrix.distro }} pkgmgr test (root)

View File

@@ -23,7 +23,7 @@ jobs:
- name: Build virgin container (${{ matrix.distro }}) - name: Build virgin container (${{ matrix.distro }})
run: | run: |
set -euo pipefail set -euo pipefail
distro="${{ matrix.distro }}" make build-missing-virgin PKGMGR_DISTRO="${{ matrix.distro }}" make build-missing-virgin
# 🔹 RUN test inside virgin image as non-root # 🔹 RUN test inside virgin image as non-root
- name: Virgin ${{ matrix.distro }} pkgmgr test (user) - name: Virgin ${{ matrix.distro }} pkgmgr test (user)

View File

@@ -75,7 +75,7 @@ build-no-cache-all:
@set -e; \ @set -e; \
for d in $(DISTROS); do \ for d in $(DISTROS); do \
echo "=== build-no-cache: $$d ==="; \ echo "=== build-no-cache: $$d ==="; \
distro="$$d" $(MAKE) build-no-cache; \ PKGMGR_DISTRO="$$d" $(MAKE) build-no-cache; \
done done
# ------------------------------------------------------------ # ------------------------------------------------------------
@@ -101,7 +101,7 @@ test-env-nix: build-missing
test: test-env-virtual test-unit test-integration test-e2e test: test-env-virtual test-unit test-integration test-e2e
delete-volumes: delete-volumes:
@docker volume rm "pkgmgr_nix_store_${distro}" "pkgmgr_nix_cache_${distro}" || echo "No volumes to delete." @docker volume rm "pkgmgr_nix_store_${PKGMGR_DISTRO}" "pkgmgr_nix_cache_${PKGMGR_DISTRO}" || echo "No volumes to delete."
purge: delete-volumes build-no-cache purge: delete-volumes build-no-cache

View File

@@ -8,13 +8,13 @@ set -euo pipefail
: "${BASE_IMAGE_CENTOS:=quay.io/centos/centos:stream9}" : "${BASE_IMAGE_CENTOS:=quay.io/centos/centos:stream9}"
resolve_base_image() { resolve_base_image() {
local distro="$1" local PKGMGR_DISTRO="$1"
case "$distro" in case "$PKGMGR_DISTRO" in
arch) echo "$BASE_IMAGE_ARCH" ;; arch) echo "$BASE_IMAGE_ARCH" ;;
debian) echo "$BASE_IMAGE_DEBIAN" ;; debian) echo "$BASE_IMAGE_DEBIAN" ;;
ubuntu) echo "$BASE_IMAGE_UBUNTU" ;; ubuntu) echo "$BASE_IMAGE_UBUNTU" ;;
fedora) echo "$BASE_IMAGE_FEDORA" ;; fedora) echo "$BASE_IMAGE_FEDORA" ;;
centos) echo "$BASE_IMAGE_CENTOS" ;; centos) echo "$BASE_IMAGE_CENTOS" ;;
*) echo "ERROR: Unknown distro '$distro'" >&2; exit 1 ;; *) echo "ERROR: Unknown distro '$PKGMGR_DISTRO'" >&2; exit 1 ;;
esac esac
} }

View File

@@ -22,13 +22,13 @@ IS_STABLE="false" # "true" -> publish stable tags
DEFAULT_DISTRO="arch" DEFAULT_DISTRO="arch"
usage() { usage() {
local default_tag="pkgmgr-${distro}" local default_tag="pkgmgr-${PKGMGR_DISTRO}"
if [[ -n "${TARGET:-}" ]]; then if [[ -n "${TARGET:-}" ]]; then
default_tag="${default_tag}-${TARGET}" default_tag="${default_tag}-${TARGET}"
fi fi
cat <<EOF cat <<EOF
Usage: distro=<distro> $0 [options] Usage: PKGMGR_DISTRO=<distro> $0 [options]
Build options: Build options:
--missing Build only if the image does not already exist (local build only) --missing Build only if the image does not already exist (local build only)
@@ -103,13 +103,13 @@ done
# Derive default local tag if not provided # Derive default local tag if not provided
if [[ -z "${IMAGE_TAG}" ]]; then if [[ -z "${IMAGE_TAG}" ]]; then
IMAGE_TAG="${REPO_PREFIX}-${distro}" IMAGE_TAG="${REPO_PREFIX}-${PKGMGR_DISTRO}"
if [[ -n "${TARGET}" ]]; then if [[ -n "${TARGET}" ]]; then
IMAGE_TAG="${IMAGE_TAG}-${TARGET}" IMAGE_TAG="${IMAGE_TAG}-${TARGET}"
fi fi
fi fi
BASE_IMAGE="$(resolve_base_image "$distro")" BASE_IMAGE="$(resolve_base_image "$PKGMGR_DISTRO")"
# Local-only "missing" shortcut # Local-only "missing" shortcut
if [[ "${MISSING_ONLY}" == "1" ]]; then if [[ "${MISSING_ONLY}" == "1" ]]; then
@@ -141,7 +141,7 @@ fi
echo echo
echo "------------------------------------------------------------" echo "------------------------------------------------------------"
echo "[build] Building image" echo "[build] Building image"
echo "distro = ${distro}" echo "distro = ${PKGMGR_DISTRO}"
echo "BASE_IMAGE = ${BASE_IMAGE}" echo "BASE_IMAGE = ${BASE_IMAGE}"
if [[ -n "${TARGET}" ]]; then echo "target = ${TARGET}"; fi if [[ -n "${TARGET}" ]]; then echo "target = ${TARGET}"; fi
if [[ "${NO_CACHE}" == "1" ]]; then echo "cache = disabled"; fi if [[ "${NO_CACHE}" == "1" ]]; then echo "cache = disabled"; fi
@@ -167,14 +167,14 @@ if [[ -n "${TARGET}" ]]; then
fi fi
compute_publish_tags() { compute_publish_tags() {
local distro_tag_base="${REGISTRY}/${OWNER}/${REPO_PREFIX}-${distro}" local distro_tag_base="${REGISTRY}/${OWNER}/${REPO_PREFIX}-${PKGMGR_DISTRO}"
local alias_tag_base="" local alias_tag_base=""
if [[ -n "${TARGET}" ]]; then if [[ -n "${TARGET}" ]]; then
distro_tag_base="${distro_tag_base}-${TARGET}" distro_tag_base="${distro_tag_base}-${TARGET}"
fi fi
if [[ "${distro}" == "${DEFAULT_DISTRO}" ]]; then if [[ "${PKGMGR_DISTRO}" == "${DEFAULT_DISTRO}" ]]; then
alias_tag_base="${REGISTRY}/${OWNER}/${REPO_PREFIX}" alias_tag_base="${REGISTRY}/${OWNER}/${REPO_PREFIX}"
if [[ -n "${TARGET}" ]]; then if [[ -n "${TARGET}" ]]; then
alias_tag_base="${alias_tag_base}-${TARGET}" alias_tag_base="${alias_tag_base}-${TARGET}"

View File

@@ -30,11 +30,11 @@ echo "[publish] DISTROS=${DISTROS}"
for d in ${DISTROS}; do for d in ${DISTROS}; do
echo echo
echo "============================================================" echo "============================================================"
echo "[publish] distro=${d}" echo "[publish] PKGMGR_DISTRO=${d}"
echo "============================================================" echo "============================================================"
# virgin # virgin
distro="${d}" bash "${SCRIPT_DIR}/image.sh" \ PKGMGR_DISTRO="${d}" bash "${SCRIPT_DIR}/image.sh" \
--publish \ --publish \
--registry "${REGISTRY}" \ --registry "${REGISTRY}" \
--owner "${OWNER}" \ --owner "${OWNER}" \
@@ -43,7 +43,7 @@ for d in ${DISTROS}; do
--target virgin --target virgin
# full (default target) # full (default target)
distro="${d}" bash "${SCRIPT_DIR}/image.sh" \ PKGMGR_DISTRO="${d}" bash "${SCRIPT_DIR}/image.sh" \
--publish \ --publish \
--registry "${REGISTRY}" \ --registry "${REGISTRY}" \
--owner "${OWNER}" \ --owner "${OWNER}" \

View File

@@ -2,17 +2,17 @@
set -euo pipefail set -euo pipefail
echo "============================================================" echo "============================================================"
echo ">>> Running E2E tests: $distro" echo ">>> Running E2E tests: $PKGMGR_DISTRO"
echo "============================================================" echo "============================================================"
docker run --rm \ docker run --rm \
-v "$(pwd):/src" \ -v "$(pwd):/src" \
-v "pkgmgr_nix_store_${distro}:/nix" \ -v "pkgmgr_nix_store_${PKGMGR_DISTRO}:/nix" \
-v "pkgmgr_nix_cache_${distro}:/root/.cache/nix" \ -v "pkgmgr_nix_cache_${PKGMGR_DISTRO}:/root/.cache/nix" \
-e REINSTALL_PKGMGR=1 \ -e REINSTALL_PKGMGR=1 \
-e TEST_PATTERN="${TEST_PATTERN}" \ -e TEST_PATTERN="${TEST_PATTERN}" \
--workdir /src \ --workdir /src \
"pkgmgr-${distro}" \ "pkgmgr-${PKGMGR_DISTRO}" \
bash -lc ' bash -lc '
set -euo pipefail set -euo pipefail

View File

@@ -1,17 +1,17 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
IMAGE="pkgmgr-${distro}" IMAGE="pkgmgr-${PKGMGR_DISTRO}"
echo "============================================================" echo "============================================================"
echo ">>> Running Nix flake-only test in ${distro} container" echo ">>> Running Nix flake-only test in ${PKGMGR_DISTRO} container"
echo ">>> Image: ${IMAGE}" echo ">>> Image: ${IMAGE}"
echo "============================================================" echo "============================================================"
docker run --rm \ docker run --rm \
-v "$(pwd):/src" \ -v "$(pwd):/src" \
-v "pkgmgr_nix_store_${distro}:/nix" \ -v "pkgmgr_nix_store_${PKGMGR_DISTRO}:/nix" \
-v "pkgmgr_nix_cache_${distro}:/root/.cache/nix" \ -v "pkgmgr_nix_cache_${PKGMGR_DISTRO}:/root/.cache/nix" \
--workdir /src \ --workdir /src \
-e REINSTALL_PKGMGR=1 \ -e REINSTALL_PKGMGR=1 \
"${IMAGE}" \ "${IMAGE}" \
@@ -27,7 +27,7 @@ docker run --rm \
echo ">>> preflight: nix must exist in image" echo ">>> preflight: nix must exist in image"
if ! command -v nix >/dev/null 2>&1; then if ! command -v nix >/dev/null 2>&1; then
echo "NO_NIX" echo "NO_NIX"
echo "ERROR: nix not found in image '\'''"${IMAGE}"''\'' (distro='"${distro}"')" echo "ERROR: nix not found in image '\'''"${IMAGE}"''\'' (PKGMGR_DISTRO='"${PKGMGR_DISTRO}"')"
echo "HINT: Ensure Nix is installed during image build for this distro." echo "HINT: Ensure Nix is installed during image build for this distro."
exit 1 exit 1
fi fi

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
IMAGE="pkgmgr-$distro" IMAGE="pkgmgr-$PKGMGR_DISTRO"
echo echo
echo "------------------------------------------------------------" echo "------------------------------------------------------------"
@@ -16,9 +16,9 @@ echo
# 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 REINSTALL_PKGMGR=1 \ -e REINSTALL_PKGMGR=1 \
-v pkgmgr_nix_store_${distro}:/nix \ -v pkgmgr_nix_store_${PKGMGR_DISTRO}:/nix \
-v "$(pwd):/src" \ -v "$(pwd):/src" \
-v "pkgmgr_nix_cache_${distro}:/root/.cache/nix" \ -v "pkgmgr_nix_cache_${PKGMGR_DISTRO}:/root/.cache/nix" \
"$IMAGE" 2>&1); then "$IMAGE" 2>&1); then
echo "$OUTPUT" echo "$OUTPUT"
echo echo

View File

@@ -2,17 +2,17 @@
set -euo pipefail set -euo pipefail
echo "============================================================" echo "============================================================"
echo ">>> Running INTEGRATION tests in ${distro} container" echo ">>> Running INTEGRATION tests in ${PKGMGR_DISTRO} container"
echo "============================================================" echo "============================================================"
docker run --rm \ docker run --rm \
-v "$(pwd):/src" \ -v "$(pwd):/src" \
-v pkgmgr_nix_store_${distro}:/nix \ -v pkgmgr_nix_store_${PKGMGR_DISTRO}:/nix \
-v "pkgmgr_nix_cache_${distro}:/root/.cache/nix" \ -v "pkgmgr_nix_cache_${PKGMGR_DISTRO}:/root/.cache/nix" \
--workdir /src \ --workdir /src \
-e REINSTALL_PKGMGR=1 \ -e REINSTALL_PKGMGR=1 \
-e TEST_PATTERN="${TEST_PATTERN}" \ -e TEST_PATTERN="${TEST_PATTERN}" \
"pkgmgr-${distro}" \ "pkgmgr-${PKGMGR_DISTRO}" \
bash -lc ' bash -lc '
set -e; set -e;
git config --global --add safe.directory /src || true; git config --global --add safe.directory /src || true;

View File

@@ -2,17 +2,17 @@
set -euo pipefail set -euo pipefail
echo "============================================================" echo "============================================================"
echo ">>> Running UNIT tests in ${distro} container" echo ">>> Running UNIT tests in ${PKGMGR_DISTRO} container"
echo "============================================================" echo "============================================================"
docker run --rm \ docker run --rm \
-v "$(pwd):/src" \ -v "$(pwd):/src" \
-v "pkgmgr_nix_cache_${distro}:/root/.cache/nix" \ -v "pkgmgr_nix_cache_${PKGMGR_DISTRO}:/root/.cache/nix" \
-v pkgmgr_nix_store_${distro}:/nix \ -v pkgmgr_nix_store_${PKGMGR_DISTRO}:/nix \
--workdir /src \ --workdir /src \
-e REINSTALL_PKGMGR=1 \ -e REINSTALL_PKGMGR=1 \
-e TEST_PATTERN="${TEST_PATTERN}" \ -e TEST_PATTERN="${TEST_PATTERN}" \
"pkgmgr-${distro}" \ "pkgmgr-${PKGMGR_DISTRO}" \
bash -lc ' bash -lc '
set -e; set -e;
git config --global --add safe.directory /src || true; git config --global --add safe.directory /src || true;