-
Notifications
You must be signed in to change notification settings - Fork 990
Expand file tree
/
Copy pathMakefile
More file actions
123 lines (103 loc) · 3.55 KB
/
Copy pathMakefile
File metadata and controls
123 lines (103 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
PWD := $(shell pwd)
# Detect Python and pip commands
PYTHON := $(shell command -v python3 2>/dev/null || command -v python 2>/dev/null)
PIP := $(shell command -v pip3 2>/dev/null || command -v pip 2>/dev/null)
# Validate Python and pip are available
.PHONY: check-python
check-python:
@if [ -z "$(PYTHON)" ]; then \
echo "Error: Python is not installed. Please install Python (Python 3 recommended)."; \
exit 1; \
fi
@if [ -z "$(PIP)" ]; then \
echo "Error: pip is not installed. Please install pip."; \
exit 1; \
fi
# see https://github.com/open-telemetry/build-tools/releases for semconvgen updates
# Keep links in semantic_conventions/README.md and .vscode/settings.json in sync!
SEMCONVGEN_VERSION=0.17.0
# TODO: add `yamllint` step to `all` after making sure it works on Mac.
.PHONY: all
all: install-tools markdownlint textlint markdown-link-check cspell
# Perform an analysis of language used which includes spell checking and linting.
.PHONY: language-analysis
language-analysis: textlint cspell
.PHONY: cspell
cspell:
@if ! npm ls cspell; then npm install; fi
npx cspell . --no-progress
.PHONY: textlint
textlint:
@if ! npm ls textlint; then npm install; fi
@if [ "$(format)" = "github" ]; then \
npx textlint --format github .; \
else \
npx textlint .; \
fi
.PHONY: textlint-correction
textlint-correction:
@if ! npm ls textlint; then npm install; fi
npx textlint --fix .
.PHONY: markdown-link-check
markdown-link-check:
docker run --rm \
--mount 'type=bind,source=$(PWD),target=/home/repo' \
lycheeverse/lychee:sha-8222559@sha256:6f49010cc46543af3b765f19d5319c0cdd4e8415d7596e1b401d5b4cec29c799 \
--config home/repo/.lychee.toml \
--root-dir /home/repo \
--include-fragments \
-v \
home/repo
# check that all links to opentelemetry.io are canonical (no redirects)
# see https://github.com/open-telemetry/opentelemetry-specification/pull/4554
docker run --rm \
--mount 'type=bind,source=$(PWD),target=/home/repo' \
lycheeverse/lychee:sha-8222559@sha256:6f49010cc46543af3b765f19d5319c0cdd4e8415d7596e1b401d5b4cec29c799 \
--config home/repo/.lychee.toml \
--root-dir /home/repo \
--max-redirects 0 \
--include '^https://opentelemetry.io/.*' \
--exclude '' \
-v \
home/repo
.PHONY: markdown-toc
markdown-toc:
@if ! npm ls doctoc; then npm ci; fi
npx --no -- doctoc . --update-only --mintocitems 1 --toc-pragma-style compact --notitle --entryprefix='-,*,+' || exit 1;
.PHONY: markdown-toc-check
markdown-toc-check:
@if ! npm ls doctoc; then npm ci; fi
npx --no -- doctoc . --update-only --mintocitems 1 --toc-pragma-style compact --notitle --entryprefix='-,*,+' --dryrun || exit 1;
.PHONY: markdownlint
markdownlint:
@if ! npm ls markdownlint; then npm install; fi
@for f in $(ALL_DOCS); do \
echo $$f; \
npx --no -p markdownlint-cli markdownlint -c .markdownlint.yaml $$f \
|| exit 1; \
done
.PHONY: install-yamllint
install-yamllint: check-python
# Using a venv is recommended
$(PIP) install -U yamllint~=1.26.1
.PHONY: yamllint
yamllint:
yamllint .
# Run all checks in order of speed / likely failure.
.PHONY: check
check: cspell textlint markdownlint markdown-link-check
@echo "All checks complete"
# Attempt to fix issues / regenerate tables.
.PHONY: fix
fix: textlint-correction
@echo "All autofixes complete"
# Generate spec compliance matrix from YAML source
.PHONY: compliance-matrix
compliance-matrix: check-python
$(PIP) install -U PyYAML
$(PYTHON) .github/scripts/compliance_matrix.py
@echo "Compliance matrix generation complete"
.PHONY: install-tools
install-tools:
npm install
@echo "All tools installed"