Skip to content

Commit d9d3beb

Browse files
authored
Make it easier to run lychee locally (open-telemetry#14155)
1 parent 8bcdeff commit d9d3beb

9 files changed

+67
-36
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# this file exists so that Renovate can auto-update docker image versions that are then used elsewhere
2+
3+
FROM lycheeverse/lychee:sha-2aa22f8@sha256:2e3786630482c41f9f2dd081e06d7da1c36d66996e8cf6573409b8bc418d48c4 AS lychee

.github/scripts/link-check.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
export MSYS_NO_PATHCONV=1 # for Git Bash on Windows
6+
7+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+
LYCHEE_CONFIG="$SCRIPT_DIR/../../.lychee.toml"
9+
DEPENDENCIES_DOCKERFILE="$SCRIPT_DIR/dependencies.dockerfile"
10+
11+
# Extract lychee version from dependencies.dockerfile
12+
LYCHEE_VERSION=$(grep "FROM lycheeverse/lychee:" "$DEPENDENCIES_DOCKERFILE" | sed 's/.*FROM lycheeverse\/lychee:\([^ ]*\).*/\1/')
13+
14+
# Build the lychee command with optional GitHub token
15+
CMD="lycheeverse/lychee:$LYCHEE_VERSION --verbose --config $(basename "$LYCHEE_CONFIG")"
16+
17+
# Add GitHub token if available
18+
if [[ -n "$GITHUB_TOKEN" ]]; then
19+
CMD="$CMD --github-token $GITHUB_TOKEN"
20+
fi
21+
22+
# Add the target directory
23+
CMD="$CMD ."
24+
25+
# Determine if we should allocate a TTY
26+
DOCKER_FLAGS="--rm --init"
27+
if [[ -t 0 ]]; then
28+
DOCKER_FLAGS="$DOCKER_FLAGS -it"
29+
else
30+
DOCKER_FLAGS="$DOCKER_FLAGS -i"
31+
fi
32+
33+
# Run lychee with proper signal handling
34+
# shellcheck disable=SC2086
35+
exec docker run $DOCKER_FLAGS -v "$(dirname "$LYCHEE_CONFIG")":/data -w /data $CMD

.github/workflows/build-daily-no-build-cache.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
# muzzle is not included here because it doesn't use gradle cache anyway and so is already covered
2828
# by the normal daily build
2929

30-
# markdown-link-check and misspell-check are not included here because they don't use gradle cache
30+
# link-check and misspell-check are not included here because they don't use gradle cache
3131
# anyway and so are already covered by the normal daily build
3232

3333
workflow-notification:

.github/workflows/build-daily.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jobs:
2626
shell-script-check:
2727
uses: ./.github/workflows/reusable-shell-script-check.yml
2828

29-
markdown-link-check:
30-
uses: ./.github/workflows/reusable-markdown-link-check.yml
29+
link-check:
30+
uses: ./.github/workflows/reusable-link-check.yml
3131

3232
markdown-lint-check:
3333
uses: ./.github/workflows/reusable-markdown-lint-check.yml
@@ -43,7 +43,7 @@ jobs:
4343
- common
4444
- test-latest-deps
4545
- muzzle
46-
- markdown-link-check
46+
- link-check
4747
- misspell-check
4848
if: always()
4949
uses: ./.github/workflows/reusable-workflow-notification.yml
@@ -53,6 +53,6 @@ jobs:
5353
needs.common.result == 'success' &&
5454
needs.test-latest-deps.result == 'success' &&
5555
needs.muzzle.result == 'success' &&
56-
needs.markdown-link-check.result == 'success' &&
56+
needs.link-check.result == 'success' &&
5757
needs.misspell-check.result == 'success'
5858
}}

.github/workflows/build-pull-request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ jobs:
4343
uses: ./.github/workflows/reusable-shell-script-check.yml
4444

4545
# this is not a required check to avoid blocking pull requests if external links break
46-
markdown-link-check:
46+
markdown-check:
4747
# release branches are excluded because the README.md javaagent download link has to be updated
4848
# on release branches before the release download has been published
4949
if: "!startsWith(github.ref_name, 'release/') && !startsWith(github.base_ref, 'release/')"
50-
uses: ./.github/workflows/reusable-markdown-link-check.yml
50+
uses: ./.github/workflows/reusable-link-check.yml
5151

5252
markdown-lint-check:
5353
uses: ./.github/workflows/reusable-markdown-lint-check.yml

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ jobs:
3737
if: "!startsWith(github.ref_name, 'release/')"
3838
uses: ./.github/workflows/reusable-shell-script-check.yml
3939

40-
markdown-link-check:
40+
link-check:
4141
# release branches are excluded to avoid unnecessary maintenance if external links break
4242
# (and also because the README.md javaagent download link has to be updated on release branches
4343
# before the release download has been published)
4444
if: "!startsWith(github.ref_name, 'release/')"
45-
uses: ./.github/workflows/reusable-markdown-link-check.yml
45+
uses: ./.github/workflows/reusable-link-check.yml
4646

4747
markdown-lint-check:
4848
# release branches are excluded
@@ -58,7 +58,7 @@ jobs:
5858
publish-snapshots:
5959
needs:
6060
# intentionally not blocking snapshot publishing on test-latest-deps, muzzle,
61-
# markdown-link-check, or misspell-check
61+
# link-check, or misspell-check
6262
- common
6363
runs-on: ubuntu-latest
6464
# skipping release branches because the versions in those branches are not snapshots
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Reusable - Link check
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
link-check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
14+
15+
- name: Link check
16+
env:
17+
GITHUB_TOKEN: ${{ github.token }}
18+
run: ./.github/scripts/link-check.sh

.github/workflows/reusable-markdown-link-check.yml

Lines changed: 0 additions & 20 deletions
This file was deleted.

lychee.toml renamed to .lychee.toml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ retry_wait_time = 5
33
max_retries = 6
44
max_concurrency = 4
55

6-
# Stealth
7-
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0"
8-
9-
# Check fragments in links
6+
# Check link anchors
107
include_fragments = true
118

129
# excluding links to pull requests and issues is done for performance
@@ -17,5 +14,3 @@ exclude = [
1714
'^https://softwareengineering.stackexchange.com/questions/29727.*',
1815
'^https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/io/opentelemetry/$',
1916
]
20-
21-

0 commit comments

Comments
 (0)