diff --git a/.github/lychee.toml b/.github/lychee.toml new file mode 100644 index 000000000000..a228cd084361 --- /dev/null +++ b/.github/lychee.toml @@ -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 diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index f2966c9065ff..50efb4040a6d 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -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 diff --git a/.github/workflows/check-links.yaml b/.github/workflows/check-links.yaml index 69fe83dd18c6..e048c17d1f37 100644 --- a/.github/workflows/check-links.yaml +++ b/.github/workflows/check-links.yaml @@ -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 @@ -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" diff --git a/.github/workflows/check_links_config.json b/.github/workflows/check_links_config.json deleted file mode 100644 index 299206c09254..000000000000 --- a/.github/workflows/check_links_config.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "ignorePatterns": [ - { - "pattern": "http(s)?://\\d+\\.\\d+\\.\\d+\\.\\d+" - }, - { - "pattern": "http(s)?://localhost" - }, - { - "pattern": "http(s)?://example.com" - }, - { - "pattern": "^#" - }, - { - "pattern": "https://blogs\\.oracle\\.com/developers/post/connecting-a-go-application-to-oracle-database" - } - ], - "aliveStatusCodes": [429, 200] -} diff --git a/Makefile.Common b/Makefile.Common index 386dcf760dd7..81b7a0a3ed5a 100644 --- a/Makefile.Common +++ b/Makefile.Common @@ -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. @@ -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)