From caae0b4e7edf471044e9e2debca3ad0137f78cf2 Mon Sep 17 00:00:00 2001 From: leiicamundi <153937047+leiicamundi@users.noreply.github.com> Date: Tue, 21 May 2024 09:28:39 +0200 Subject: [PATCH] chore: use lychee for links checking --- .github/markdown-links.json | 20 ------------------- .github/workflows/links.yml | 40 +++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 8 +------- lychee-links.toml | 19 ++++++++++++++++++ 4 files changed, 60 insertions(+), 27 deletions(-) delete mode 100644 .github/markdown-links.json create mode 100644 .github/workflows/links.yml create mode 100644 lychee-links.toml diff --git a/.github/markdown-links.json b/.github/markdown-links.json deleted file mode 100644 index 4a04df6..0000000 --- a/.github/markdown-links.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "projectBaseUrl":"${workspaceFolder}", - "ignorePatterns": [ - { - "pattern": "^http(s?)://localhost" - }, - { - "pattern": "^#" - } - ], - "replacementPatterns": [ - ], - "httpHeaders": [ - ], - "timeout": "20s", - "retryOn429": true, - "retryCount": 5, - "fallbackRetryDelay": "30s", - "aliveStatusCodes": [200, 206] - } diff --git a/.github/workflows/links.yml b/.github/workflows/links.yml new file mode 100644 index 0000000..79d7d9b --- /dev/null +++ b/.github/workflows/links.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f99a63c..78069a9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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] ... diff --git a/lychee-links.toml b/lychee-links.toml new file mode 100644 index 0000000..8fe7ed8 --- /dev/null +++ b/lychee-links.toml @@ -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:", +]