From 1597b27eaa93a15bd63d0806a9f620462aa50abf Mon Sep 17 00:00:00 2001 From: Trask Stalnaker Date: Tue, 8 Jul 2025 21:19:47 -0700 Subject: [PATCH] More link check improvements --- .github/scripts/.lychee-relative.toml | 7 ---- ...ies.dockerfile => dependencies.Dockerfile} | 0 .github/scripts/link-check.sh | 32 +++++++++---------- .../{.lychee.toml => lychee-config.toml} | 0 .github/workflows/reusable-link-check.yml | 2 +- 5 files changed, 16 insertions(+), 25 deletions(-) delete mode 100644 .github/scripts/.lychee-relative.toml rename .github/scripts/{dependencies.dockerfile => dependencies.Dockerfile} (100%) rename .github/scripts/{.lychee.toml => lychee-config.toml} (100%) diff --git a/.github/scripts/.lychee-relative.toml b/.github/scripts/.lychee-relative.toml deleted file mode 100644 index 03124f675..000000000 --- a/.github/scripts/.lychee-relative.toml +++ /dev/null @@ -1,7 +0,0 @@ -# Check link anchors -include_fragments = true - -# For relative links only, we exclude all external URLs -exclude = [ - "^https?://.*", -] diff --git a/.github/scripts/dependencies.dockerfile b/.github/scripts/dependencies.Dockerfile similarity index 100% rename from .github/scripts/dependencies.dockerfile rename to .github/scripts/dependencies.Dockerfile diff --git a/.github/scripts/link-check.sh b/.github/scripts/link-check.sh index f6d3ec7e7..7e6b6910a 100755 --- a/.github/scripts/link-check.sh +++ b/.github/scripts/link-check.sh @@ -6,21 +6,21 @@ export MSYS_NO_PATHCONV=1 # for Git Bash on Windows SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ROOT_DIR="$SCRIPT_DIR/../.." -DEPENDENCIES_DOCKERFILE="$SCRIPT_DIR/dependencies.dockerfile" +DEPENDENCIES_DOCKERFILE="$SCRIPT_DIR/dependencies.Dockerfile" # Parse command line arguments -RELATIVE_ONLY=false -MODIFIED_FILES="" +LOCAL_LINKS_ONLY=false +TARGET="" while [[ $# -gt 0 ]]; do case $1 in - --relative-only) - RELATIVE_ONLY=true + --local-links-only) + LOCAL_LINKS_ONLY=true shift ;; *) # Treat any other arguments as file paths - MODIFIED_FILES="$MODIFIED_FILES $1" + TARGET="$TARGET $1" shift ;; esac @@ -29,26 +29,24 @@ done # Extract lychee version from dependencies.dockerfile LYCHEE_VERSION=$(grep "FROM lycheeverse/lychee:" "$DEPENDENCIES_DOCKERFILE" | sed 's/.*FROM lycheeverse\/lychee:\([^ ]*\).*/\1/') -# Determine target files/directories and config file -TARGET="." -LYCHEE_CONFIG=".github/scripts/.lychee.toml" - -if [[ "$RELATIVE_ONLY" == "true" ]]; then - LYCHEE_CONFIG=".github/scripts/.lychee-relative.toml" -fi - -if [[ -n "$MODIFIED_FILES" ]]; then - TARGET="$MODIFIED_FILES" +if [[ -z "$TARGET" ]]; then + TARGET="." fi # Build the lychee command with optional GitHub token -CMD="lycheeverse/lychee:$LYCHEE_VERSION --verbose --config $LYCHEE_CONFIG" +CMD="lycheeverse/lychee:$LYCHEE_VERSION --verbose --root-dir /data" # Add GitHub token if available if [[ -n "$GITHUB_TOKEN" ]]; then CMD="$CMD --github-token $GITHUB_TOKEN" fi +if [[ "$LOCAL_LINKS_ONLY" == "true" ]]; then + CMD="$CMD --scheme file --include-fragments" +else + CMD="$CMD --config .github/scripts/lychee-config.toml" +fi + CMD="$CMD $TARGET" # Determine if we should allocate a TTY diff --git a/.github/scripts/.lychee.toml b/.github/scripts/lychee-config.toml similarity index 100% rename from .github/scripts/.lychee.toml rename to .github/scripts/lychee-config.toml diff --git a/.github/workflows/reusable-link-check.yml b/.github/workflows/reusable-link-check.yml index 6e45185c7..961a078f8 100644 --- a/.github/workflows/reusable-link-check.yml +++ b/.github/workflows/reusable-link-check.yml @@ -18,7 +18,7 @@ jobs: if: github.event_name == 'pull_request' env: GITHUB_TOKEN: ${{ github.token }} - run: ./.github/scripts/link-check.sh --relative-only + run: ./.github/scripts/link-check.sh --local-links-only - name: Get modified files if: github.event_name == 'pull_request'