From 5ea7a636b8614d05405284fb42e9ee481898ec0b Mon Sep 17 00:00:00 2001 From: Marijn Doeve Date: Fri, 3 Jul 2026 14:28:01 +0200 Subject: [PATCH] ci: skip dev image build on tags, wait for in-progress CI runs, improve quality error output (#171) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Skip the dev image build job on tag pushes — it was wasted work since quality and tests are already skipped on tags - Remove the unnecessary `needs: build` from verify-prior-run; it ran independently of the dev image anyway - Make verify-prior-run poll (30s interval, 15 min max) so tagging immediately after a push to main waits for the CI run to finish rather than failing instantly - Replace the yes/no outcomes string in "Assert all checks passed" with per-step ::error:: annotations so GitHub highlights exactly which quality check failed --- .github/workflows/ci.yml | 58 +++++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 333d19c..05b6565 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,6 +21,7 @@ jobs: name: Build Dev Image runs-on: ubuntu-latest timeout-minutes: 15 + if: "!startsWith(github.ref, 'refs/tags/')" permissions: contents: read steps: @@ -97,8 +98,20 @@ jobs: - name: Assert all checks passed if: always() run: | - outcomes="${{ steps.twig_lint.outcome }} ${{ steps.cs.outcome }} ${{ steps.twig_cs.outcome }} ${{ steps.phpstan.outcome }} ${{ steps.rector.outcome }}" - if echo "$outcomes" | grep -q "failure"; then exit 1; fi + failed=0 + check() { + local name="$1" outcome="$2" + if [[ "$outcome" == "failure" ]]; then + echo "::error::$name failed" + failed=1 + fi + } + check "Twig Lint" "${{ steps.twig_lint.outcome }}" + check "Coding Style" "${{ steps.cs.outcome }}" + check "Twig Coding Style" "${{ steps.twig_cs.outcome }}" + check "PHPStan" "${{ steps.phpstan.outcome }}" + check "Rector" "${{ steps.rector.outcome }}" + exit $failed tests: name: Tests @@ -148,23 +161,44 @@ jobs: verify-prior-run: name: Verify Prior CI Run runs-on: ubuntu-latest - needs: build + timeout-minutes: 20 if: startsWith(github.ref, 'refs/tags/') permissions: actions: read steps: - - name: Check for successful CI run on this commit + - name: Wait for and verify successful CI run on this commit env: GH_TOKEN: ${{ github.token }} run: | - count=$(gh api \ - "repos/${{ github.repository }}/actions/workflows/ci.yml/runs?head_sha=${{ github.sha }}&status=success&per_page=5" \ - --jq "[.workflow_runs[] | select(.id != ${{ github.run_id }})] | length") - if [[ "$count" -eq 0 ]]; then - echo "::error::No prior successful CI run found for ${{ github.sha }}. Only tag commits that have passed CI on main." - exit 1 - fi - echo "Found $count prior successful CI run(s) for this commit." + max_attempts=30 + attempt=0 + while [[ $attempt -lt $max_attempts ]]; do + attempt=$((attempt + 1)) + + success_count=$(gh api \ + "repos/${{ github.repository }}/actions/workflows/ci.yml/runs?head_sha=${{ github.sha }}&status=success&per_page=5" \ + --jq "[.workflow_runs[] | select(.id != ${{ github.run_id }})] | length") + + if [[ "$success_count" -gt 0 ]]; then + echo "Found $success_count prior successful CI run(s) for ${{ github.sha }}." + exit 0 + fi + + in_progress_count=$(gh api \ + "repos/${{ github.repository }}/actions/workflows/ci.yml/runs?head_sha=${{ github.sha }}&per_page=10" \ + --jq "[.workflow_runs[] | select(.id != ${{ github.run_id }}) | select(.status == \"in_progress\" or .status == \"queued\" or .status == \"waiting\" or .status == \"requested\" or .status == \"pending\")] | length") + + if [[ "$in_progress_count" -gt 0 ]]; then + echo "CI still in progress (attempt $attempt/$max_attempts), waiting 30s..." + sleep 30 + else + echo "::error::No prior successful CI run found for ${{ github.sha }}. Only tag commits that have passed CI on main." + exit 1 + fi + done + + echo "::error::Timed out waiting for CI run to complete for ${{ github.sha }}." + exit 1 build-deploy: name: Build and Deploy