Refactor CI distro handling and container build scripts
- Introduce a GitHub Actions matrix for `test-container` and `test-e2e` to run against arch, debian, ubuntu, fedora, and centos - Run unit and integration tests only in the Arch container by passing `distro="arch"` via make in the corresponding workflows - Replace the global DISTROS loop with a single `distro` variable in the Makefile, defaulting to `arch`, and export it for all scripts - Update build scripts (build-image, build-image-no-cache, build-image-missing) to build images for the selected distro only - Simplify test-container script to validate a single distro image using the `distro` environment variable - Simplify E2E, unit, and integration test scripts to run against a single distro container instead of iterating over all distros https://chatgpt.com/share/693acbba-9e30-800f-94fb-fea4489e9078
This commit is contained in:
10
.github/workflows/test-container.yml
vendored
10
.github/workflows/test-container.yml
vendored
@@ -7,6 +7,10 @@ jobs:
|
|||||||
test-container:
|
test-container:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
distro: [arch, debian, ubuntu, fedora, centos]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -15,5 +19,7 @@ jobs:
|
|||||||
- name: Show Docker version
|
- name: Show Docker version
|
||||||
run: docker version
|
run: docker version
|
||||||
|
|
||||||
- name: Run container tests
|
- name: Run container tests (${{ matrix.distro }})
|
||||||
run: make test-container
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
distro="${{ matrix.distro }}" make test-container
|
||||||
|
|||||||
12
.github/workflows/test-e2e.yml
vendored
12
.github/workflows/test-e2e.yml
vendored
@@ -6,7 +6,11 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
test-e2e:
|
test-e2e:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
timeout-minutes: 60 # E2E + all distros can be heavier
|
timeout-minutes: 60 # E2E can be heavier
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
distro: [arch, debian, ubuntu, fedora, centos]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -15,5 +19,7 @@ jobs:
|
|||||||
- name: Show Docker version
|
- name: Show Docker version
|
||||||
run: docker version
|
run: docker version
|
||||||
|
|
||||||
- name: Run E2E tests via make (all distros)
|
- name: Run E2E tests via make (${{ matrix.distro }})
|
||||||
run: make test-e2e
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
distro="${{ matrix.distro }}" make test-e2e
|
||||||
|
|||||||
2
.github/workflows/test-integration.yml
vendored
2
.github/workflows/test-integration.yml
vendored
@@ -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 DISTROS="arch"
|
run: make test-integration distro="arch"
|
||||||
|
|||||||
2
.github/workflows/test-unit.yml
vendored
2
.github/workflows/test-unit.yml
vendored
@@ -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 DISTROS="arch"
|
run: make test-unit distro="arch"
|
||||||
|
|||||||
9
Makefile
9
Makefile
@@ -2,11 +2,15 @@
|
|||||||
test build build-no-cache test-unit test-e2e test-integration \
|
test build build-no-cache test-unit test-e2e test-integration \
|
||||||
test-container
|
test-container
|
||||||
|
|
||||||
|
# Distro
|
||||||
|
# Options: arch debian ubuntu fedora centos
|
||||||
|
distro ?= arch
|
||||||
|
export distro
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# Distro list and base images
|
# Base images
|
||||||
# (kept for documentation/reference; actual build logic is in scripts/build)
|
# (kept for documentation/reference; actual build logic is in scripts/build)
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
DISTROS := arch debian ubuntu fedora centos
|
|
||||||
BASE_IMAGE_ARCH := archlinux:latest
|
BASE_IMAGE_ARCH := archlinux:latest
|
||||||
BASE_IMAGE_DEBIAN := debian:stable-slim
|
BASE_IMAGE_DEBIAN := debian:stable-slim
|
||||||
BASE_IMAGE_UBUNTU := ubuntu:latest
|
BASE_IMAGE_UBUNTU := ubuntu:latest
|
||||||
@@ -14,7 +18,6 @@ BASE_IMAGE_FEDORA := fedora:latest
|
|||||||
BASE_IMAGE_CENTOS := quay.io/centos/centos:stream9
|
BASE_IMAGE_CENTOS := quay.io/centos/centos:stream9
|
||||||
|
|
||||||
# Make them available in scripts
|
# Make them available in scripts
|
||||||
export DISTROS
|
|
||||||
export BASE_IMAGE_ARCH
|
export BASE_IMAGE_ARCH
|
||||||
export BASE_IMAGE_DEBIAN
|
export BASE_IMAGE_DEBIAN
|
||||||
export BASE_IMAGE_UBUNTU
|
export BASE_IMAGE_UBUNTU
|
||||||
|
|||||||
@@ -4,32 +4,21 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/resolve-base-image.sh"
|
source "${SCRIPT_DIR}/resolve-base-image.sh"
|
||||||
|
|
||||||
echo "============================================================"
|
IMAGE="package-manager-test-$distro"
|
||||||
echo ">>> Building ONLY missing container images"
|
BASE_IMAGE="$(resolve_base_image "$distro")"
|
||||||
echo "============================================================"
|
|
||||||
|
|
||||||
for distro in $DISTROS; do
|
if docker image inspect "$IMAGE" >/dev/null 2>&1; then
|
||||||
IMAGE="package-manager-test-$distro"
|
|
||||||
BASE_IMAGE="$(resolve_base_image "$distro")"
|
|
||||||
|
|
||||||
if docker image inspect "$IMAGE" >/dev/null 2>&1; then
|
|
||||||
echo "[build-missing] Image already exists: $IMAGE (skipping)"
|
echo "[build-missing] Image already exists: $IMAGE (skipping)"
|
||||||
continue
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "------------------------------------------------------------"
|
echo "------------------------------------------------------------"
|
||||||
echo "[build-missing] Building missing image: $IMAGE"
|
echo "[build-missing] Building missing image: $IMAGE"
|
||||||
echo "BASE_IMAGE = $BASE_IMAGE"
|
echo "BASE_IMAGE = $BASE_IMAGE"
|
||||||
echo "------------------------------------------------------------"
|
echo "------------------------------------------------------------"
|
||||||
|
|
||||||
docker build \
|
docker build \
|
||||||
--build-arg BASE_IMAGE="$BASE_IMAGE" \
|
--build-arg BASE_IMAGE="$BASE_IMAGE" \
|
||||||
-t "$IMAGE" \
|
-t "$IMAGE" \
|
||||||
.
|
.
|
||||||
done
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "============================================================"
|
|
||||||
echo ">>> build-missing: Done"
|
|
||||||
echo "============================================================"
|
|
||||||
|
|||||||
@@ -4,14 +4,12 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/resolve-base-image.sh"
|
source "${SCRIPT_DIR}/resolve-base-image.sh"
|
||||||
|
|
||||||
for distro in $DISTROS; do
|
base_image="$(resolve_base_image "$distro")"
|
||||||
base_image="$(resolve_base_image "$distro")"
|
|
||||||
|
|
||||||
echo ">>> Building test image for distro '$distro' with NO CACHE (BASE_IMAGE=$base_image)..."
|
echo ">>> Building test image for distro '$distro' with NO CACHE (BASE_IMAGE=$base_image)..."
|
||||||
|
|
||||||
docker build \
|
docker build \
|
||||||
--no-cache \
|
--no-cache \
|
||||||
--build-arg BASE_IMAGE="$base_image" \
|
--build-arg BASE_IMAGE="$base_image" \
|
||||||
-t "package-manager-test-$distro" \
|
-t "package-manager-test-$distro" \
|
||||||
.
|
.
|
||||||
done
|
|
||||||
|
|||||||
@@ -4,13 +4,11 @@ set -euo pipefail
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
source "${SCRIPT_DIR}/resolve-base-image.sh"
|
source "${SCRIPT_DIR}/resolve-base-image.sh"
|
||||||
|
|
||||||
for distro in $DISTROS; do
|
base_image="$(resolve_base_image "$distro")"
|
||||||
base_image="$(resolve_base_image "$distro")"
|
|
||||||
|
|
||||||
echo ">>> Building test image for distro '$distro' (BASE_IMAGE=$base_image)..."
|
echo ">>> Building test image for distro '$distro' (BASE_IMAGE=$base_image)..."
|
||||||
|
|
||||||
docker build \
|
docker build \
|
||||||
--build-arg BASE_IMAGE="$base_image" \
|
--build-arg BASE_IMAGE="$base_image" \
|
||||||
-t "package-manager-test-$distro" \
|
-t "package-manager-test-$distro" \
|
||||||
.
|
.
|
||||||
done
|
|
||||||
|
|||||||
@@ -1,23 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
echo "============================================================"
|
IMAGE="package-manager-test-$distro"
|
||||||
echo ">>> Running sanity test: verifying test containers start"
|
|
||||||
echo "============================================================"
|
|
||||||
|
|
||||||
for distro in $DISTROS; do
|
echo
|
||||||
IMAGE="package-manager-test-$distro"
|
echo "------------------------------------------------------------"
|
||||||
|
echo ">>> Testing container: $IMAGE"
|
||||||
|
echo "------------------------------------------------------------"
|
||||||
|
|
||||||
echo
|
echo "[test-container] Running: docker run --rm --entrypoint pkgmgr $IMAGE --help"
|
||||||
echo "------------------------------------------------------------"
|
echo
|
||||||
echo ">>> Testing container: $IMAGE"
|
|
||||||
echo "------------------------------------------------------------"
|
|
||||||
|
|
||||||
echo "[test-container] Running: docker run --rm --entrypoint pkgmgr $IMAGE --help"
|
# Run the command and capture the output
|
||||||
echo
|
if OUTPUT=$(docker run --rm \
|
||||||
|
|
||||||
# Run the command and capture the output
|
|
||||||
if OUTPUT=$(docker run --rm \
|
|
||||||
-e PKGMGR_DEV=1 \
|
-e PKGMGR_DEV=1 \
|
||||||
-v pkgmgr_nix_store_${distro}:/nix \
|
-v pkgmgr_nix_store_${distro}:/nix \
|
||||||
-v "$(pwd):/src" \
|
-v "$(pwd):/src" \
|
||||||
@@ -27,15 +22,9 @@ for distro in $DISTROS; do
|
|||||||
echo
|
echo
|
||||||
echo "[test-container] SUCCESS: $IMAGE responded to 'pkgmgr --help'"
|
echo "[test-container] SUCCESS: $IMAGE responded to 'pkgmgr --help'"
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "$OUTPUT"
|
echo "$OUTPUT"
|
||||||
echo
|
echo
|
||||||
echo "[test-container] ERROR: $IMAGE failed to run 'pkgmgr --help'"
|
echo "[test-container] ERROR: $IMAGE failed to run 'pkgmgr --help'"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
|
||||||
|
|
||||||
echo
|
|
||||||
echo "============================================================"
|
|
||||||
echo ">>> All containers passed the sanity check"
|
|
||||||
echo "============================================================"
|
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
echo ">>> Running E2E tests in all distros: $DISTROS"
|
echo "============================================================"
|
||||||
|
echo ">>> Running E2E tests: $distro"
|
||||||
|
echo "============================================================"
|
||||||
|
|
||||||
for distro in $DISTROS; do
|
docker run --rm \
|
||||||
echo "============================================================"
|
|
||||||
echo ">>> Running E2E tests: $distro"
|
|
||||||
echo "============================================================"
|
|
||||||
|
|
||||||
docker run --rm \
|
|
||||||
-v "$(pwd):/src" \
|
-v "$(pwd):/src" \
|
||||||
-v "pkgmgr_nix_store_${distro}:/nix" \
|
-v "pkgmgr_nix_store_${distro}:/nix" \
|
||||||
-v "pkgmgr_nix_cache_${distro}:/root/.cache/nix" \
|
-v "pkgmgr_nix_cache_${distro}:/root/.cache/nix" \
|
||||||
@@ -61,4 +58,3 @@ for distro in $DISTROS; do
|
|||||||
-s /src/tests/e2e \
|
-s /src/tests/e2e \
|
||||||
-p "$TEST_PATTERN"
|
-p "$TEST_PATTERN"
|
||||||
'
|
'
|
||||||
done
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
: "${distro:=arch}"
|
|
||||||
|
|
||||||
echo "============================================================"
|
echo "============================================================"
|
||||||
echo ">>> Running INTEGRATION tests in ${distro} container"
|
echo ">>> Running INTEGRATION tests in ${distro} container"
|
||||||
echo "============================================================"
|
echo "============================================================"
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
: "${distro:=arch}"
|
|
||||||
|
|
||||||
echo "============================================================"
|
echo "============================================================"
|
||||||
echo ">>> Running UNIT tests in ${distro} container"
|
echo ">>> Running UNIT tests in ${distro} container"
|
||||||
echo "============================================================"
|
echo "============================================================"
|
||||||
|
|||||||
Reference in New Issue
Block a user