|
| 1 | +# Skeleton of the manifest-driven integration workflow (IC-ADR-002 §5; scaffold issue #9). |
| 2 | +# |
| 3 | +# The matrix is generated from tests/integration/stacks.yml — adding a stack, configuration or |
| 4 | +# version is a manifest entry plus files, never a workflow edit. generate_matrix.py emits jobs only |
| 5 | +# for *harmonized* stacks (those with a stacks/<id>/compose.yml); stacks that are seeded in the |
| 6 | +# manifest but not yet harmonized are announced with a `::notice` in the matrix job and produce no |
| 7 | +# job here (so this workflow has zero jobs until the first stack lands). |
| 8 | +# |
| 9 | +# Triggers on any PR that touches the integration suite (so a stack PR self-tests the moment it |
| 10 | +# lands files — no workflow edit), plus manual/reusable dispatch. It is NOT yet gating: until issue |
| 11 | +# #14 wires it into ci.yml, has CI pull prebuilt images from GHCR (instead of building on the |
| 12 | +# runner), and makes it a required check, a red run here does not block merges. |
| 13 | +name: Integration tests |
| 14 | + |
| 15 | +on: |
| 16 | + workflow_dispatch: |
| 17 | + workflow_call: |
| 18 | + pull_request: |
| 19 | + paths: |
| 20 | + - "tests/integration/**" |
| 21 | + - ".github/workflows/integration.yml" |
| 22 | + - ".github/actions/pixi-setup/**" |
| 23 | + |
| 24 | +permissions: |
| 25 | + contents: read |
| 26 | + |
| 27 | +jobs: |
| 28 | + matrix: |
| 29 | + runs-on: ubuntu-latest |
| 30 | + outputs: |
| 31 | + matrix: ${{ steps.gen.outputs.matrix }} |
| 32 | + steps: |
| 33 | + - uses: actions/checkout@v6 |
| 34 | + - name: Generate {stack x config x version} matrix from stacks.yml |
| 35 | + id: gen |
| 36 | + # Same script developers run locally (without --github-output) to preview the matrix. It |
| 37 | + # also filters to harmonized stacks and prints a notice for the seeded-only ones. |
| 38 | + # PyYAML ships with the runner's system python; `pip install pyyaml` here if that changes. |
| 39 | + run: python3 tests/integration/generate_matrix.py --github-output |
| 40 | + |
| 41 | + integration: |
| 42 | + needs: matrix |
| 43 | + if: needs.matrix.outputs.matrix != '[]' |
| 44 | + runs-on: ubuntu-latest |
| 45 | + strategy: |
| 46 | + fail-fast: false |
| 47 | + matrix: |
| 48 | + include: ${{ fromJSON(needs.matrix.outputs.matrix) }} |
| 49 | + name: ${{ matrix.stack }} / ${{ matrix.config }} / ${{ matrix.version }} |
| 50 | + env: |
| 51 | + COMPOSE_FILE: tests/integration/stacks/${{ matrix.compose_stack }}/compose.yml |
| 52 | + BACKEND_VERSION: ${{ matrix.version }} |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@v6 |
| 55 | + |
| 56 | + # Every job in the matrix is a harmonized stack (the matrix job filtered out the rest), so |
| 57 | + # compose.yml is guaranteed present — no per-step "has this stack landed?" guard is needed. |
| 58 | + - name: Start the stack (healthchecks gate readiness) |
| 59 | + run: docker compose -f "$COMPOSE_FILE" up --wait |
| 60 | + |
| 61 | + - uses: ./.github/actions/pixi-setup |
| 62 | + if: matrix.exec_in_container == false |
| 63 | + with: |
| 64 | + environments: py313 |
| 65 | + |
| 66 | + - name: Run the contract suite |
| 67 | + run: | |
| 68 | + if [ "${{ matrix.exec_in_container }}" = "true" ]; then |
| 69 | + # local-* stacks: run pytest inside the batch container (IC-ADR-002 §1). The batch |
| 70 | + # scheduler typically refuses to run as root (HTCondor, Slurm), so the image must ship |
| 71 | + # an unprivileged test user and the suite + pytest must be mounted or baked in. |
| 72 | + # TODO(#13/#14): mount/install the suite and pin the exec user (compose `user:` or |
| 73 | + # `exec --user <test-user>`); see docs/dev/reference/integration-stacks.md. |
| 74 | + runner=(docker compose -f "$COMPOSE_FILE" exec -T backend pytest) |
| 75 | + else |
| 76 | + runner=(pixi run -e py313 pytest) |
| 77 | + fi |
| 78 | + set +e # keep going so exit 5 (no tests selected) can be handled below |
| 79 | + "${runner[@]}" tests/integration -m "${{ matrix.markers }}" \ |
| 80 | + --stack="${{ matrix.stack }}" --config="${{ matrix.config }}" |
| 81 | + rc=$? |
| 82 | + # pytest exits 5 when the stack's markers select no tests. Phase 0 ships only the |
| 83 | + # manifest tests, so the first harmonized stack would otherwise go red for "no tests |
| 84 | + # ran"; tolerate exit 5 with a notice until the Phase-2 contract suite lands. |
| 85 | + if [ "$rc" -eq 5 ]; then |
| 86 | + echo "::notice::stack '${{ matrix.stack }}': no tests matched markers '${{ matrix.markers }}' (pytest exit 5) - passing until the contract suite lands" |
| 87 | + rc=0 |
| 88 | + fi |
| 89 | + exit "$rc" |
| 90 | +
|
| 91 | + - name: Collect daemon logs |
| 92 | + if: failure() |
| 93 | + # Daemons run in the foreground and log to stdout/stderr (IC-ADR-002 §3), so compose logs |
| 94 | + # are the whole failure story — a file-logging daemon redirects its log to /dev/stdout. |
| 95 | + run: docker compose -f "$COMPOSE_FILE" logs --no-color > compose-logs.txt || true |
| 96 | + |
| 97 | + - name: Upload logs as artifacts |
| 98 | + if: failure() |
| 99 | + uses: actions/upload-artifact@v4 |
| 100 | + with: |
| 101 | + name: logs-${{ matrix.stack }}-${{ matrix.config }}-${{ matrix.version }} |
| 102 | + path: compose-logs.txt |
0 commit comments