ci: skip unnecessary jobs based on change detection#892
Merged
Conversation
rekmarks
reviewed
Mar 23, 2026
sirtimid
enabled auto-merge
March 23, 2026 22:20
sirtimid
force-pushed
the
sirtimid/ci-skip-unnecessary-jobs
branch
from
March 24, 2026 16:59
1eea7ec to
ee5166b
Compare
rekmarks
requested changes
Mar 25, 2026
Add a `detect-changes` job that classifies files into categories and conditionally skips expensive CI jobs: - docs-only (.md, .txt, docs/, .claude/, LICENSE): skip all jobs - config/tooling-only (.eslintrc, .prettierrc, etc.): run lint only - CI-only (.github/): run actionlint only - code changes: run everything as before The `all-jobs-complete` gate is updated to verify the right jobs succeeded based on what actually changed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove redundant AGENTS.md pattern (already matched by *.md) - Group redirects to $GITHUB_OUTPUT and $GITHUB_STEP_SUMMARY Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Address two gaps in the all-jobs-complete gate: - Fail if detect-changes itself fails (prevents empty outputs from letting the gate pass with zero validation) - Verify check-workflows succeeded for CI-only PRs (has-ci=true) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Docs files (.md, .txt, etc.) now set HAS_LINT_TARGETS=true since prettier runs on them via lint:misc (rekmarks review) - analyse-code and lint-build-test handle skipped check-workflows via explicit result guard to prevent cascade-skip issues - Gate now requires check-workflows for code changes too (not just CI) - Dead else branch now fails explicitly instead of using github.event.before Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The implicit success() in GitHub Actions if: conditions short-circuits when an upstream job is skipped, making the '== skipped' check dead code. Use always() with '!= failure' instead so analyse-code and lint-build-test can run when check-workflows is legitimately skipped. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
CI workflow files (.yml) go through prettier via lint:misc, so they need HAS_LINT_TARGETS=true to trigger the lint-only job. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The always() pattern on analyse-code and lint-build-test bypassed the merge queue skip optimization. Add check-skip-merge-queue to their needs and condition so they don't run when the merge queue determines the PR is already up-to-date. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
sirtimid
force-pushed
the
sirtimid/ci-skip-unnecessary-jobs
branch
from
March 26, 2026 08:28
ee5166b to
c9901ec
Compare
Changes to .github/actions/* (e.g. playwright-install) were classified as CI-only, skipping build/test validation. Split into its own case that also sets HAS_CODE=true so the lint-build-test pipeline runs. Also removes .claude/* from the doc-only pattern so it falls through to the code catch-all, future-proofing for executable skills/plugins. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
LICENSE only matched a bare LICENSE file, but the repo uses LICENSE.APACHE2 and LICENSE.MIT. Change to LICENSE* so license-only changes are correctly classified as documentation, not code. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Adds a
detect-changesjob to the main CI workflow that classifies changed files and conditionally skips expensive jobs when they aren't needed. This reduces CI time and resource usage for documentation, config, and CI-only PRs.Changes
detect-changesjob that categorizes files into: docs, config/tooling, CI, and code.md,.txt,docs/,.claude/,LICENSE): run lint only, skip build, test, integration, e2e, and security scan.eslintrc,.prettierrc,.editorconfig, etc.): run lint only, skip build/test/e2e.github/workflows/,.github/actions/): run actionlint only, skip everything elselint-onlyjob for config-only changes that don't need the full build/test pipelineall-jobs-completegate to dynamically verify success based on what was expected to runmainalways run the full pipeline regardless of file typesTesting
This is a CI workflow change. It can be validated by observing the GitHub Actions run on this PR itself — since the only changed file is
.github/workflows/main.yml, thedetect-changesjob should classify it as CI-only and skip lint/build/test jobs. The workflow is also self-testing through its own merge queue integration.Note
Medium Risk
Medium risk because it changes CI gating logic and could unintentionally skip required checks or misclassify changes, affecting merge protection and security scanning coverage.
Overview
Adds a new
detect-changesjob that diffs against the PR/merge-queue base SHA and classifies changes intohas-code,has-ci, andhas-lint-targets, publishing a step summary for debugging.Updates the main workflow to conditionally run
check-workflows,analyse-code, andlint-build-testonly when relevant (while always running the full pipeline on pushes tomain), and introduces alint-onlyjob for non-code changes.Refactors
all-jobs-completeto dynamically enforce success based on the detected change category (including requiringdetect-changesto succeed) so the final gate accurately reflects what was expected to run.Written by Cursor Bugbot for commit 6ac945e. This will update automatically on new commits. Configure here.