From bae4344edeecc2ee07068148c7937b2c87682be8 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Mon, 26 Jan 2026 13:16:54 +0100 Subject: [PATCH 1/6] lint only changed text files Signed-off-by: Gregor Zeitlinger --- .github/config/lychee.toml | 34 ++++++++++++++++++++ .github/workflows/lint-rest.yml | 21 ++++++++++--- .mise/tasks/lint/links-in-modified-files.sh | 35 +++++++++++++++++++++ .mise/tasks/lint/links.sh | 12 +++++++ .mise/tasks/lint/local-links.sh | 12 +++++++ lychee.toml | 15 --------- mise.toml | 4 --- 7 files changed, 110 insertions(+), 23 deletions(-) create mode 100644 .github/config/lychee.toml create mode 100755 .mise/tasks/lint/links-in-modified-files.sh create mode 100755 .mise/tasks/lint/links.sh create mode 100755 .mise/tasks/lint/local-links.sh delete mode 100644 lychee.toml diff --git a/.github/config/lychee.toml b/.github/config/lychee.toml new file mode 100644 index 000000000..399643fc8 --- /dev/null +++ b/.github/config/lychee.toml @@ -0,0 +1,34 @@ +# Lychee configuration file +# See https://lychee.cli.rs/config/ + +timeout = 30 +retry_wait_time = 5 +max_retries = 6 +max_concurrency = 4 + +# Check link anchors +include_fragments = true + +remap = [ + # workaround for https://github.com/lycheeverse/lychee/issues/1729 + "https://github.com/(.*?)/(.*?)/blob/(.*?)/(.*#.*)$ https://raw.githubusercontent.com/$1/$2/$3/$4" +] + +exclude = [ + # excluding links to pull requests and issues is done for performance + "^https://github.com/prometheus/client_java/(issues|pull)/\\d+$", + + # exclude localhost URLs as they require running services + "^http://localhost", + "^https://localhost", + + # exclude root-relative URLs that are for the built site + "^/client_java/", + + # exclude Hugo template variables + "\\{\\{", + "%7B%7B", + + # exclude private GitHub settings pages + "^https://github.com/prometheus/client_java/settings/", +] diff --git a/.github/workflows/lint-rest.yml b/.github/workflows/lint-rest.yml index efce5cfa5..8a81a8bbd 100644 --- a/.github/workflows/lint-rest.yml +++ b/.github/workflows/lint-rest.yml @@ -1,9 +1,14 @@ --- name: Lint What Super Linter Can't -on: [pull_request] +on: + pull_request: + push: + branches: + - main -permissions: {} +permissions: + contents: read jobs: lint: @@ -12,10 +17,18 @@ jobs: - name: Check out with: persist-credentials: false + fetch-depth: 0 # needed for merge-base used in lint:links-in-modified-files uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 - uses: jdx/mise-action@6d1e696aa24c1aa1bcc1adea0212707c71ab78a8 # v3.6.1 with: version: v2026.1.7 sha256: d98523f15392ab17909a55560244667aa81122766209b816d9a9b9585109bfea - - name: Lint - run: mise run lint:rest + + - name: Lint for pull requests + if: github.event_name == 'pull_request' + env: + GITHUB_TOKEN: ${{ github.token }} + run: | + mise run lint:bom + mise run lint:local-links + mise run lint:links-in-modified-files --base origin/${{ github.base_ref }} --head ${{ github.event.pull_request.head.sha }} diff --git a/.mise/tasks/lint/links-in-modified-files.sh b/.mise/tasks/lint/links-in-modified-files.sh new file mode 100755 index 000000000..e96c05da4 --- /dev/null +++ b/.mise/tasks/lint/links-in-modified-files.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +#MISE description="Lint links in modified files" + +set -e + +#USAGE flag "--base " help="base branch to compare against (default: origin/main)" default="origin/main" +#USAGE flag "--head " help="head branch to compare against (empty for local changes) (default: empty)" default="" + +if [ "$usage_head" = "''" ]; then + usage_head="" +fi + +# Check if lychee config was modified +# - because usage_head may be empty +config_modified=$(git diff --name-only --merge-base "$usage_base" $usage_head \ + | grep -E '^(\.github/config/lychee\.toml|\.mise/tasks/lint/.*|mise\.toml)$' || true) + +if [ -n "$config_modified" ] ; then + echo "config changes, checking all files." + mise run lint:links +else + # Using lychee's default extension filter here to match when it runs against all files + # Note: --diff-filter=d filters out deleted files + # - because usage_head may be empty + modified_files=$(git diff --name-only --diff-filter=d "$usage_base" $usage_head \ + | grep -E '\.(md|mkd|mdx|mdown|mdwn|mkdn|mkdown|markdown|html|htm|txt)$' \ + | tr '\n' ' ' || true) + + if [ -z "$modified_files" ]; then + echo "No modified files, skipping link linting." + exit 0 + fi + + mise run lint:links $modified_files +fi diff --git a/.mise/tasks/lint/links.sh b/.mise/tasks/lint/links.sh new file mode 100755 index 000000000..5f22566ad --- /dev/null +++ b/.mise/tasks/lint/links.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +#MISE description="Lint links in all files" + +set -e + +#USAGE arg "" var=#true help="files to check" default="." + +for f in $usage_file; do + echo "Checking links in file: $f" +done + +lychee --verbose --config .github/config/lychee.toml $usage_file diff --git a/.mise/tasks/lint/local-links.sh b/.mise/tasks/lint/local-links.sh new file mode 100755 index 000000000..328576105 --- /dev/null +++ b/.mise/tasks/lint/local-links.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +#MISE description="Lint links in local files" + +set -e + +#USAGE arg "" var=#true help="files to check" default="." + +for f in $usage_file; do + echo "Checking links in file: $f" +done + +lychee --verbose --scheme file --include-fragments --config .github/config/lychee.toml $usage_file diff --git a/lychee.toml b/lychee.toml deleted file mode 100644 index d67acf825..000000000 --- a/lychee.toml +++ /dev/null @@ -1,15 +0,0 @@ -max_retries = 6 -exclude_loopback = true -cache = true - -base_url = "https://prometheus.github.io" -exclude_path = ["docs/themes"] -exclude = [ - '^https://github\.com/prometheus/client_java/settings', - '#', - 'CONTRIBUTING.md', - 'LICENSE', - 'MAINTAINERS.md' -] - - diff --git a/mise.toml b/mise.toml index 9e0118e33..cf6cfe694 100644 --- a/mise.toml +++ b/mise.toml @@ -43,10 +43,6 @@ run = "./mvnw verify" description = "build all modules without tests" run = "./mvnw install -DskipTests -Dcoverage.skip=true" -[tasks."lint:links"] -description = "Lint markdown links" -run = "lychee --include-fragments ." - [tasks."lint:rest"] description = "All lints not covered by super linter" depends = ["lint:links", "lint:bom"] From 0c17a600e18b16c674b98873f54d77b4c92b2f12 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Mon, 26 Jan 2026 13:21:38 +0100 Subject: [PATCH 2/6] lint only changed text files Signed-off-by: Gregor Zeitlinger --- .mise/tasks/lint/links-in-modified-files.sh | 34 ++++++++++----------- .mise/tasks/lint/links.sh | 2 +- .mise/tasks/lint/local-links.sh | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.mise/tasks/lint/links-in-modified-files.sh b/.mise/tasks/lint/links-in-modified-files.sh index e96c05da4..17382254f 100755 --- a/.mise/tasks/lint/links-in-modified-files.sh +++ b/.mise/tasks/lint/links-in-modified-files.sh @@ -7,29 +7,29 @@ set -e #USAGE flag "--head " help="head branch to compare against (empty for local changes) (default: empty)" default="" if [ "$usage_head" = "''" ]; then - usage_head="" + usage_head="" fi # Check if lychee config was modified # - because usage_head may be empty -config_modified=$(git diff --name-only --merge-base "$usage_base" $usage_head \ - | grep -E '^(\.github/config/lychee\.toml|\.mise/tasks/lint/.*|mise\.toml)$' || true) +config_modified=$(git diff --name-only --merge-base "$usage_base" $usage_head | + grep -E '^(\.github/config/lychee\.toml|\.mise/tasks/lint/.*|mise\.toml)$' || true) -if [ -n "$config_modified" ] ; then - echo "config changes, checking all files." - mise run lint:links +if [ -n "$config_modified" ]; then + echo "config changes, checking all files." + mise run lint:links else - # Using lychee's default extension filter here to match when it runs against all files - # Note: --diff-filter=d filters out deleted files - # - because usage_head may be empty - modified_files=$(git diff --name-only --diff-filter=d "$usage_base" $usage_head \ - | grep -E '\.(md|mkd|mdx|mdown|mdwn|mkdn|mkdown|markdown|html|htm|txt)$' \ - | tr '\n' ' ' || true) + # Using lychee's default extension filter here to match when it runs against all files + # Note: --diff-filter=d filters out deleted files + # - because usage_head may be empty + modified_files=$(git diff --name-only --diff-filter=d "$usage_base" $usage_head | + grep -E '\.(md|mkd|mdx|mdown|mdwn|mkdn|mkdown|markdown|html|htm|txt)$' | + tr '\n' ' ' || true) - if [ -z "$modified_files" ]; then - echo "No modified files, skipping link linting." - exit 0 - fi + if [ -z "$modified_files" ]; then + echo "No modified files, skipping link linting." + exit 0 + fi - mise run lint:links $modified_files + mise run lint:links $modified_files fi diff --git a/.mise/tasks/lint/links.sh b/.mise/tasks/lint/links.sh index 5f22566ad..d916c5d96 100755 --- a/.mise/tasks/lint/links.sh +++ b/.mise/tasks/lint/links.sh @@ -6,7 +6,7 @@ set -e #USAGE arg "" var=#true help="files to check" default="." for f in $usage_file; do - echo "Checking links in file: $f" + echo "Checking links in file: $f" done lychee --verbose --config .github/config/lychee.toml $usage_file diff --git a/.mise/tasks/lint/local-links.sh b/.mise/tasks/lint/local-links.sh index 328576105..7391f6f60 100755 --- a/.mise/tasks/lint/local-links.sh +++ b/.mise/tasks/lint/local-links.sh @@ -6,7 +6,7 @@ set -e #USAGE arg "" var=#true help="files to check" default="." for f in $usage_file; do - echo "Checking links in file: $f" + echo "Checking links in file: $f" done lychee --verbose --scheme file --include-fragments --config .github/config/lychee.toml $usage_file From 722ed13e3ad588aa66bb355fec3c2a392c7abea7 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Mon, 26 Jan 2026 13:23:48 +0100 Subject: [PATCH 3/6] lint only changed text files Signed-off-by: Gregor Zeitlinger --- .editorconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 6aed0058b..355cca83e 100644 --- a/.editorconfig +++ b/.editorconfig @@ -18,5 +18,5 @@ max_line_length = 120 indent_size = 4 max_line_length = 120 -[{.mise/tasks/build-release.sh,.mise/tasks/lint/super-linter.sh,.github/workflows/multi-version-test.yml}] -max_line_length = 200 \ No newline at end of file +[{.mise/tasks/build-release.sh,.mise/tasks/lint/super-linter.sh,.mise/tasks/lint/links-in-modified-files.sh,.github/workflows/multi-version-test.yml,.github/workflows/lint-rest.yml}] +max_line_length = 200 From defbb1c61c0bdbd0b9c0f08fe008d2e45bd3645e Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Mon, 26 Jan 2026 13:54:13 +0100 Subject: [PATCH 4/6] lint only changed text files Signed-off-by: Gregor Zeitlinger --- .mise/tasks/lint/links-in-modified-files.sh | 4 ++++ .mise/tasks/lint/links.sh | 2 ++ .mise/tasks/lint/local-links.sh | 2 ++ 3 files changed, 8 insertions(+) diff --git a/.mise/tasks/lint/links-in-modified-files.sh b/.mise/tasks/lint/links-in-modified-files.sh index 17382254f..3b39a133d 100755 --- a/.mise/tasks/lint/links-in-modified-files.sh +++ b/.mise/tasks/lint/links-in-modified-files.sh @@ -6,12 +6,14 @@ set -e #USAGE flag "--base " help="base branch to compare against (default: origin/main)" default="origin/main" #USAGE flag "--head " help="head branch to compare against (empty for local changes) (default: empty)" default="" +# shellcheck disable=SC2154 if [ "$usage_head" = "''" ]; then usage_head="" fi # Check if lychee config was modified # - because usage_head may be empty +# shellcheck disable=SC2086,SC2154 config_modified=$(git diff --name-only --merge-base "$usage_base" $usage_head | grep -E '^(\.github/config/lychee\.toml|\.mise/tasks/lint/.*|mise\.toml)$' || true) @@ -22,6 +24,7 @@ else # Using lychee's default extension filter here to match when it runs against all files # Note: --diff-filter=d filters out deleted files # - because usage_head may be empty + # shellcheck disable=SC2086 modified_files=$(git diff --name-only --diff-filter=d "$usage_base" $usage_head | grep -E '\.(md|mkd|mdx|mdown|mdwn|mkdn|mkdown|markdown|html|htm|txt)$' | tr '\n' ' ' || true) @@ -31,5 +34,6 @@ else exit 0 fi + # shellcheck disable=SC2086 mise run lint:links $modified_files fi diff --git a/.mise/tasks/lint/links.sh b/.mise/tasks/lint/links.sh index d916c5d96..19df7f20d 100755 --- a/.mise/tasks/lint/links.sh +++ b/.mise/tasks/lint/links.sh @@ -5,8 +5,10 @@ set -e #USAGE arg "" var=#true help="files to check" default="." +# shellcheck disable=SC2154 for f in $usage_file; do echo "Checking links in file: $f" done +# shellcheck disable=SC2086 lychee --verbose --config .github/config/lychee.toml $usage_file diff --git a/.mise/tasks/lint/local-links.sh b/.mise/tasks/lint/local-links.sh index 7391f6f60..054bb4ab4 100755 --- a/.mise/tasks/lint/local-links.sh +++ b/.mise/tasks/lint/local-links.sh @@ -5,8 +5,10 @@ set -e #USAGE arg "" var=#true help="files to check" default="." +# shellcheck disable=SC2154 for f in $usage_file; do echo "Checking links in file: $f" done +# shellcheck disable=SC2086 lychee --verbose --scheme file --include-fragments --config .github/config/lychee.toml $usage_file From e7942086f8d6183c92f2fb1688c0f55147bbb717 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Mon, 26 Jan 2026 14:08:37 +0100 Subject: [PATCH 5/6] lint only changed text files Signed-off-by: Gregor Zeitlinger --- .github/workflows/lint-rest.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint-rest.yml b/.github/workflows/lint-rest.yml index 8a81a8bbd..a1649a905 100644 --- a/.github/workflows/lint-rest.yml +++ b/.github/workflows/lint-rest.yml @@ -28,7 +28,9 @@ jobs: if: github.event_name == 'pull_request' env: GITHUB_TOKEN: ${{ github.token }} + GITHUB_BASE_REF: ${{ github.base_ref }} + GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha }} run: | mise run lint:bom mise run lint:local-links - mise run lint:links-in-modified-files --base origin/${{ github.base_ref }} --head ${{ github.event.pull_request.head.sha }} + mise run lint:links-in-modified-files --base origin/"${GITHUB_BASE_REF}" --head "${GITHUB_HEAD_SHA}" From a0523423ec1498954a2d0a5bb824e2eecb299100 Mon Sep 17 00:00:00 2001 From: Gregor Zeitlinger Date: Mon, 26 Jan 2026 18:43:43 +0100 Subject: [PATCH 6/6] lint only changed text files Signed-off-by: Gregor Zeitlinger --- .github/config/lychee.toml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/config/lychee.toml b/.github/config/lychee.toml index 399643fc8..9ba423471 100644 --- a/.github/config/lychee.toml +++ b/.github/config/lychee.toml @@ -9,6 +9,9 @@ max_concurrency = 4 # Check link anchors include_fragments = true +base_url = "https://prometheus.github.io" +exclude_path = ["docs/themes"] + remap = [ # workaround for https://github.com/lycheeverse/lychee/issues/1729 "https://github.com/(.*?)/(.*?)/blob/(.*?)/(.*#.*)$ https://raw.githubusercontent.com/$1/$2/$3/$4" @@ -22,12 +25,10 @@ exclude = [ "^http://localhost", "^https://localhost", - # exclude root-relative URLs that are for the built site - "^/client_java/", - - # exclude Hugo template variables - "\\{\\{", - "%7B%7B", + '#', + 'CONTRIBUTING.md', + 'LICENSE', + 'MAINTAINERS.md', # exclude private GitHub settings pages "^https://github.com/prometheus/client_java/settings/",