Skip to content

ci: short-circuit heavy jobs for docs-only PRs (no branch-protection deadlock)#287

Merged
coseto6125 merged 2 commits into
mainfrom
ci/skip-heavy-on-docs
May 21, 2026
Merged

ci: short-circuit heavy jobs for docs-only PRs (no branch-protection deadlock)#287
coseto6125 merged 2 commits into
mainfrom
ci/skip-heavy-on-docs

Conversation

@coseto6125
Copy link
Copy Markdown
Owner

Summary

Docs-only PRs (e.g. #286 roadmap refresh) currently burn ~10 min × 3 OS on `cargo nextest` + ~2 min on audit/deny even though no code changed. This PR fixes that without re-introducing the `paths-ignore` deadlock that left docs-only PRs `BLOCKED` forever (#236 / #278).

Design: step-level `if:` short-circuit instead of job-level `if: false`.

  • New `detect-changes` job classifies the PR via shell git diff against base ref → outputs `code: true|false`
  • `code-quality`, `test` (3 OS), `audit` jobs gate every heavy step on `needs.detect-changes.outputs.code == 'true'`
  • Jobs still RUN unconditionally → required-check list sees SUCCESS on docs-only
  • `actionlint` unconditional (fast, idempotent, lints YAML that always exists)
  • Push to `main` always defaults to `code=true` (merge commits must validate)

Code-relevant path list (positive — anything outside is docs/license/config-only):
```
crates/ Cargo.toml Cargo.lock .github/ scripts/ rust-toolchain*
deny.toml clippy.toml rustfmt.toml
```

No third-party action — shell regex is transparent + auditable.

Test plan

  • This PR itself touches `.github/` → `detect-changes` should output `code=true` → all heavy jobs run normally
  • Visible `Detect code changes` job in the CI summary
  • After merge: next docs-only PR (e.g. follow-up roadmap update) should show "✓ Docs-only PR — skipping ..." in each heavy job and complete in ~1 min total instead of ~12 min

…k semantics)

Adds a `detect-changes` job that classifies PR changes via shell-based
git diff against `github.base_ref`. Downstream code-quality / test / audit
jobs gate every heavy step on `needs.detect-changes.outputs.code == 'true'`
but still RUN as jobs — so branch protection's required-check list keeps
seeing SUCCESS on docs-only PRs (e.g. #286 roadmap refresh) instead of
burning ~10 min × 3 OS on cargo nextest + ~2 min on audit/deny.

Why not paths-ignore?
  paths-ignore skips the whole workflow → required checks never report →
  docs-only PRs stuck `BLOCKED` (the #236 / #278 deadlock).

Why not job-level `if: false` for docs?
  Same problem: SKIPPED ≠ SUCCESS for branch protection's required list.

Why this design (step-level `if:`)?
  Job-level execution stays unconditional (SUCCESS reports), but the heavy
  steps short-circuit when `code != true`. Each job's first step prints a
  visible "✓ Docs-only PR — skipping ..." log line so it's obvious in the
  Actions UI what happened.

Code-relevant path classification (positive list — anything else is treated
as docs/config/license-only):
  crates/  Cargo.toml  Cargo.lock  .github/  scripts/  rust-toolchain*
  deny.toml  clippy.toml  rustfmt.toml

`actionlint` keeps running unconditionally — it lints the workflow YAML
itself (always present), and the ~30s cost is negligible.

Push-to-main events always default to `code=true` regardless of detected
paths (merge commits must get full validation).
@coseto6125 coseto6125 enabled auto-merge (squash) May 21, 2026 16:20
@coseto6125 coseto6125 added ci CI and workflow changes enhancement New feature or request labels May 21, 2026
@coseto6125 coseto6125 merged commit 8d9d928 into main May 21, 2026
13 checks passed
@coseto6125 coseto6125 deleted the ci/skip-heavy-on-docs branch May 21, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI and workflow changes enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant