Skip to content

Commit

Permalink
chore: use lychee for links checking
Browse files Browse the repository at this point in the history
  • Loading branch information
leiicamundi committed May 21, 2024
1 parent 9d49e18 commit caae0b4
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 27 deletions.
20 changes: 0 additions & 20 deletions .github/markdown-links.json

This file was deleted.

40 changes: 40 additions & 0 deletions .github/workflows/links.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Check external links

on:
push:
workflow_dispatch:
schedule:
- cron: "0 3 1 * *"

jobs:
lint:
name: links-check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4

- name: Get Current Timestamp
id: timestamp
run: echo "TIMESTAMP=$(date +%s)" >> "$GITHUB_ENV"

- name: Restore lychee cache
uses: actions/cache@e12d46a63a90f2fae62d114769bbf2a179198b5c # v3
with:
path: .lycheecache
key: "cache-lychee-${{ env.TIMESTAMP }}"
restore-keys: cache-lychee-

- name: Link Checker
uses: lycheeverse/lychee-action@2b973e86fc7b1f6b36a93795fe2c9c6ae1118621 # v1.10.0
with:
fail: true
args: -c ./lychee-links.toml --base . --cache --max-cache-age 1d . --verbose --no-progress '*.md' './**/*.md'
token: "${{ secrets.GITHUB_TOKEN }}"

- name: Create Issue From File
if: ${{ github.event_name == 'schedule' && env.lychee_exit_code != 0 }}
uses: peter-evans/create-issue-from-file@433e51abf769039ee20ba1293a088ca19d573b7f # v4
with:
title: Link Checker Report
content-filepath: ./lychee/out.md
labels: report, automated issue
8 changes: 1 addition & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,7 @@ repos:
args: ["--strict" , "--force-scope"]

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
rev: v0.10.0.1 # use tags until renovate supports sha: https://github.com/renovatebot/renovate/issues/22567
hooks:
- id: shellcheck

- repo: https://github.com/tcort/markdown-link-check
rev: v3.12.1 # use tags until renovate supports sha: https://github.com/renovatebot/renovate/issues/22567
hooks:
- id: markdown-link-check
args: [-q, -c .github/markdown-links.json]
...
19 changes: 19 additions & 0 deletions lychee-links.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Cache the results of Lychee if ran locally in order to minimise the chance of rate limiting
cache = true
# Ignore all private link (such as localhost) to avoid errors
exclude_all_private = true
# HTTP status code: 429 (Too Many Requests) will also be treated as a valid link if Lychee gets rate limited
accept = ["200", "403"]
# retry
max_retries = 6
retry_wait_time = 10
max_concurrency = 3

# Exclude all unsupported versioned_docs
exclude_path = [
]

# Explicitly exclude some URLs
exclude = [
"^file:",
]

0 comments on commit caae0b4

Please sign in to comment.