Repository navigation
ci: end a scheduled run when master has not moved since the last run - #50
Merged
Merged
Conversation
Reviewer's GuideConfigurationAdd a scheduled-run history check and use its result to skip the CI jobs when the branch has not moved, while allowing other events and failed checks to proceed.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
|
🏷️ Auto-labeling complete! Applied labels: Labels help us categorize and prioritize PRs. You can manually add or remove labels as needed. |
There was a problem hiding this comment.
Hey - I've found 5 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path=".github/workflows/ci.yml" line_range="76" />
<code_context>
pre-check:
name: Pre-checks
+ needs: changed
+ if: needs.changed.outputs.run == 'true'
runs-on: ubuntu-latest
steps:
</code_context>
<issue_to_address>
**Required checks pass without tests**
When the `changed` job fails or times out before publishing `run`, `needs.changed.outputs.run` is empty, so `pre-check` and its dependent jobs skip, and `all-checks` skips instead of reporting the failure; the required check appears successful without running the suite.
Make the final check fail when `changed` fails or omits `run`, rather than treating the empty output as a skip.
Also at `.github/workflows/ci.yml:56-58`, `.github/workflows/ci.yml:523`.
</issue_to_address>
### Comment 2
<location path=".github/workflows/ci.yml" line_range="57-58" />
<code_context>
+ run=true
+ if [ "$EVENT" = schedule ]; then
+ if wf=$(gh api "repos/$REPO/actions/runs/$RUN_ID" --jq .workflow_id) &&
+ last=$(gh api "repos/$REPO/actions/workflows/$wf/runs?branch=$BRANCH&per_page=20" \
+ --jq "[.workflow_runs[] | select(.id != $RUN_ID and .conclusion != \"cancelled\" and .event != \"pull_request\")][0].head_sha // \"\""); then
+ if [ "$last" = "$SHA" ]; then
+ run=false
</code_context>
<issue_to_address>
**Scheduled checks skip uncovered commits**
When the matching same-SHA run is failed, queued or in progress and later cancelled, or is a newer duplicate run, the selector assigns `last` from a run that is not an earlier successful completion, and the `last == SHA` check sets `run=false`; the scheduled suite skips a commit without a successful earlier run covering it.
Select only completed successful runs earlier than the current run before comparing their SHAs.
</issue_to_address>
### Comment 3
<location path=".github/workflows/ci.yml" line_range="57-58" />
<code_context>
+ run=true
+ if [ "$EVENT" = schedule ]; then
+ if wf=$(gh api "repos/$REPO/actions/runs/$RUN_ID" --jq .workflow_id) &&
+ last=$(gh api "repos/$REPO/actions/workflows/$wf/runs?branch=$BRANCH&per_page=20" \
+ --jq "[.workflow_runs[] | select(.id != $RUN_ID and .conclusion != \"cancelled\" and .event != \"pull_request\")][0].head_sha // \"\""); then
+ if [ "$last" = "$SHA" ]; then
+ run=false
</code_context>
<issue_to_address>
**Scheduled reruns skip the suite**
When someone chooses “Re-run all jobs” for a scheduled run and an earlier eligible run has the same SHA, the filter excludes the run being retried, then finds an earlier run with the same SHA and sets `run=false`. Re-running all jobs therefore skips the checks the caller is trying to rerun.
Allow scheduled reruns to proceed instead of applying the unchanged-commit gate.
</issue_to_address>
### Comment 4
<location path=".github/workflows/ci.yml" line_range="60" />
<code_context>
+ last=$(gh api "repos/$REPO/actions/workflows/$wf/runs?branch=$BRANCH&per_page=20" \
+ --jq "[.workflow_runs[] | select(.id != $RUN_ID and .conclusion != \"cancelled\" and .event != \"pull_request\")][0].head_sha // \"\""); then
+ if [ "$last" = "$SHA" ]; then
+ run=false
+ echo "$BRANCH is at $SHA, which the last run of this workflow took: nothing changed, the run ends here."
+ else
</code_context>
<issue_to_address>
**Nightly checks miss dependency regressions**
When an upstream dependency changes while the repository commit stays the same, the unchanged-SHA check sets `run=false`, so the scheduled test matrix does not install and test the newly released dependency; regressions remain undetected until another event runs CI.
Keep scheduled dependency checks running when the repository SHA is unchanged.
</issue_to_address>
### Comment 5
<location path=".github/workflows/ci.yml" line_range="58" />
<code_context>
+ if [ "$EVENT" = schedule ]; then
+ if wf=$(gh api "repos/$REPO/actions/runs/$RUN_ID" --jq .workflow_id) &&
+ last=$(gh api "repos/$REPO/actions/workflows/$wf/runs?branch=$BRANCH&per_page=20" \
+ --jq "[.workflow_runs[] | select(.id != $RUN_ID and .conclusion != \"cancelled\" and .event != \"pull_request\")][0].head_sha // \"\""); then
+ if [ "$last" = "$SHA" ]; then
+ run=false
</code_context>
<issue_to_address>
**Scheduled runs repeat the full suite**
When the 20 newest runs are excluded by the filter and an older eligible run has the current SHA, the API request limits results to 20 runs before `jq` removes excluded runs, so `last` is empty and `run=true`; the scheduled run repeats the suite unnecessarily.
Paginate through workflow runs until the newest eligible run is found before comparing its SHA.
</issue_to_address>A re-run of a scheduled run now always runs its work, a skip check that fails or leaves no answer lets the work run, and the lookup reads the newest 100 runs instead of 20.
Contributor
|
🎉 Version bumped!
The release workflow will be triggered automatically. |
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.
What changed
ci.ymlgets a first job,changed(ubuntu-latest, no checkout). On a scheduled run it reads the newest earlier run of this workflow on master (whatever its result, a cancelled run aside) and, when master is still at that run's commit,pre-checkskips, and with it every job that needs it;all-checkskeepsalways()and skips on that answer too. A push, a pull request or a dispatch always runs, and a lookup that fails runs the suite.The daily run repeated the full suite on the same commit,
1740ce4a, day after day (about 10 minutes each) until GitHub disabled the schedule: 23127451256, 23177567976, 23228346090, 23279071437, 23328281049, 23371351877.Follow-up 8b657405, from the reviews: a re-run of a scheduled run (
github.run_attemptabove 1) always runs; a skip check that fails or gives no answer runs the work (!cancelled() && needs.changed.outputs.run != 'false'); the lookup reads the newest 100 runs instead of 20.Issue
No issue
Tests
No local run (CI-only rule). The job graph was read back from the YAML. This pull request's own run shows
changedansweringrun=truefor a pull request.Not merged on purpose: a push to master here deploys the docs to GitHub Pages (
docs-deploy) and can bump the version (version-bump-push.yml). It stays open for a deliberate merge.Summary by Sourcery
Avoid rerunning the full CI suite on scheduled runs when the branch has not changed since the previous workflow run.
Enhancements:
CI: