Repository navigation
Skip CI jobs when a pull request does not change the code - issue #37 - #38
Conversation
A changes job decides whether the code has to be tested (everything but the *.md files counts as code). On a pull request, the jobs are skipped when the PR changes no code, or when a push does not change the code of the PR (e.g. resolving a CHANGELOG.md conflict or merging main) and ci-passed succeeded on the previous head. The PR's own diff is compared with git patch-id against its merge base, so that merging main does not count as a change. ci-passed reports success in these cases and still requires all jobs to pass otherwise. Pushes to main are always tested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Could you not use |
|
Thanks @sverhoeven, good question. I considered
That is why the workflow always runs: the |
|
agree with @sverhoeven here; also this PR looks fully AI-generated and the response above as well, which does not make much sense to me, it justifies its decisions based on an actions the agent itself has done (?) currently when it merges to main it will skip the tests, if you change indentation it will also skip the tests, even tho it can break the code. this is in practice a bash script written inside the action, which is anti-pattern and hard to maintain; you are using the description said:
# ...
changes:
name: Detect code changes
# ...
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
code:
- '**'
- '!**/*.md'
# ...
lint:
needs: changes
if: needs.changes.outputs.code == 'true'
# run
# ...
test:
needs: changes
if: needs.changes.outputs.code == 'true'
# run
this is likely being wrongly interpreted by the AI agent, in an interpreted language ALL the code needs to be tested regardless of where the change is, since there is no compiler to check all the code paths. if you change code in a module it can have effects in another part of the code which you will not know unless you test everything
here you just ignore to run the ci on
same likely mis-interpretation, this also requires test looks like this has already infected other repositories as well, @amjjbonvin please double check by yourself and not with your AI agent (this is a good example of scope creep) |
What does this PR do and why?
The workflow ran everything on every pull request event, so that a documentation-only PR, or the merge of
mainneeded to bring an approved PR up to date, reran the full matrix although no code changed.changesjob: decides whether the code has to be tested; everything but the*.mdfiles counts as code. On a pull request, the jobs are skipped whenCHANGELOG.mdconflict or mergingmain) andci-passedsucceeded on the previous head. The PR's own diff is compared withgit patch-idagainst its merge base, so that mergingmaindoes not count as a change.ci-passed: reports success when the jobs were skipped for these reasons, and still requires every job to pass otherwise (also when thechangesjob fails).main: always tested.CONTRIBUTING.mddescribes the skipping.How was this tested?
The
changesscript and theci-passedlogic, extracted from the workflow, were run locally withbash -e(as on GitHub) on the history of #30, #31 and #35:main: tested;ci-passedsucceeded on the previous head (82b9701): skipped;ci-passedbefore (commits from before the CI): tested;ci-passed: passes when the jobs were skipped or all passed; fails when a job failed, when the jobs were skipped although the code changed, or whenchangesfailed.The new jobs run on this PR itself (the workflow file counts as code, so everything is tested here).
AI assistance
Claude Code wrote the workflow change based on my specifications, adapting the change made in haddocking/haddock3#1749, and checked it as described above. I reviewed the changes.
Checklist
README.md,INSTALLATION.md) (CONTRIBUTING.md)test-cases/*/example-results/updated if the output changes (no output change)Related issues
Closes #37
Notes for reviewers
main, the combination is not tested in the PR when the code of the PR is unchanged; it is tested by the push tomainafter merging.ci-passedsucceeds on each of them.🤖 Generated with Claude Code