Skip to content

test(ci): skip the smoke matrix when no script can be affected (tier 1) #219

Closed

Description

@Jammy2211

Overview

PyAutoHeart/.github/workflows/smoke-tests.yml — the reusable workflow every workspace's smoke_tests.yml is a thin caller of — has exactly one skip condition: a docs-only gate that skips the matrix when every changed file matches *.md, docs/, LICENSE or runtime.txt. Anything else runs the full curated smoke list, whatever it touched. A one-character change to any non-markdown file costs the full run: ~11m20s in autolens_workspace_test (≈17 runs/week), ~8m40s in autolens_workspace (5.8 runs/day). The two extremes already in the record are 80x apart — a docs-only PR finishes in 8 seconds.

The failure mode is written into the repo already. smoke_tests.txt, on the 2026-08-22 disable of multi_dataset/jax_likelihood/mge.py: "Hit 4/4 jobs (3.12 and 3.13, twice each) on autolens_workspace_test#261, whose diff touches no script this gate runs."

Scope for this task is tier 1 only — skip when no script can be affected. Tier 2 (narrowing the entry list to the packages the diff touches) needs the selected set passed down to run_smoke.py and therefore edits each workspace's vendored runner; it is deliberately deferred and is not part of this issue. The prompt says tier 1 alone is most of the win.

Plan

  • Extend the existing changes job's classification with one more reason to skip: if the diff touches nothing under scripts/, config/, smoke_tests.txt, smoke_notebooks.txt or .github/, skip the matrix the same way the docs-only path does.
  • Emit it as a second docs_only-shaped output on the same job, so the smoke job's if: grows one clause and nothing else about the workflow's shape changes.
  • Fail closed, matching the docs-only gate exactly — no base SHA, unfetchable base, empty diff, or a single unclassifiable path runs everything. Only an explicit every-file-matches verdict may skip.
  • Gate the new skip to pull_request events, so a push to main always runs the full matrix and Heart's ci_status keeps reading a real conclusion.
  • Keep the skip inside the workflow. Do not implement it with on.pull_request.paths.
  • Verify against at least one caller of each shape (_workspace and _workspace_test) before shipping, since the change lands once for every caller.
Detailed implementation plan

Affected Repositories

  • PyAutoHeart (primary — and the only repo this tier touches)

Callers read for verification, not edited: autolens_workspace, autolens_workspace_test, autogalaxy_workspace_test.

Work Classification

Library (Heart-owned CI). No workspace leg in tier 1.

Branch Survey

Repository Current Branch Dirty?
./PyAutoHeart main clean

Suggested branch: feature/smoke-relevance-gate

Worktree root: ~/Code/PyAutoLabs-wt/smoke-relevance-gate/

