From 39d4ba0284b9fd78df50a7483b7f7652835c2acc Mon Sep 17 00:00:00 2001 From: Jeppe B <2jepp9350@gmail.com> Date: Thu, 23 Apr 2026 23:40:12 +0200 Subject: [PATCH] Run unit CI inside php1 container on self-hosted runner --- .github/workflows/tests.yml | 40 +++++++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8722bca8..16ee3813 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,25 +22,35 @@ jobs: - name: Check AI workflow sync run: node scripts/sync-ai-workflow.mjs --check - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: '8.2' - extensions: mysqli, curl, openssl, json, redis, xdebug - coverage: xdebug - ini-values: variables_order=EGPCS,xdebug.mode=coverage + - name: Materialize compose env files + env: + COMPOSE_ENV: ${{ secrets.COMPOSE_ENV }} + COMPOSE_ENV_STAGING: ${{ secrets.COMPOSE_ENV_STAGING }} + run: | + set -euo pipefail + if [ -z "${COMPOSE_ENV}" ]; then + echo "Required GitHub secret COMPOSE_ENV is not configured." >&2 + exit 1 + fi + if [ -z "${COMPOSE_ENV_STAGING}" ]; then + echo "Required GitHub secret COMPOSE_ENV_STAGING is not configured." >&2 + exit 1 + fi + printf '%s\n' "$COMPOSE_ENV" > .env + printf '%s\n' "$COMPOSE_ENV_STAGING" > .env.staging + + - name: Boot php1 test stack + run: docker compose up -d redis mysql-debug php1 - name: Resolve dependencies - working-directory: services/nginx/app - run: composer update --no-interaction --prefer-dist + run: docker compose exec -T php1 sh -lc "cd /var/www/html && composer update --no-interaction --prefer-dist" - name: Run unit tests - working-directory: services/nginx/app - run: composer test:unit + run: docker compose exec -T php1 sh -lc "cd /var/www/html && composer test:unit" - name: Generate coverage report - working-directory: services/nginx/app - run: composer test:coverage + run: | + docker compose exec -T php1 sh -lc "cd /var/www/html && if php -m | grep -Eq '^(pcov|xdebug)$'; then composer test:coverage; else echo 'Skipping coverage: no pcov/xdebug extension available in php1 image.'; fi" - name: Upload coverage artifact if: ${{ github.event_name == 'pull_request' }} @@ -52,6 +62,10 @@ jobs: if-no-files-found: warn retention-days: 1 + - name: Tear down php1 test stack + if: always() + run: docker compose down -v + edge-agent: name: Edge Agent (required) runs-on: [self-hosted, Linux, X64, default]