diff --git a/.github/workflows/linkcheck.yml b/.github/workflows/linkcheck.yml index 705597c54..3ee3dcae4 100644 --- a/.github/workflows/linkcheck.yml +++ b/.github/workflows/linkcheck.yml @@ -6,12 +6,14 @@ on: schedule: # https://crontab.guru/#00_18_*_*_1 - cron: "00 18 * * 1" + pull_request: permissions: issues: write jobs: - linkChecker: + linkcheck-pr: + if: github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -25,22 +27,37 @@ jobs: - name: Build run: hugo --minify - - name: Link Checker - uses: lycheeverse/lychee-action@v2.0.2 + # Intentionally skips (req for full deploy parity) to keep + # PR checks fast and network-light. + - name: Generate blog post redirects + run: python scripts/generate-blog-aliases.py + + - name: Link Checker (internal, offline) + uses: lycheeverse/lychee-action@v2.7.0 + with: + args: --offline --no-progress --root-dir "${{ github.workspace }}/public" --exclude '^file://.*/public/roadmap/?$' public/**/*.html + + linkcheck-scheduled: + if: github.event_name != 'pull_request' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup Hugo + uses: peaceiris/actions-hugo@v2 + with: + hugo-version: '0.125.3' + extended: true + + - name: Build + run: hugo --minify + + - name: Generate blog post redirects + run: python scripts/generate-blog-aliases.py + + - name: Link Checker (external) + uses: lycheeverse/lychee-action@v2.7.0 with: - args: | - # fonts.gstatic.com is an expected fail - --exclude https://fonts.gstatic.com - # "%oo many requests" errors - --exclude twitter.com - # 403 Forbidden errors - --exclude https://data8.org - # 403 Forbidden errors - --exclude https://biorxiv.org - --exclude https://www.biorxiv.org - --verbose - --no-progress - public/**/*.html + args: --verbose --no-progress --root-dir "${{ github.workspace }}/public" public/**/*.html env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} @@ -50,4 +67,4 @@ jobs: with: title: Link Checker Report content-filepath: ./lychee/out.md - labels: report, automated issue \ No newline at end of file + labels: report, automated issue diff --git a/lychee.toml b/lychee.toml new file mode 100644 index 000000000..eb9603963 --- /dev/null +++ b/lychee.toml @@ -0,0 +1,9 @@ +exclude = [ + "https://fonts.gstatic.com", # expected connectivity failure + "twitter.com", + "https://data8.org", + "https://biorxiv.org", + "https://www.biorxiv.org", +] + +max_concurrency = 50 diff --git a/noxfile.py b/noxfile.py index 8efeb0a98..d5ac13135 100644 --- a/noxfile.py +++ b/noxfile.py @@ -54,8 +54,6 @@ def linkcheck(session): "--offline", "--accept", "200,301,302", - "--max-concurrency", - "50", "public", external=True, )