@@ -25,18 +25,11 @@ jobs:
2525 if : ${{ github.repository_owner == 'pypa' || github.event_name != 'schedule' }}
2626 runs-on : ubuntu-latest
2727 timeout-minutes : 20
28- continue-on-error : >-
29- ${{ fromJSON(matrix.continue-on-error) }}
3028 strategy :
3129 matrix :
3230 noxenv :
3331 - build
34- continue-on-error :
35- - false
36- include :
37- - noxenv : linkcheck
38- continue-on-error : >- # Don't block PRs on linkcheck unrelated failures
39- ${{ toJSON(github.event_name == 'pull_request') }}
32+ - linkcheck
4033
4134 steps :
4235 - uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
@@ -50,17 +43,44 @@ jobs:
5043 cache : ' pip'
5144 cache-dependency-path : ' requirements.txt'
5245
46+ - name : Restore linkcheck report
47+ if : matrix.noxenv == 'linkcheck' && github.event_name == 'pull_request'
48+ id : linkcheck-cache
49+ uses : actions/cache/restore@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
50+ with :
51+ path : build/output.json
52+ key : linkcheck-${{ github.event.pull_request.base.sha }}
53+ restore-keys : |
54+ linkcheck-
55+
5356 - name : Install dependencies
5457 run : |
5558 python -m pip install --upgrade nox virtualenv
5659
5760 - name : Nox ${{ matrix.noxenv }}
61+ id : nox
62+ continue-on-error : ${{ matrix.noxenv == 'linkcheck' && github.event_name == 'pull_request' }}
5863 env :
5964 # Authenticate github.com requests during linkcheck to avoid rate limits.
6065 GITHUB_TOKEN : ${{ matrix.noxenv == 'linkcheck' && github.token || '' }}
6166 run : |
6267 python -m nox -s ${{ matrix.noxenv }}
6368
69+ - name : Fail on newly added broken links
70+ if : >-
71+ matrix.noxenv == 'linkcheck' &&
72+ github.event_name == 'pull_request' &&
73+ steps.linkcheck-cache.outputs.cache-hit != '' &&
74+ steps.nox.outcome == 'failure'
75+ run : exit 1
76+
77+ - name : Save linkcheck report
78+ if : matrix.noxenv == 'linkcheck' && github.event_name != 'pull_request' && success()
79+ uses : actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
80+ with :
81+ path : build/output.json
82+ key : linkcheck-${{ github.sha }}
83+
6484
6585 check :
6686 # This job does nothing and is only used for the branch protection
0 commit comments