|
| 1 | +name: CI |
| 2 | + |
| 3 | +# Orchestrator workflow. Runs ``detect-changes`` once, then conditionally |
| 4 | +# calls the sub-workflows that a PR can actually affect. A final |
| 5 | +# ``all-checks-pass`` gate job aggregates results so branch protection only |
| 6 | +# needs to require a single check. |
| 7 | +# |
| 8 | +# Sub-workflows are triggered via ``workflow_call`` and keep their own job |
| 9 | +# definitions, matrices, and concurrency settings. They no longer have |
| 10 | +# ``push:`` / ``pull_request:`` triggers of their own — everything flows |
| 11 | +# through this file. |
| 12 | + |
| 13 | +on: |
| 14 | + pull_request: |
| 15 | + branches: [main] |
| 16 | + push: |
| 17 | + branches: [main] |
| 18 | + |
| 19 | +permissions: |
| 20 | + contents: read |
| 21 | + pull-requests: write # needed by lint (PR comment) + supply-chain (PR comment) |
| 22 | + actions: read # needed by osv-scanner (SARIF upload) |
| 23 | + security-events: write # needed by osv-scanner (SARIF upload) |
| 24 | + |
| 25 | +concurrency: |
| 26 | + group: ci-${{ github.ref }} |
| 27 | + cancel-in-progress: ${{ github.event_name == 'pull_request' }} |
| 28 | + |
| 29 | +jobs: |
| 30 | + # ───────────────────────────────────────────────────────────────────── |
| 31 | + # detect: run the classifier once. Every downstream job reads its outputs |
| 32 | + # to decide whether to run. On push/dispatch the classifier fails open |
| 33 | + # (all lanes true) so post-merge validation is never weakened. |
| 34 | + # ───────────────────────────────────────────────────────────────────── |
| 35 | + detect: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + outputs: |
| 38 | + python: ${{ steps.classify.outputs.python }} |
| 39 | + frontend: ${{ steps.classify.outputs.frontend }} |
| 40 | + site: ${{ steps.classify.outputs.site }} |
| 41 | + scan: ${{ steps.classify.outputs.scan }} |
| 42 | + deps: ${{ steps.classify.outputs.deps }} |
| 43 | + docker_meta: ${{ steps.classify.outputs.docker_meta }} |
| 44 | + mcp_catalog: ${{ steps.classify.outputs.mcp_catalog }} |
| 45 | + event_name: ${{ github.event_name }} |
| 46 | + steps: |
| 47 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 48 | + - name: Detect affected areas |
| 49 | + id: classify |
| 50 | + uses: ./.github/actions/detect-changes |
| 51 | + |
| 52 | + # ───────────────────────────────────────────────────────────────────── |
| 53 | + # Lane-gated sub-workflows. Each runs in parallel after detect finishes. |
| 54 | + # Skipped workflows (if condition is false) don't spin up runners. |
| 55 | + # ───────────────────────────────────────────────────────────────────── |
| 56 | + tests: |
| 57 | + needs: detect |
| 58 | + if: needs.detect.outputs.python == 'true' |
| 59 | + uses: ./.github/workflows/tests.yml |
| 60 | + |
| 61 | + lint: |
| 62 | + needs: detect |
| 63 | + if: needs.detect.outputs.python == 'true' |
| 64 | + uses: ./.github/workflows/lint.yml |
| 65 | + with: |
| 66 | + event_name: ${{ needs.detect.outputs.event_name }} |
| 67 | + |
| 68 | + typecheck: |
| 69 | + needs: detect |
| 70 | + if: needs.detect.outputs.frontend == 'true' |
| 71 | + uses: ./.github/workflows/typecheck.yml |
| 72 | + |
| 73 | + docs-site: |
| 74 | + needs: detect |
| 75 | + if: needs.detect.outputs.site == 'true' |
| 76 | + uses: ./.github/workflows/docs-site-checks.yml |
| 77 | + |
| 78 | + history-check: |
| 79 | + needs: detect |
| 80 | + if: needs.detect.outputs.event_name == 'pull_request' |
| 81 | + uses: ./.github/workflows/history-check.yml |
| 82 | + |
| 83 | + contributor-check: |
| 84 | + needs: detect |
| 85 | + if: needs.detect.outputs.python == 'true' |
| 86 | + uses: ./.github/workflows/contributor-check.yml |
| 87 | + |
| 88 | + uv-lockfile: |
| 89 | + needs: detect |
| 90 | + uses: ./.github/workflows/uv-lockfile-check.yml |
| 91 | + |
| 92 | + docker-lint: |
| 93 | + needs: detect |
| 94 | + if: needs.detect.outputs.docker_meta == 'true' |
| 95 | + uses: ./.github/workflows/docker-lint.yml |
| 96 | + |
| 97 | + supply-chain: |
| 98 | + needs: detect |
| 99 | + if: needs.detect.outputs.event_name == 'pull_request' && (needs.detect.outputs.scan == 'true' || needs.detect.outputs.deps == 'true' || needs.detect.outputs.mcp_catalog == 'true') |
| 100 | + uses: ./.github/workflows/supply-chain-audit.yml |
| 101 | + with: |
| 102 | + event_name: ${{ needs.detect.outputs.event_name }} |
| 103 | + scan: ${{ needs.detect.outputs.scan == 'true' }} |
| 104 | + deps: ${{ needs.detect.outputs.deps == 'true' }} |
| 105 | + mcp_catalog: ${{ needs.detect.outputs.mcp_catalog == 'true' }} |
| 106 | + |
| 107 | + osv-scanner: |
| 108 | + needs: detect |
| 109 | + uses: ./.github/workflows/osv-scanner.yml |
| 110 | + |
| 111 | + # ───────────────────────────────────────────────────────────────────── |
| 112 | + # Gate: runs after everything. ``if: always()`` ensures it reports a |
| 113 | + # status even when some deps were skipped. Only actual ``failure`` |
| 114 | + # results cause it to fail; ``skipped`` is treated as success. |
| 115 | + # |
| 116 | + # Branch protection should require ONLY this check. |
| 117 | + # ───────────────────────────────────────────────────────────────────── |
| 118 | + all-checks-pass: |
| 119 | + name: All required checks pass |
| 120 | + needs: |
| 121 | + - tests |
| 122 | + - lint |
| 123 | + - typecheck |
| 124 | + - docs-site |
| 125 | + - history-check |
| 126 | + - contributor-check |
| 127 | + - uv-lockfile |
| 128 | + - docker-lint |
| 129 | + - supply-chain |
| 130 | + - osv-scanner |
| 131 | + if: always() |
| 132 | + runs-on: ubuntu-latest |
| 133 | + steps: |
| 134 | + - name: Evaluate job results |
| 135 | + env: |
| 136 | + RESULTS: ${{ toJSON(needs.*.result) }} |
| 137 | + run: | |
| 138 | + echo "$RESULTS" | python3 -c " |
| 139 | + import json, sys |
| 140 | + results = json.load(sys.stdin) |
| 141 | + failed = [r for r in results if r == 'failure'] |
| 142 | + if failed: |
| 143 | + print(f'::error::{len(failed)} job(s) failed') |
| 144 | + sys.exit(1) |
| 145 | + print('All checks passed (or were skipped)') |
| 146 | + " |
0 commit comments