Skip to content

Only run linkcheck for changed source files in PRs#860

Open
JoergAtGithub wants to merge 1 commit into
mixxxdj:2.6from
JoergAtGithub:link_check_only_for_changed_files
Open

Only run linkcheck for changed source files in PRs#860
JoergAtGithub wants to merge 1 commit into
mixxxdj:2.6from
JoergAtGithub:link_check_only_for_changed_files

Conversation

@JoergAtGithub
Copy link
Copy Markdown
Member

@JoergAtGithub JoergAtGithub commented Mar 28, 2026

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.

@JoergAtGithub JoergAtGithub force-pushed the link_check_only_for_changed_files branch 2 times, most recently from 1b951bf to 3174293 Compare March 28, 2026 11:24
@JoergAtGithub JoergAtGithub force-pushed the link_check_only_for_changed_files branch 2 times, most recently from bdb75e1 to 175c64c Compare March 28, 2026 11:44
@JoergAtGithub
Copy link
Copy Markdown
Member Author

I tested this with injected failures in this PR. Finally it worked as intended and I reverted the injected failures.

@JoergAtGithub JoergAtGithub marked this pull request as ready for review March 28, 2026 11:50
Copy link
Copy Markdown
Member

@acolombier acolombier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 }}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@JoergAtGithub
Copy link
Copy Markdown
Member Author

bash is Unix only. Not a good option for a platform Independent project.

@acolombier
Copy link
Copy Markdown
Member

Does git not come with Bash anymore on Windows?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants