Skip to content

Commit 96bc9a7

Browse files
chalinlmolkova
andauthored
[CI] Report non-normalized link from docs into docs (#1844)
Co-authored-by: Liudmila Molkova <limolkova@microsoft.com>
1 parent 5598427 commit 96bc9a7

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Makefile

+17-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@ PWD := $(shell pwd)
55
# Determine OS & Arch for specific OS only tools on Unix based systems
66
OS := $(shell uname | tr '[:upper:]' '[:lower:]')
77
ifeq ($(OS),darwin)
8-
SED := gsed
8+
SED ?= gsed
99
else
10-
SED := sed
10+
SED ?= sed
1111
endif
1212

1313
TOOLS_DIR := $(PWD)/internal/tools
1414

15+
MARKDOWN_LINK_CHECK_ARG= # pass extra arguments such as --exclude '^http'
1516
MISSPELL_BINARY=bin/misspell
1617
MISSPELL = $(TOOLS_DIR)/$(MISSPELL_BINARY)
1718

@@ -66,14 +67,27 @@ misspell: $(MISSPELL)
6667
misspell-correction: $(MISSPELL)
6768
$(MISSPELL) -w $(ALL_DOCS)
6869

70+
.PHONY: normalized-link-check
71+
# NOTE: we check `model/[a-z]*` to avoid `model/README.md`, which contains
72+
# valid occurrences of `../docs/`.
73+
normalized-link-check:
74+
@if grep -R '\.\./docs/' docs model/[a-z]*; then \
75+
echo "\nERROR: Found occurrences of '../docs/'; see above."; \
76+
echo " Remove the '../docs/' from doc page links referencing doc pages."; \
77+
exit 1; \
78+
else \
79+
echo "Normalized-link check passed."; \
80+
fi
81+
6982
.PHONY: markdown-link-check
70-
markdown-link-check:
83+
markdown-link-check: normalized-link-check
7184
docker run --rm \
7285
--mount 'type=bind,source=$(PWD),target=/home/repo' \
7386
lycheeverse/lychee \
7487
--config home/repo/.lychee.toml \
7588
--root-dir /home/repo \
7689
--verbose \
90+
$(MARKDOWN_LINK_CHECK_ARG) \
7791
home/repo
7892

7993
.PHONY: markdown-link-check-changelog-preview

0 commit comments

Comments
 (0)