Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] use lychee for checklinks #37100

Merged
merged 2 commits into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/lychee.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include-fragments = true

accept = ["200..=299", "429"]

exclude = [
"^http(s)?://localhost",
"^http(s)?://example.com"
]

# better to be safe and avoid failures
max-retries = 6
16 changes: 6 additions & 10 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,10 @@ jobs:
- name: Render .chloggen changelog entries
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependencies') && !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') && !contains(github.event.pull_request.title, '[chore]')}}
run: make chlog-preview > changelog_preview.md
- name: Install markdown-link-check
- name: Link Checker
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependencies') && !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') && !contains(github.event.pull_request.title, '[chore]')}}
run: npm install -g markdown-link-check@${{ env.MD_LINK_CHECK_VERSION }}
- name: Run markdown-link-check
if: ${{ !contains(github.event.pull_request.labels.*.name, 'dependencies') && !contains(github.event.pull_request.labels.*.name, 'Skip Changelog') && !contains(github.event.pull_request.title, '[chore]')}}
run: |
markdown-link-check \
--verbose \
--config .github/workflows/check_links_config.json \
changelog_preview.md \
|| { echo "Check that anchor links are lowercase"; exit 1; }
id: lychee
uses: lycheeverse/lychee-action@f796c8b7d468feb9b8c0a46da3fac0af6874d374
with:
args: "--verbose --no-progress ./changelog_preview.md --config .github/lychee.toml"
failIfEmpty: false
23 changes: 5 additions & 18 deletions .github/workflows/check-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

env:
# renovate: datasource=github-releases depName=tcort/markdown-link-check
MD_LINK_CHECK_VERSION: "3.12.2"

jobs:
changedfiles:
name: changed files
Expand Down Expand Up @@ -43,18 +39,9 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install markdown-link-check
run: npm install -g markdown-link-check@${{ env.MD_LINK_CHECK_VERSION }}
- name: Run markdown-link-check
run: |
if [ -n "${{ needs.changedfiles.outputs.yaml_files }}" ]; then
md=$(find . -type f -name "*.md")
else
md="${{ needs.changedfiles.outputs.md_files }}"
fi

markdown-link-check \
--verbose \
--config .github/workflows/check_links_config.json \
$md \
|| { echo "Check that anchor links are lowercase"; exit 1; }
- name: Link Checker
id: lychee
uses: lycheeverse/lychee-action@f796c8b7d468feb9b8c0a46da3fac0af6874d374
with:
args: "--verbose --no-progress ${{needs.changedfiles.outputs.md_files}} ${{needs.changedfiles.outputs.yaml_files}} --config .github/lychee.toml"
20 changes: 0 additions & 20 deletions .github/workflows/check_links_config.json

This file was deleted.

14 changes: 11 additions & 3 deletions Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ GOOS=$(shell $(GOCMD) env GOOS)
GOARCH=$(shell $(GOCMD) env GOARCH)
GOTESTARCH?=$(GOARCH)

DOCKERCMD ?= docker

# In order to help reduce toil related to managing tooling for the open telemetry collector
# this section of the makefile looks at only requiring command definitions to be defined
# as part of $(TOOLS_MOD_DIR)/tools.go, following the existing practice.
Expand Down Expand Up @@ -206,9 +208,15 @@ checklicense: $(ADDLICENSE)

.PHONY: checklinks
checklinks:
command -v $(MDLINKCHECK) >/dev/null 2>&1 || { echo >&2 "$(MDLINKCHECK) not installed. Run 'npm install -g markdown-link-check'"; exit 1; }
find . -name \*.md -print0 | xargs -0 -n1 \
$(MDLINKCHECK) -q -c $(SRC_ROOT)/.github/workflows/check_links_config.json || true
command -v $(DOCKERCMD) >/dev/null 2>&1 || { echo >&2 "$(DOCKERCMD) not installed. Install before continuing"; exit 1; }
$(DOCKERCMD) run -w /home/repo --rm \
--mount 'type=bind,source='$(PWD)',target=/home/repo' \
--mount 'type=bind,source='$(SRC_ROOT)/.github/lychee.toml',target=/lychee.toml' \
lycheeverse/lychee \
--config /lychee.toml \
--root-dir /home/repo \
-v \
--no-progress './**/*.md'

.PHONY: fmt
fmt: $(GOFUMPT) $(GOIMPORTS)
Expand Down
Loading