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/scripts/markdown-link-check-config.json b/.github/scripts/markdown-link-check-config.json deleted file mode 100644 index 3e0784cbf..000000000 --- a/.github/scripts/markdown-link-check-config.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "retryOn429": true, - "aliveStatusCodes": [ - 200, - 403 - ], - "ignorePatterns": [ - { - "pattern": "^http://localhost:16686$" - }, - { - "pattern": "^https://maven-badges.sml.io/maven-central/io.opentelemetry.android/.*$" - }, - { - "pattern": "^https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/.*$" - } - ] -} \ No newline at end of file diff --git a/.github/scripts/markdown-link-check-with-retry.sh b/.github/scripts/markdown-link-check-with-retry.sh deleted file mode 100755 index 741d4a3d5..000000000 --- a/.github/scripts/markdown-link-check-with-retry.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -e - -# this script helps to reduce sporadic link check failures by retrying at a file-by-file level - -retry_count=3 - -for file in "$@"; do - for i in $(seq 1 $retry_count); do - if markdown-link-check --config "$(dirname "$0")/markdown-link-check-config.json" \ - "$file"; then - break - elif [[ $i -eq $retry_count ]]; then - exit 1 - fi - sleep 5 - done -done \ No newline at end of file diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 402d27895..3122ac07a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -39,7 +39,7 @@ jobs: markdown-link-check: # release branches are excluded to avoid unnecessary maintenance if: ${{ !startsWith(github.ref_name, 'release/') }} - uses: ./.github/workflows/reusable-markdown-link-check.yml + uses: ./.github/workflows/reusable-link-check.yml workflow-notification: permissions: # required by the reusable workflow 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 57311d8ef..000000000 --- a/.github/workflows/reusable-markdown-link-check.yml +++ /dev/null @@ -1,24 +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 - - - name: Install markdown-link-check - # https://github.com/tcort/markdown-link-check/issues/297 - run: npm install -g markdown-link-check@3.11.2 - - - name: Run markdown-link-check - run: | - find . -type f \ - -name '*.md' \ - -not -path './CHANGELOG.md' \ - | xargs .github/scripts/markdown-link-check-with-retry.sh \ No newline at end of file diff --git a/.lychee.toml b/.lychee.toml new file mode 100644 index 000000000..6b4ee4d00 --- /dev/null +++ b/.lychee.toml @@ -0,0 +1,15 @@ +timeout = 30 +retry_wait_time = 5 +max_retries = 6 +max_concurrency = 4 + +# Check link anchors +include_fragments = true + +# excluding links to pull requests and issues is done for performance +exclude = [ + "^http://localhost:16686/$", + '^https://github.com/open-telemetry/opentelemetry-android/(issues|pull)/\d+$', + "^https://maven-badges.sml.io/maven-central/io.opentelemetry.android/.*$", + "^https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/.*$", +] diff --git a/reusable-link-check.yml b/reusable-link-check.yml new file mode 100644 index 000000000..044e85e1f --- /dev/null +++ b/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