Skip to content

Commit

Permalink
[chore] update link checker to use lychee (#12041)
Browse files Browse the repository at this point in the history
This was done in the [specification
repo](open-telemetry/opentelemetry-specification@6c626de),
and allows us to use a github action instead of install npm packages as
part of the build process (which kept bringing security warnings back)

Signed-off-by: Alex Boten <[email protected]>
  • Loading branch information
codeboten authored Jan 8, 2025
1 parent 7993ef0 commit 70fc33e
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 53 deletions.
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
18 changes: 5 additions & 13 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ concurrency:

permissions: read-all

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

jobs:
changelog:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -81,12 +77,8 @@ jobs:
# In order to validate any links in the yaml file, render the config to markdown
- name: Render .chloggen changelog entries
run: make chlog-preview > changelog_preview.md
- name: Install markdown-link-check
run: npm install -g markdown-link-check@${{ env.MD_LINK_CHECK_VERSION }}
- name: Run markdown-link-check
run: |
npx --no -- markdown-link-check \
--verbose \
--config .github/workflows/check_links_config.json \
changelog_preview.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 ./changelog_preview.md --config .github/lychee.toml"
15 changes: 5 additions & 10 deletions .github/workflows/check-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,8 @@ jobs:
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: |
npx --no -- markdown-link-check \
--verbose \
--config .github/workflows/check_links_config.json \
${{needs.changedfiles.outputs.files}} \
|| { 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.files}} --config .github/lychee.toml"
25 changes: 0 additions & 25 deletions .github/workflows/check_links_config.json

This file was deleted.

14 changes: 10 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,9 @@ PROTO_PACKAGE=go.opentelemetry.io/collector/$(PROTO_TARGET_GEN_DIR)
# Intermediate directory used during generation.
PROTO_INTERMEDIATE_DIR=pdata/internal/.patched-otlp-proto

DOCKERCMD ?= docker
DOCKER_PROTOBUF ?= otel/build-protobuf:0.23.0
PROTOC := docker run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD}/$(PROTO_INTERMEDIATE_DIR) ${DOCKER_PROTOBUF} --proto_path=${PWD}
PROTOC := $(DOCKERCMD) run --rm -u ${shell id -u} -v${PWD}:${PWD} -w${PWD}/$(PROTO_INTERMEDIATE_DIR) ${DOCKER_PROTOBUF} --proto_path=${PWD}
PROTO_INCLUDES := -I/usr/include/github.com/gogo/protobuf -I./

# Cleanup temporary directory
Expand Down Expand Up @@ -402,9 +403,14 @@ clean:

.PHONY: checklinks
checklinks:
command -v markdown-link-check >/dev/null 2>&1 || { echo >&2 "markdown-link-check not installed. Run 'npm install -g markdown-link-check'"; exit 1; }
find . -name \*.md -print0 | xargs -0 -n1 \
markdown-link-check -q -c ./.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' \
lycheeverse/lychee \
--config .github/lychee.toml \
--root-dir /home/repo \
-v \
--no-progress './**/*.md'

# error message "failed to sync logger: sync /dev/stderr: inappropriate ioctl for device"
# is a known issue but does not affect function.
Expand Down
2 changes: 1 addition & 1 deletion docs/rfcs/env-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ expect the string to be `0123`).

The Configuration WG defines an [*environment variable expansion feature
for SDK
configurations*](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/file-configuration.md#environment-variable-substitution).
configurations*](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/configuration/data-model.md#environment-variable-substitution).
This accepts only non empty alphanumeric + underscore identifiers
starting with alphabetic or underscore. If the Configuration WG were to
expand this in the future (e.g. to include other features present in
Expand Down

0 comments on commit 70fc33e

Please sign in to comment.