From d0c547350d601ca2345a0e8e93cf7e14ae389803 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 30 Jul 2026 15:30:04 +0100 Subject: [PATCH] feat: docs-only changes skip the reusable smoke matrix (fail-closed gate) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every workspace smoke caller is on: [push, pull_request] with no path filter, so a README one-liner ran 2 Python versions x a 5-library chain, twice (PyAutoHeart#126). A 'changes' gate job in the reusable workflow classifies the diff (base = pull_request.base.sha || event.before, shallow fetch, two-dot diff): the matrix is skipped ONLY when every changed file matches the tiny allowlist (*.md, docs/, LICENSE, runtime.txt) — no base, unfetchable base, empty diff, or any other file runs it (dotfiles and sidecars count as code). Skips list the files in the step summary; a skipped matrix satisfies required-check semantics. Wiring test pins needs+if fail-closed shape. Co-Authored-By: Claude Fable 5 --- .github/workflows/smoke-tests.yml | 46 +++++++++++++++++++++++++++++++ tests/test_workflow_wiring.py | 11 ++++++++ 2 files changed, 57 insertions(+) diff --git a/.github/workflows/smoke-tests.yml b/.github/workflows/smoke-tests.yml index 3f39dcec..ad0acc41 100644 --- a/.github/workflows/smoke-tests.yml +++ b/.github/workflows/smoke-tests.yml @@ -39,7 +39,53 @@ on: default: "C03S98FEDK2" jobs: + # Docs-only gate: skip the matrix when the diff touches nothing but prose. + # FAIL CLOSED — any doubt (no base sha, unfetchable base, empty diff, a + # single non-allowlisted file) runs the matrix; only an explicit + # every-file-matches verdict skips. The allowlist is deliberately tiny: + # dotfiles and path-keyed sidecars count as code. The two-dot diff against + # the base TIP (not the merge-base) means upstream drift on the base branch + # shows up as extra files and conservatively runs the matrix. A skipped + # matrix job reports "skipped", which satisfies required-check semantics. + changes: + runs-on: ubuntu-latest + outputs: + docs_only: ${{ steps.diff.outputs.docs_only }} + steps: + - name: Checkout workspace (shallow) + uses: actions/checkout@v4 + - name: Classify the diff + id: diff + env: + BASE: ${{ github.event.pull_request.base.sha || github.event.before }} + run: | + docs_only=false + files="" + if [ -n "$BASE" ] \ + && [ "$BASE" != "0000000000000000000000000000000000000000" ] \ + && git fetch --quiet --depth=1 origin "$BASE" 2>/dev/null; then + files="$(git diff --name-only "$BASE" HEAD 2>/dev/null || true)" + if [ -n "$files" ]; then + docs_only=true + while IFS= read -r f; do + case "$f" in + *.md|docs/*|LICENSE|runtime.txt) ;; + *) docs_only=false; break ;; + esac + done <<< "$files" + fi + fi + echo "docs_only=$docs_only" >> "$GITHUB_OUTPUT" + if [ "$docs_only" = true ]; then + { + echo "### Smoke matrix skipped — docs/metadata-only change" + printf -- '- `%s`\n' $files + } >> "$GITHUB_STEP_SUMMARY" + fi + smoke: + needs: changes + if: needs.changes.outputs.docs_only != 'true' runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/tests/test_workflow_wiring.py b/tests/test_workflow_wiring.py index b826be26..180ec672 100644 --- a/tests/test_workflow_wiring.py +++ b/tests/test_workflow_wiring.py @@ -60,3 +60,14 @@ def test_test_run_reads_an_existing_entry_workflow(): assert (WORKFLOWS / VALIDATION_WORKFLOW).is_file() # ...and specifically the smoke channel, never the body or release entry. assert VALIDATION_WORKFLOW == "workspace-smoke.yml" + + +def test_smoke_reusable_docs_only_gate_is_wired_fail_closed(): + """The docs-only gate must stay fail-closed: the matrix job runs unless + the changes job explicitly said docs_only == 'true' (PyAutoHeart#126).""" + data = _load("smoke-tests.yml") + jobs = data["jobs"] + assert "changes" in jobs + smoke = jobs["smoke"] + assert smoke["needs"] == "changes" + assert smoke["if"] == "needs.changes.outputs.docs_only != 'true'"