Skip to content

Commit a3304f7

Browse files
authored
ci: Add "PR checks" gate job to enable auto-merge (#2336)
1 parent bbc9a16 commit a3304f7

3 files changed

Lines changed: 42 additions & 10 deletions

File tree

.claude/references/commit-conventions.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,15 @@ merged, so the PR title becomes the commit message on `main`):
4444

4545
## Merging PRs
4646

47-
- When instructed to merge a PR, **squash merge** (`gh pr merge <number> --squash`)
48-
only after the **full test suite (150+ GHA jobs) has succeeded** (`gh pr checks`).
49-
- **Never use `gh pr merge --auto`**: this repo has no required checks, so
50-
`--auto` merges instantly instead of waiting for CI. Watch CI to completion,
51-
then merge.
47+
- When instructed to merge a PR, **squash merge with auto-merge**
48+
(`gh pr merge <number> --squash --auto`). Branch protection requires the
49+
**"PR checks"** status check — the `pr-gate` job in
50+
`.github/workflows/pytest.yaml` that fans in every PR job — so `--auto`
51+
waits for the full test suite before merging.
52+
- The gate skips on draft PRs (drafts run a reduced test matrix and cannot be
53+
merged anyway); mark the PR ready for review to trigger the full matrix.
54+
- When adding a job to `pytest.yaml`, add it to the `pr-gate` job's `needs:`
55+
list, or its failures will not block merging.
5256

5357
## Handling flaky test failures in CI
5458

.github/workflows/build-docs.yaml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ on:
2020
jobs:
2121
build-docs:
2222
runs-on: ubuntu-latest
23-
strategy:
24-
matrix:
25-
python-version: ["3.13"]
26-
fail-fast: false
23+
env:
24+
PYTHON_VERSION: "3.13"
2725

2826
steps:
2927
- uses: actions/checkout@v6
@@ -33,7 +31,7 @@ jobs:
3331
- name: Setup py-shiny
3432
uses: ./.github/py-shiny/setup
3533
with:
36-
python-version: ${{ matrix.python-version }}
34+
python-version: ${{ env.PYTHON_VERSION }}
3735

3836
# =====================================================
3937
# API docs

.github/workflows/pytest.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,3 +326,33 @@ jobs:
326326
uses: ./.github/py-shiny/narwhals-test
327327
with:
328328
shiny-dir: "."
329+
330+
# Single stable check for branch protection / auto-merge. Jobs above may be
331+
# renamed or re-matrixed freely, but every PR job MUST be listed in `needs`
332+
# below or its failure will not block merging.
333+
pr-gate:
334+
name: "PR checks"
335+
# `always()` is required: without it, an upstream failure would make this
336+
# job skip, and GitHub treats a skipped required check as satisfied.
337+
# Skipping on draft PRs is safe for the same reason in reverse: drafts
338+
# cannot be merged (or auto-merged) regardless, and skipping avoids
339+
# failure emails from the reduced draft test matrix. Marking the PR
340+
# ready for review re-triggers the workflow with the full matrix.
341+
if: always() && github.event_name == 'pull_request' && !github.event.pull_request.draft
342+
needs:
343+
- check
344+
- playwright-shiny
345+
- playwright-examples
346+
- playwright-ai
347+
- playwright-deploys-precheck
348+
- test-narwhals-integration
349+
runs-on: ubuntu-latest
350+
steps:
351+
- name: Verify that all PR jobs succeeded
352+
env:
353+
RESULTS: ${{ toJSON(needs.*.result) }}
354+
run: |
355+
echo "Job results: $RESULTS"
356+
if echo "$RESULTS" | grep -qE 'failure|cancelled|skipped'; then
357+
exit 1
358+
fi

0 commit comments

Comments
 (0)