Only run linkcheck for changed source files in PRs#860
Open
JoergAtGithub wants to merge 1 commit into
Open
Conversation
1b951bf to
3174293
Compare
bdb75e1 to
175c64c
Compare
Member
Author
|
I tested this with injected failures in this PR. Finally it worked as intended and I reverted the injected failures. |
acolombier
reviewed
Mar 28, 2026
Member
acolombier
left a comment
There was a problem hiding this comment.
Thanks for addressing this. I have suggested a bash-only approach, that could allow removing the Python script and allow to easily run it locally when debugging
Comment on lines
+20
to
+38
| - name: Fetch base branch for diff | ||
| if: github.event_name == 'pull_request' | ||
| run: git fetch origin ${{ github.event.pull_request.base.sha }} | ||
| - name: Get changed source files | ||
| id: changed | ||
| if: github.event_name == 'pull_request' | ||
| env: | ||
| GITHUB_EVENT_NAME: ${{ github.event_name }} | ||
| PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} | ||
| PUSH_BEFORE_SHA: ${{ github.event.before }} | ||
| run: python tools/list_changed_source_files.py | ||
| - name: Install Python dependencies | ||
| if: github.event_name == 'push' || steps.changed.outputs.files != '' | ||
| run: | | ||
| python -m pip install --upgrade pip | ||
| python -m pip install -r requirements.txt | ||
| - name: Check for broken links | ||
| run: sphinx-build -q --color -b linkcheck source build | ||
| if: github.event_name == 'push' || steps.changed.outputs.files != '' | ||
| run: sphinx-build -q --color -b linkcheck source build ${{ steps.changed.outputs.files }} |
Member
There was a problem hiding this comment.
Suggested change
| - name: Fetch base branch for diff | |
| if: github.event_name == 'pull_request' | |
| run: git fetch origin ${{ github.event.pull_request.base.sha }} | |
| - name: Get changed source files | |
| id: changed | |
| if: github.event_name == 'pull_request' | |
| env: | |
| GITHUB_EVENT_NAME: ${{ github.event_name }} | |
| PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
| PUSH_BEFORE_SHA: ${{ github.event.before }} | |
| run: python tools/list_changed_source_files.py | |
| - name: Install Python dependencies | |
| if: github.event_name == 'push' || steps.changed.outputs.files != '' | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -r requirements.txt | |
| - name: Check for broken links | |
| run: sphinx-build -q --color -b linkcheck source build | |
| if: github.event_name == 'push' || steps.changed.outputs.files != '' | |
| run: sphinx-build -q --color -b linkcheck source build ${{ steps.changed.outputs.files }} | |
| - name: Fetch base branch for diff | |
| if: github.event_name == 'pull_request' | |
| run: git fetch origin ${{ github.event.pull_request.base.sha }} | |
| - name: Install Python dependencies | |
| if: github.event_name == 'push' || steps.changed.outputs.files != '' | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install -r requirements.txt | |
| - name: Check for broken links | |
| env: | |
| BEFORE: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }} | |
| run: | | |
| changed_files=`git diff $BEFORE --name-only --diff-filter=d HEAD -- source/ | grep -E '\.(md|rst)$' | xargs` | |
| if [ -n "$changed_files" ]; then | |
| sphinx-build -q --color -b linkcheck source build $changed_files | |
| fi |
Member
Author
|
bash is Unix only. Not a good option for a platform Independent project. |
Member
|
Does git not come with Bash anymore on Windows? |
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.
This still runs the full link-check over all source files on push commits, but in PRs it only checks th links in files source files changed compared to the base commit of the PR.
Means if we want to see the full list of broken links, we can always look at the resul of branches like 2.5, 2.6 or main, while the CI result of PR buils will be green unless a link in the modified fils is broken.