From 308c9d6871fe66fc375ef5aa77aa9191b922b05f Mon Sep 17 00:00:00 2001 From: Jason Plumb Date: Mon, 30 Jun 2025 10:44:12 -0700 Subject: [PATCH 1/3] add config for link checker --- .../reusable-markdown-link-check.yml | 7 ++----- lychee.toml | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 lychee.toml diff --git a/.github/workflows/reusable-markdown-link-check.yml b/.github/workflows/reusable-markdown-link-check.yml index 3120678ce..7c2f372df 100644 --- a/.github/workflows/reusable-markdown-link-check.yml +++ b/.github/workflows/reusable-markdown-link-check.yml @@ -14,10 +14,7 @@ jobs: - uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332 # v2.4.1 with: - # excluding links to pull requests and issues is done for performance args: > - --include-fragments - --exclude "^https://github.com/open-telemetry/opentelemetry-java-contrib/(issues|pull)/\\d+$" - --max-retries 6 - --max-concurrency 1 + --config ./lychee.toml + --github-token ${{ github.token }} . diff --git a/lychee.toml b/lychee.toml new file mode 100644 index 000000000..ad31749b0 --- /dev/null +++ b/lychee.toml @@ -0,0 +1,19 @@ +timeout = 30 +retry_wait_time = 5 +max_retries = 6 +max_concurrency = 1 + +# Stealth +user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0" + +# Check fragments in links +include_fragments = true + +# excluding links to pull requests and issues is done for performance +# sonatype snapshots are currrently unbrowseable +exclude = [ + "^https://github.com/open-telemetry/opentelemetry-java-contrib/(issues|pull)/\\d+$", + '^https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/io/opentelemetry/contrib/$', +] + + From 6a92818c46e4391888c97047c4817092b9b55db8 Mon Sep 17 00:00:00 2001 From: Jason Plumb Date: Mon, 30 Jun 2025 10:44:24 -0700 Subject: [PATCH 2/3] github.token is the default, so we remove it --- .github/workflows/reusable-markdown-link-check.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/reusable-markdown-link-check.yml b/.github/workflows/reusable-markdown-link-check.yml index 7c2f372df..5225a3f5a 100644 --- a/.github/workflows/reusable-markdown-link-check.yml +++ b/.github/workflows/reusable-markdown-link-check.yml @@ -16,5 +16,4 @@ jobs: with: args: > --config ./lychee.toml - --github-token ${{ github.token }} . From 466b28dc0f765adb8cdf30cd2fd3f308d047d995 Mon Sep 17 00:00:00 2001 From: Jason Plumb Date: Tue, 1 Jul 2025 09:37:45 -0700 Subject: [PATCH 3/3] align link checking with changes in instrumentation repo --- .github/scripts/dependencies.dockerfile | 3 ++ .github/scripts/link-check.sh | 35 +++++++++++++++++++ .github/workflows/build.yml | 10 ++++-- .github/workflows/reusable-link-check.yml | 18 ++++++++++ .../reusable-markdown-link-check.yml | 19 ---------- lychee.toml => .lychee.toml | 7 ++-- 6 files changed, 65 insertions(+), 27 deletions(-) create mode 100644 .github/scripts/dependencies.dockerfile create mode 100755 .github/scripts/link-check.sh create mode 100644 .github/workflows/reusable-link-check.yml delete mode 100644 .github/workflows/reusable-markdown-link-check.yml rename lychee.toml => .lychee.toml (72%) diff --git a/.github/scripts/dependencies.dockerfile b/.github/scripts/dependencies.dockerfile new file mode 100644 index 000000000..d8e3bbfe1 --- /dev/null +++ b/.github/scripts/dependencies.dockerfile @@ -0,0 +1,3 @@ +# this file exists so that Renovate can auto-update docker image versions that are then used elsewhere + +FROM lycheeverse/lychee:sha-2aa22f8@sha256:2e3786630482c41f9f2dd081e06d7da1c36d66996e8cf6573409b8bc418d48c4 AS lychee diff --git a/.github/scripts/link-check.sh b/.github/scripts/link-check.sh new file mode 100755 index 000000000..788e22830 --- /dev/null +++ b/.github/scripts/link-check.sh @@ -0,0 +1,35 @@ +#!/bin/bash + +set -e + +export MSYS_NO_PATHCONV=1 # for Git Bash on Windows + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +LYCHEE_CONFIG="$SCRIPT_DIR/../../.lychee.toml" +DEPENDENCIES_DOCKERFILE="$SCRIPT_DIR/dependencies.dockerfile" + +# Extract lychee version from dependencies.dockerfile +LYCHEE_VERSION=$(grep "FROM lycheeverse/lychee:" "$DEPENDENCIES_DOCKERFILE" | sed 's/.*FROM lycheeverse\/lychee:\([^ ]*\).*/\1/') + +# Build the lychee command with optional GitHub token +CMD="lycheeverse/lychee:$LYCHEE_VERSION --verbose --config $(basename "$LYCHEE_CONFIG")" + +# Add GitHub token if available +if [[ -n "$GITHUB_TOKEN" ]]; then + CMD="$CMD --github-token $GITHUB_TOKEN" +fi + +# Add the target directory +CMD="$CMD ." + +# Determine if we should allocate a TTY +DOCKER_FLAGS="--rm --init" +if [[ -t 0 ]]; then + DOCKER_FLAGS="$DOCKER_FLAGS -it" +else + DOCKER_FLAGS="$DOCKER_FLAGS -i" +fi + +# Run lychee with proper signal handling +# shellcheck disable=SC2086 +exec docker run $DOCKER_FLAGS -v "$(dirname "$LYCHEE_CONFIG")":/data -w /data $CMD diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4850fa48c..939716004 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -118,8 +118,12 @@ jobs: name: integration-test-results path: jmx-metrics/build/reports/tests/integrationTest - markdown-link-check: - uses: ./.github/workflows/reusable-markdown-link-check.yml + link-check: + # release branches are excluded to avoid unnecessary maintenance if external links break + # (and also because the README.md might need update on release branches before the release + # download has been published) + if: "!startsWith(github.ref_name, 'release/')" + uses: ./.github/workflows/reusable-link-check.yml markdown-lint-check: uses: ./.github/workflows/reusable-markdown-lint.yml @@ -142,7 +146,7 @@ jobs: # and so would not short-circuit if used in the second-last position name: publish-snapshots${{ (github.ref_name != 'main' || github.repository != 'open-telemetry/opentelemetry-java-contrib') && ' (skipped)' || '' }} needs: - # intentionally not blocking snapshot publishing on markdown-link-check or misspell-check + # intentionally not blocking snapshot publishing on link-check or misspell-check - build - integration-test runs-on: ubuntu-latest diff --git a/.github/workflows/reusable-link-check.yml b/.github/workflows/reusable-link-check.yml new file mode 100644 index 000000000..044e85e1f --- /dev/null +++ b/.github/workflows/reusable-link-check.yml @@ -0,0 +1,18 @@ +name: Reusable - Link check + +on: + workflow_call: + +permissions: + contents: read + +jobs: + link-check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Link check + env: + GITHUB_TOKEN: ${{ github.token }} + run: ./.github/scripts/link-check.sh diff --git a/.github/workflows/reusable-markdown-link-check.yml b/.github/workflows/reusable-markdown-link-check.yml deleted file mode 100644 index 5225a3f5a..000000000 --- a/.github/workflows/reusable-markdown-link-check.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: Reusable - Markdown link check - -on: - workflow_call: - -permissions: - contents: read - -jobs: - markdown-link-check: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - uses: lycheeverse/lychee-action@82202e5e9c2f4ef1a55a3d02563e1cb6041e5332 # v2.4.1 - with: - args: > - --config ./lychee.toml - . diff --git a/lychee.toml b/.lychee.toml similarity index 72% rename from lychee.toml rename to .lychee.toml index ad31749b0..d368a2404 100644 --- a/lychee.toml +++ b/.lychee.toml @@ -1,12 +1,9 @@ timeout = 30 retry_wait_time = 5 max_retries = 6 -max_concurrency = 1 +max_concurrency = 4 -# Stealth -user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:128.0) Gecko/20100101 Firefox/128.0" - -# Check fragments in links +# Check link anchors include_fragments = true # excluding links to pull requests and issues is done for performance