Skip to content

fix: document cbox-init Management API and fix env var inconsistencies #16

fix: document cbox-init Management API and fix env var inconsistencies

fix: document cbox-init Management API and fix env var inconsistencies #16

Workflow file for this run

name: E2E Tests
on:
push:
branches: [main]
paths:
- 'php-base/**'
- 'php-fpm/**'
- 'php-fpm-nginx/**'
- 'common/**'
- 'tests/e2e/**'
- '.github/workflows/e2e-tests.yml'
pull_request:
branches: [main]
paths:
- 'php-base/**'
- 'php-fpm/**'
- 'php-fpm-nginx/**'
- 'common/**'
- 'tests/e2e/**'
- '.github/workflows/e2e-tests.yml'
workflow_dispatch:
inputs:
php_version:
description: 'PHP version to test'
required: false
default: '8.3'
type: choice
options:
- '8.2'
- '8.3'
- '8.4'
os_variant:
description: 'OS variant to test'
required: false
default: 'bookworm'
type: choice
options:
- 'bookworm'
scenario:
description: 'Test scenario to run'
required: false
default: 'all'
type: choice
options:
- 'all'
- 'plain-php'
- 'health-checks'
- 'image-formats'
env:
REGISTRY: ghcr.io/cboxdk/php-baseimages
jobs:
# Quick smoke test on every push - builds entire chain locally
smoke-test:
if: github.event_name != 'workflow_dispatch'
runs-on: [self-hosted, linux, ax41]
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Read Cbox Init version
id: versions
run: |
echo "CBOX_INIT_VERSION=$(jq -r '.tools.cbox_init' versions.json)" >> $GITHUB_OUTPUT
- name: Download and verify Cbox Init binaries
run: |
mkdir -p cbox-init/binaries
VERSION="${{ steps.versions.outputs.CBOX_INIT_VERSION }}"
BASE_URL="https://github.com/cboxdk/init/releases/download/v${VERSION}"
echo "Downloading Cbox Init v${VERSION}..."
curl -fsSL "${BASE_URL}/cbox-init-linux-amd64" -o cbox-init/binaries/cbox-init-linux-amd64
curl -fsSL "${BASE_URL}/cbox-init-linux-arm64" -o cbox-init/binaries/cbox-init-linux-arm64
curl -fsSL "${BASE_URL}/checksums.txt" -o cbox-init/binaries/checksums.txt
echo "Verifying SHA256 checksums..."
cd cbox-init/binaries
grep -E "cbox-init-linux-(amd64|arm64)$" checksums.txt | sha256sum -c -
cd -
chmod +x cbox-init/binaries/cbox-init-*
- name: Build image chain (php-base → php-fpm → php-fpm-nginx)
run: |
echo "=== Building php-base:8.3-bookworm ==="
docker build --target root --build-arg PHP_VERSION=8.3 \
-f php-base/Dockerfile \
-t ghcr.io/cboxdk/php-baseimages/php-base:8.3-bookworm .
echo "=== Building php-fpm:8.3-bookworm ==="
docker build --target root --build-arg PHP_VERSION=8.3 \
-f php-fpm/Dockerfile \
-t ghcr.io/cboxdk/php-baseimages/php-fpm:8.3-bookworm .
echo "=== Building php-fpm-nginx:8.3-bookworm ==="
docker build --target root --build-arg PHP_VERSION=8.3 \
-f php-fpm-nginx/Dockerfile \
-t test-image:local .
- name: Run plain PHP E2E test
env:
IMAGE: test-image:local
VERBOSE: "true"
run: |
chmod +x tests/e2e/run-e2e-tests.sh
chmod +x tests/e2e/scenarios/*.sh
chmod +x tests/e2e/lib/*.sh
tests/e2e/run-e2e-tests.sh "$IMAGE" plain-php
- name: Run health check E2E test
env:
IMAGE: test-image:local
VERBOSE: "true"
run: |
tests/e2e/run-e2e-tests.sh "$IMAGE" health-checks
- name: Run image formats test
env:
IMAGE: test-image:local
VERBOSE: "true"
run: |
tests/e2e/run-e2e-tests.sh "$IMAGE" image-formats
# Full matrix test (manual trigger)
full-matrix:
if: github.event_name == 'workflow_dispatch'
runs-on: [self-hosted, linux, ax41]
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Read Cbox Init version
id: versions
run: |
echo "CBOX_INIT_VERSION=$(jq -r '.tools.cbox_init' versions.json)" >> $GITHUB_OUTPUT
- name: Download and verify Cbox Init binaries
run: |
mkdir -p cbox-init/binaries
VERSION="${{ steps.versions.outputs.CBOX_INIT_VERSION }}"
BASE_URL="https://github.com/cboxdk/init/releases/download/v${VERSION}"
echo "Downloading Cbox Init v${VERSION}..."
curl -fsSL "${BASE_URL}/cbox-init-linux-amd64" -o cbox-init/binaries/cbox-init-linux-amd64
curl -fsSL "${BASE_URL}/cbox-init-linux-arm64" -o cbox-init/binaries/cbox-init-linux-arm64
curl -fsSL "${BASE_URL}/checksums.txt" -o cbox-init/binaries/checksums.txt
echo "Verifying SHA256 checksums..."
cd cbox-init/binaries
grep -E "cbox-init-linux-(amd64|arm64)$" checksums.txt | sha256sum -c -
cd -
chmod +x cbox-init/binaries/cbox-init-*
- name: Determine Dockerfile paths
id: paths
run: |
echo "base=php-base/Dockerfile" >> $GITHUB_OUTPUT
echo "fpm=php-fpm/Dockerfile" >> $GITHUB_OUTPUT
echo "nginx=php-fpm-nginx/Dockerfile" >> $GITHUB_OUTPUT
- name: Build image chain
run: |
PHP="${{ github.event.inputs.php_version }}"
OS="${{ github.event.inputs.os_variant }}"
echo "=== Building php-base:${PHP}-${OS} ==="
docker build --target root --build-arg PHP_VERSION=${PHP} \
-f ${{ steps.paths.outputs.base }} \
-t ghcr.io/cboxdk/php-baseimages/php-base:${PHP}-${OS} .
echo "=== Building php-fpm:${PHP}-${OS} ==="
docker build --target root --build-arg PHP_VERSION=${PHP} \
-f ${{ steps.paths.outputs.fpm }} \
-t ghcr.io/cboxdk/php-baseimages/php-fpm:${PHP}-${OS} .
echo "=== Building php-fpm-nginx:${PHP}-${OS} ==="
docker build --target root --build-arg PHP_VERSION=${PHP} \
-f ${{ steps.paths.outputs.nginx }} \
-t test-image:${PHP}-${OS} .
- name: Run E2E tests
env:
IMAGE: test-image:${{ github.event.inputs.php_version }}-${{ github.event.inputs.os_variant }}
SCENARIO: ${{ github.event.inputs.scenario }}
run: |
chmod +x tests/e2e/run-e2e-tests.sh
chmod +x tests/e2e/scenarios/*.sh
chmod +x tests/e2e/lib/*.sh
tests/e2e/run-e2e-tests.sh "$IMAGE" "$SCENARIO"
- name: Upload test logs on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: e2e-logs-${{ github.event.inputs.php_version }}-${{ github.event.inputs.os_variant }}
path: /tmp/e2e-*.log
retention-days: 7