Skip the build and the test matrix on a documentation-only pull request - #3039
Merged
Conversation
A pull request that only touches .md ran the full 8 leg matrix and a Windows runner. Putting paths-ignore back on the pull_request trigger is not the fix: a workflow skipped by a path filter never reports, so "Done" would sit Pending forever and the pull request could not be merged. A job skipped by an `if:` does report, as skipped, which counts as passed. So the workflow keeps running on every pull request and the expensive jobs opt out instead. A `changes` job classifies the pull request from the compare API, about ten seconds and no checkout, and `build` and `test` sit behind it. "Done" now depends on everything and decides for itself rather than reading one result. It is never skipped, so a green "Done" is always a decision it made. It asks `code != 'false'`, not `code == 'true'`, so a failed API call, a file list truncated at the API cap, or an event the classifier does not understand all end up demanding real test results. A `changes` job that fails outright takes `build` with it and "Done" then fails, rather than waving the run through. Also adds an empty docs lane, so adding a markdown linter later is one step.
code-analysis.yml was separate only because CI ran on Azure DevOps while this one check was already on Actions, for the inline annotations on the diff. The annotations come from the SARIF upload, not from living in its own workflow, so moving it changes nothing there. As a job it needs nothing from build, so it runs in parallel with the whole matrix and adds no wall clock to a code pull request. It sits behind `changes` like the rest, so a documentation-only pull request no longer pays for a Windows runner either. "Done" now covers it too, which is the point: branch protection can name one check instead of two, and the analyzer can be renamed or replaced without touching the policy. The job keeps the name "PSScriptAnalyzer". The check context in Actions is the job name, so the context does not move while it is still named in branch protection, and this can merge without a policy change first.
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
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.
A pull request that only touches
.mdruns the full 8 leg matrix plus a Windows runner. #3037 is the example, it edits one file.Putting
paths-ignoreback on thepull_requesttrigger is not the fix, and this is the part worth knowing:if:does report, as skipped, and a skipped required check counts as passedThat is why #3017 dropped the filters, and the reasoning still holds. So the workflow keeps running on every pull request and the expensive jobs opt out instead.
Shape
changesclassifies the pull request from the compare API. About ten seconds, no checkout.buildandtestsit behind it.Done decides, and fails closed
Donedepends on everything now and is never skipped, so a greenDoneis always a decision it made rather than one it inherited from a skip.!= 'false', not== 'true'. A failed API call, a file list truncated at the 300 file cap, or an event the classifier does not understand all end up demanding real test results. The only thing that skips the matrix is a positive answer that every changed file is documentation. And achangesjob that fails outright takesbuildwith it, soDonefails rather than waving the run through.Classifier, checked against real cases
What this does not do yet
The docs lane is deliberately empty, so this change is only the plumbing. Adding a markdown linter is one step in that job.
PSScriptAnalyzerstill lives incode-analysis.ymland still runs on every pull request, so a docs-only pull request still pays for one Windows runner. Folding it in as a job here, soDonecovers it and branch protection can name one check instead of two, is the next change. Doing it separately keeps this diff to the plumbing and means the required check names do not move untilDoneis proven.Verification
I can only prove the code path here, since this pull request changes
ci.ymland therefore classifies as code, which is itself the right answer. The docs-only path needs a documentation pull request opened after this merges. The classifier logic above was run directly against those file lists.🤖