Implementation Steps

  1. Extend the changes job (.github/workflows/smoke-tests.yml, currently ~lines 115–158). It already computes docs_only from a two-dot git diff --name-only "$BASE" HEAD against the base tip, inside a guard that requires a non-null, non-zero $BASE that git fetch --depth=1 can reach. Reuse that same $files list — do not re-derive the diff, and do not switch to a merge-base diff: the two-dot form against the tip is deliberate so upstream drift shows up as extra files and conservatively runs the matrix.
  2. Add a second classification pass over $files producing no_smoke_relevant_changes (name it to read as a reason, matching docs_only). A path is smoke-relevant if it matches scripts/*, config/*, smoke_tests.txt, smoke_notebooks.txt or .github/*; if no changed path matches any of those, the new output is true. Follow the existing while IFS= read -r f; do case "$f" in … esac; done <<< "$files" shape and its break-on-first-mismatch structure, inverted appropriately.
  3. Fail closed. Initialise the new flag false before the guard, exactly as docs_only is, so every early-exit path (no $BASE, the all-zero SHA, a failed fetch, an empty $files) leaves it false and the matrix runs. The two flags are independent — a docs-only diff satisfies both, which is fine; they are ORed.
  4. Gate to pull_request. The new skip must not apply to a push to main. Either set it false unless github.event_name == 'pull_request', or add the event test to the smoke job's if:. Whichever is chosen, state it in a comment: config/repos.yaml lists workspaces_test: ["Smoke Tests"] and workspaces: ["Smoke Tests", "Navigator Check"] under required_workflows; ci_status reads their conclusion on the main HEAD commit and readiness gates RED on failure, and cancelled is in Heart's FAILURE_CONCLUSIONS. Narrowing PR-side runs is free — Heart never reads them — but a skipped or cancelled main run breaks the readiness gate.
  5. Wire the outputs. Add the new output to the changes job's outputs: block and extend smoke's if: needs.changes.outputs.docs_only != 'true' to also require the new flag != 'true'. A job skipped this way still reports skipped, which satisfies required-check semantics — that is the whole reason the gate lives inside the workflow.
  6. Write the step summary for the new path the way the docs-only path does, so a reader of a skipped run can see which files were classified and why.
  7. Test. Add coverage to PyAutoHeart's own suite for the classification predicate if the repo has a place for it; whatever the repo's existing convention is for testing this workflow, follow it rather than inventing one. Run the full suite.
  8. Verify against callers. Read autolens_workspace/.github/workflows/smoke_tests.yml (a _workspace-shape caller) and autolens_workspace_test/.github/workflows/smoke_tests.yml (a _workspace_test-shape caller) and confirm neither passes an input this change invalidates and neither relies on the matrix always running. Report what each declares.

Key Files

  • .github/workflows/smoke-tests.yml — the changes job and the smoke job's if:; this is the whole diff
  • config/repos.yaml — read only, required_workflows, for the main-push constraint
  • PyAutoHeart's test suite — wherever workflow-shape assertions already live

Acceptance

  • A PR touching only README.md plus a config sidecar still skips (the existing docs-only path is unaffected).
  • A PR touching nothing under scripts/, config/, smoke_tests.txt, smoke_notebooks.txt or .github/ now skips.
  • A PR with an unresolvable base still runs the full matrix.
  • The Smoke Tests check reports skipped, not pending, on every skip path.
  • main-push runs are unchanged and Heart's ci_status still reads a real conclusion.

Out of scope

Tier 2 (package-level narrowing of the entry list). It needs the selected set passed to run_smoke.py as an input and therefore touches each workspace's vendored runner — a separate change in separate repos, to be filed on its own. Also out of scope: making the slow entries cheaper, which is the sibling prompt draft/test/workspaces/slowest_smoke_gate_scripts.md.

Original Prompt

Click to expand starting prompt

Relevance-gate the reusable smoke workflow so a PR only runs what its diff can affect

Type: test
Target: PyAutoHeart
Repos:

  • PyAutoHeart
  • autolens_workspace_test
  • autogalaxy_workspace_test
  • autolens_workspace
    Themes:
  • ci-smoke
    Difficulty: medium
    Autonomy: safe
    Priority: normal
    Status: formalised
    Consequence: judge
    Review-minutes: 20
    Unattended: ready

PyAutoHeart/.github/workflows/smoke-tests.yml — the reusable workflow every
workspace's smoke_tests.yml is a thin caller of — has exactly one skip
condition: a docs-only gate that skips the matrix when every changed file
matches *.md, docs/, LICENSE or runtime.txt. Anything else runs the
full curated smoke list, whatever it touched.

This prompt cuts how often the gate runs. Making the slow entries cheaper is
the sibling prompt draft/test/workspaces/slowest_smoke_gate_scripts.md; they
compound but are separate changes in separate repos.

Why

  • autolens_workspace_test smoke costs ~11m20s and fires on every PR event
    plus every push to main. Run numbers put it at roughly 17 runs/week
    (#555 on 2026-07-28 → #616 on 2026-08-22; approximate, since superseded PR
    runs are cancelled).
  • autolens_workspace costs ~8m40s over 37 entries, 5.8 runs/day in the week
    to 2026-08-23.
  • The failure mode is already recorded in the repo. smoke_tests.txt, on the
    2026-08-22 disable of multi_dataset/jax_likelihood/mge.py: "Hit 4/4 jobs
    (3.12 and 3.13, twice each) on autolens_workspace_test#261, whose diff
    touches no script this gate runs."
  • The two extremes already exist and are 80x apart: a docs-only PR finishes in
    8 seconds (autolens_workspace_test run #605, autogalaxy_workspace #545);
    a one-character change to any non-markdown file costs the full run.

Task

Two tiers, shippable independently. Tier 1 alone is most of the win.

  1. Skip when no script can be affected. Extend the existing changes job's
    classification: if the diff touches nothing under scripts/, config/,
    smoke_tests.txt, smoke_notebooks.txt or .github/, skip the matrix the
    same way the docs-only path does. Same fail-closed shape, same
    docs_only-style output, one more reason to skip.

  2. Narrow the entry list to the packages the diff touches, plus a fixed
    core.
    The smoke entries cluster cleanly by top-level package, so a
    directory-level mapping is enough — no dependency analysis needed:

    package autolens_ws_test autogalaxy_ws_test autolens_workspace
    imaging/ 232.8s (42%) 175.8s (32%) 63.6s (18%)
    multi_dataset/ — 177.1s (32%) 13.5s (4%)
    misc/ 154.6s (28%) 37.6s (7%) —
    interferometer/ 92.1s (17%) 150.6s (27%) 54.6s (16%)
    point_source/ 47.7s (9%) — 15.7s (4%)
    multi_galaxy/ 25.8s (5%) 11.8s (2%) 166.4s (47%)
    group/ — — 22.9s (7%)
    guides/ — — 14.3s (4%)
    cluster/ — 4.2s (1%) —

    A PR touching only scripts/misc/ would run 155s instead of 553s; one
    touching only multi_galaxy/ in _test would run 26s. Tier 2 needs the
    selected set passed down to run_smoke.py as an input, so it also touches
    each workspace's vendored runner — scope it deliberately or defer it.

autogalaxy_workspace_test is the same size and has no other lever

Measured after this prompt was first filed (run 32533004337, 2026-08-21, py3.12,
557.1s across 37 entries — within 4s of autolens_workspace_test's 553.0s,
and again reconciling exactly to the step wall-clock).

Unlike its autolens sibling it has no hot spot at all: slowest entry 40.0s,
median 13.5s, and the top three are only 21% of the run. There is nothing to
speed up, so the sibling prompt does not apply and this gate is the only
lever for that repo.

What it does have is a combinatorial matrix: 25 of its 37 entries are
{imaging, interferometer, multi_dataset}/jax_{likelihood,grad}/{lp, mge, mge_group, rectangular, rectangular_mge, delaunay, delaunay_mge}, i.e. the
same handful of meshes crossed with three dataset types. Tier 2's
package-level narrowing maps onto that cleanly. A representative-subset
policy for the PR gate (full cross-product weekly) is worth considering
alongside it, but is a separate decision and belongs to that repo, not here.

Checked and NOT a factor: its six jax_grad/ entries were the obvious
suspect, since Heart budgets that class at 1800s for running at full
resolution. Measured they are 86.4s total (15.5%), 10.8–21.8s each. The
expensive jax_grad scripts are the autolens ones, and those are not in any
smoke list.

Hard constraints

  • Do not implement this with on.pull_request.paths. A job skipped by a
    path filter never reports a conclusion, so a required status check sits
    pending forever and blocks the merge. The in-workflow changes job emits a
    real skipped, which satisfies required-check semantics — the workflow's own
    comment already says so. Keep the skip inside the workflow.
  • Fail closed, matching the docs-only gate exactly: no base SHA, unfetchable
    base, empty diff, or a single unclassifiable path ⇒ run everything. Only an
    explicit every-file-matches verdict may skip. Keep the two-dot diff against
    the base tip so upstream drift shows up as extra files.
  • Do not touch the push-to-main run. PyAutoHeart/config/repos.yaml lists
    workspaces_test: ["Smoke Tests"] and workspaces: ["Smoke Tests", "Navigator Check"] under required_workflows; ci_status reads their
    conclusion on the main HEAD commit and readiness gates RED on failure.
    cancelled is in Heart's FAILURE_CONCLUSIONS, which is why the callers'
    concurrency block only cancels non-main refs. Narrowing PR-side runs is
    free — Heart never reads them — but a skipped or cancelled main run breaks
    the readiness gate. If tier 1 would skip on a main push, gate it to
    pull_request events only.
  • The change is Heart-owned and lands once for every caller (both _workspace
    and _workspace_test families, plus the HowTo repos). Verify against at
    least one caller of each shape before merging.

Acceptance

  • A PR touching only scripts/misc/ in autolens_workspace_test runs
    materially less than the full 553s (tier 2), or a PR touching only
    README.md + a config sidecar still skips (tier 1).
  • A PR with an unresolvable base still runs the full matrix.
  • The Smoke Tests check reports skipped, not pending, on every skip path.
  • main-push runs are unchanged and Heart's ci_status still reads a real
    conclusion.

Activity

  1. Jammy2211 commented on Sep 9, 2026

    @Jammy2211
    ContributorAuthor

    Shipped

    PR: #220 — merged to main as 1593a765. Tier 1 only, as scoped.

    smoke-tests.yml's changes job now publishes a second reason to skip, no_smoke_relevant_changes: a diff touching none of scripts/, config/, smoke_tests.txt, smoke_notebooks.txt or .github/ cannot change what any smoke script does, so the matrix skips the way the docs-only path does. Both flags are classified from the same $files list — git diff --name-only still appears exactly once, so the two verdicts cannot disagree about what changed, and a test pins that.

    The pull_request gate turned out to be load-bearing for a narrower reason than the prompt gave, worth recording: skipped is not in Heart's FAILURE_CONCLUSIONS, so a skipped run on main would not RED. But ci_status.rollup returns green only on an explicit success on HEAD — its own docstring says "otherwise ... an unknown, never a green" — so a skipped main run would leave readiness permanently unable to reach GREEN. cancelled is the one that REDs outright. The gate lives inside the classify step rather than on the smoke job's if:, so the published output means "a skip is warranted" instead of being true-but-inapplicable on a push. Push-to-main behaviour is byte-for-byte unchanged, and the docs-only gate was deliberately not narrowed to pull_request alongside it.

    Fail-closed was executed, not reasoned about: the step's real run: body was run with only git stubbed, and both flags come back false with an empty step summary for an empty $BASE, the all-zero SHA, a failing git fetch, and an empty diff — plus a single relevant path in an otherwise irrelevant diff, tested at every insertion position since the loop breaks on first match. The two-dot diff against the base tip is preserved; merge-base appears nowhere.

    Not implemented with on.pull_request.paths — the job header comment now says why.

    Tests: 965 passed, 0 failed, 0 skipped, run independently by the implementing agent and by the architect session. 11 new test functions / 25 node ids in tests/test_smoke_tests_wiring.py that execute the predicate under bash -e against a synthetic diff rather than pattern-matching the YAML, following the repo's existing subprocess.run(["bash", …]) convention; the docs-only assertion in tests/test_workflow_wiring.py generalised to both gates.

    Callers verified, one of each shape. autolens_workspace and autolens_workspace_test ship byte-identical smoke_tests.yml (same blob 65789266), declaring only chain: and secrets: inherit. Neither passes an input this change invalidates, neither reads any output of the reusable workflow, and neither runs a job downstream of the matrix — so a skipped matrix has no dependant.

    Tier 2 remains open and unstarted: narrowing the entry list to the packages the diff touches needs the selected set passed down to each workspace's vendored run_smoke.py, so it is a multi-repo change and belongs to its own prompt. The sibling prompt draft/test/workspaces/slowest_smoke_gate_scripts.md (making the slow entries cheaper) is unaffected by this and still stands.

    Shipped as member 3 of the ci-smoke bundle.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions