-
Notifications
You must be signed in to change notification settings - Fork 23
Workflow changes to add automated link checking #428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
cf97781
Initial plan
Copilot 581abfe
Add check-links.yml workflow with all PR #424 feedback applied
Copilot d5168bd
Address all bart-vmware review feedback on check-links.yml and build-…
Copilot 68fb4ea
add link-checking of internal links of built site content
TimHess d1f19ab
process improvements, add local script for checking links from all do…
TimHess 5631660
focus on external link checking in static content
TimHess 6af1af4
drop branch filter from PR trigger
TimHess cc825fe
fix lychee install link
TimHess 82e6e9f
focus check-links job on external links, exclude vendored sources
TimHess ec140f6
add --root-dir to resolve root-relative image paths without error
TimHess 02374e2
Update .github/workflows/check-links.yml
TimHess 9016ef2
PR suggests and alphabetize lychee params
TimHess dd15c02
re-add root-dir, primarily for running in CI
TimHess ec3c124
re-add --verbose, local script enhancements
TimHess b0140cd
move settings to shared lychee.toml
TimHess b26c2cb
fix exclude_paths broken in move to lychee.toml
TimHess 83b2dab
isolate lychee caching to specific workstreams
TimHess ef49b7e
Apply suggestions from code review
TimHess File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| name: Check external links | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| pull_request: | ||
| paths: | ||
| - '**.md' | ||
| - 'docs/**' | ||
| - '.github/workflows/check-links.yml' | ||
| - 'lychee.toml' | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| check-links: | ||
| name: Check external links in documentation | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Git checkout | ||
|
bart-vmware marked this conversation as resolved.
|
||
| uses: actions/checkout@v6 | ||
| with: | ||
| persist-credentials: false | ||
|
|
||
| # To clear the lychee cache for a PR, replace `<pull-request-number>` with the PR number and run in pwsh: | ||
| # $ids = gh api repos/SteeltoeOSS/Documentation/actions/caches ` | ||
| # --paginate ` | ||
| # --jq '.actions_caches[] | ||
| # | select(.key | startswith("cache-lychee-<pull-request-number>-")) | ||
| # | .id' | ||
| # $ids | ForEach-Object { | ||
| # gh api -X DELETE "repos/SteeltoeOSS/Documentation/actions/caches/$_" | ||
| # Write-Host "Deleted cache $_" | ||
| # } | ||
| - name: Restore lychee cache | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: .lycheecache | ||
| key: cache-lychee-${{ github.event.pull_request.number || 'manual' }}-${{ github.sha }} | ||
| restore-keys: cache-lychee-${{ github.event.pull_request.number || 'manual' }}- | ||
|
|
||
| - name: Check external links with lychee | ||
| uses: lycheeverse/lychee-action@v2 | ||
| with: | ||
| args: --no-progress '**/*.md' | ||
| fail: false | ||
| failIfEmpty: true | ||
| jobSummary: false | ||
|
bart-vmware marked this conversation as resolved.
|
||
|
|
||
| - name: Add link checking results to job summary | ||
| run: | | ||
| if [ -f ./lychee/out.md ]; then | ||
| sed 's/^# Summary$/# External link checking results/' ./lychee/out.md | tee -a "$GITHUB_STEP_SUMMARY" > ./lychee/results.md | ||
| fi | ||
|
|
||
| - name: Comment on PR with link check results | ||
| if: ${{ github.event_name == 'pull_request' }} | ||
| uses: mshick/add-pr-comment@v2 | ||
| with: | ||
| message-id: external-links-check | ||
| message-path: ./lychee/results.md | ||
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/usr/bin/env pwsh | ||
| # Check external links in markdown files, matching what the check-links CI job does. | ||
| # Run from anywhere in the repo. Requires lychee: https://lychee.cli.rs/guides/getting-started/ | ||
|
|
||
| Set-StrictMode -Version Latest | ||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| if (-not (Get-Command lychee -ErrorAction SilentlyContinue)) { | ||
| throw 'lychee not found. Install: cargo install lychee, scoop install lychee, or winget install lycheeverse.lychee' | ||
| } | ||
|
|
||
| $baseDir = Split-Path -Parent $MyInvocation.MyCommand.Path | ||
| $repoRoot = (Get-Item $baseDir).Parent.FullName | ||
| Push-Location $repoRoot | ||
|
|
||
| try { | ||
| $mdFiles = Get-ChildItem -Path . -Filter '*.md' -Recurse -File | ||
| if ($mdFiles.Count -eq 0) { | ||
| throw 'No .md files found in the repository.' | ||
| } | ||
|
|
||
| Write-Output "Checking external links in $($mdFiles.Count) markdown files ..." | ||
|
|
||
| & lychee '**/*.md' | ||
|
|
||
| if ($LASTEXITCODE -ne 0) { | ||
| throw "lychee exited with code $LASTEXITCODE" | ||
| } | ||
| } | ||
| finally { | ||
| Pop-Location | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| # Shared lychee config for CI and local script (build/check-external-links.ps1). | ||
|
|
||
| verbose = "info" | ||
| cache = true | ||
| scheme = ["http", "https"] | ||
| require_https = true | ||
| include_fragments = true | ||
| retry_wait_time = 5 | ||
| root_dir = "." | ||
| host_concurrency = 5 | ||
| host_request_interval = "250ms" | ||
| exclude_loopback = true | ||
|
|
||
| # Browser-like UA so sites that block bots (e.g. mysql.com) respond normally. | ||
| user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36" | ||
|
|
||
| exclude = [ | ||
| # Placeholder hostnames in code samples. | ||
| "fortuneservice", | ||
| "\\.internal", | ||
| "consul-register-example", | ||
| # False positives: these sites generate anchor IDs via JS, so fragments | ||
| # aren't in the raw HTML. Track https://github.com/lycheeverse/lychee/issues/1729 | ||
| "https://learn\\.microsoft\\.com/.*#remarks", | ||
| "https://github\\.com/.*#", | ||
| ] | ||
|
|
||
| exclude_path = [ | ||
| # Vendored sources from API browser build. | ||
| "build.sources", | ||
| "build.docfx-net10-binaries", | ||
| ] |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.