Repository navigation
ci: improve linkcheck job behavior and failure modes
#5429
Workflow file for this run
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
| name: Test | |
| on: | |
| merge_group: | |
| push: | |
| branches-ignore: | |
| - gh-readonly-queue/** # Temporary merge queue-related GH-made branches | |
| pull_request: | |
| types: | |
| - opened # default | |
| - synchronize # default | |
| - reopened # default | |
| - ready_for_review # used in PRs created from GitHub Actions workflows | |
| workflow_call: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} | |
| cancel-in-progress: true | |
| permissions: {} | |
| jobs: | |
| build: | |
| name: ${{ matrix.noxenv }} | |
| if: ${{ github.repository_owner == 'pypa' || github.event_name != 'schedule' }} | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| continue-on-error: >- | |
| ${{ fromJSON(matrix.continue-on-error) }} | |
| env: | |
| LINKCHECK_BASE_REF: >- | |
| ${{ matrix.noxenv == 'linkcheck' && | |
| (github.event.pull_request.base.sha || github.event.merge_group.base_sha) || '' }} | |
| LINKCHECK_BASELINE: >- | |
| ${{ matrix.noxenv == 'linkcheck' && | |
| contains(fromJSON('["pull_request", "merge_group"]'), github.event_name) && | |
| format('{0}/.nox/.cache/linkcheck-baseline.jsonl', github.workspace) || '' }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| noxenv: | |
| - build | |
| - tests | |
| continue-on-error: | |
| - false | |
| include: | |
| - noxenv: linkcheck | |
| # Pushes monitor all links; only new links block PRs and merge groups. | |
| # Scheduled runs remain blocking to report site-wide link failures. | |
| continue-on-error: >- | |
| ${{ toJSON(github.event_name == 'push') }} | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| persist-credentials: false | |
| - name: Set up Python | |
| uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v6.0.0 | |
| with: | |
| python-version: "3.14" | |
| cache: 'pip' | |
| cache-dependency-path: 'requirements.txt' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade nox virtualenv | |
| - name: Restore linkcheck baseline | |
| if: env.LINKCHECK_BASE_REF != '' | |
| uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: .nox/.cache/linkcheck-baseline.jsonl | |
| key: linkcheck-baseline-v1-${{ env.LINKCHECK_BASE_REF }} | |
| - name: Nox ${{ matrix.noxenv }} | |
| env: | |
| # Authenticate github.com requests during linkcheck to avoid rate limits. | |
| GITHUB_TOKEN: ${{ matrix.noxenv == 'linkcheck' && github.token || '' }} | |
| run: | | |
| python -m nox -s ${{ matrix.noxenv }} | |
| - name: Prepare report for baseline cache | |
| id: baseline-report | |
| if: >- | |
| ${{ always() && matrix.noxenv == 'linkcheck' && github.event_name == 'push' && | |
| github.ref_name == github.event.repository.default_branch }} | |
| run: >- | |
| python scripts/linkcheck.py publish --report build/output.json | |
| --baseline .nox/.cache/linkcheck-baseline.jsonl | |
| - name: Save linkcheck baseline | |
| if: ${{ always() && steps.baseline-report.outcome == 'success' }} | |
| uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: .nox/.cache/linkcheck-baseline.jsonl | |
| key: linkcheck-baseline-v1-${{ github.sha }} | |
| - name: Upload full linkcheck reports | |
| if: >- | |
| ${{ always() && matrix.noxenv == 'linkcheck' && | |
| (github.event_name == 'schedule' || (github.event_name == 'push' && | |
| github.ref_name == github.event.repository.default_branch)) }} | |
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 | |
| with: | |
| name: linkcheck-reports | |
| path: | | |
| build/output.json | |
| build/output.txt | |
| if-no-files-found: warn | |
| - name: Summarize full linkcheck | |
| if: >- | |
| ${{ always() && matrix.noxenv == 'linkcheck' && | |
| (github.event_name == 'schedule' || (github.event_name == 'push' && | |
| github.ref_name == github.event.repository.default_branch)) }} | |
| run: >- | |
| python scripts/linkcheck.py summarize --report build/output.json | |
| --summary "$GITHUB_STEP_SUMMARY" | |
| check: | |
| # This job does nothing and is only used for the branch protection | |
| # or multi-stage CI jobs, like making sure that all tests pass before | |
| # a publishing job is started. | |
| if: always() | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Decide whether the needed jobs succeeded or failed | |
| uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2 | |
| with: | |
| jobs: ${{ toJSON(needs) }} |