-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
195 lines (170 loc) · 5.43 KB
/
Makefile
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
PROJECT=docs
COMPANY=giantswarm
REGISTRY=gsoci.azurecr.io
SHELL=bash
MARKDOWNLINT_IMAGE=ghcr.io/igorshubovych/markdownlint-cli:v0.35.0@sha256:22cf4699a448a7bbc311a940e0600019423d7671cbedae9c35cd32b51f560350
VALE_IMAGE=gsoci.azurecr.io/giantswarm/vale:v3.4.0@sha256:fe9c173ef6dcd782cefa53cad69d1684bc317b12188b03299b0d29aecf265a59
APPLICATION=docs-app
RUNNING_IN_CI ?= false
include Makefile.*.mk
default: docker-build
# Export CSV on article metadata
export-csv:
docker run --rm \
--volume=${PWD}:/workdir \
-w /workdir \
$(REGISTRY)/$(COMPANY)/docs-scriptrunner:latest \
/workdir/scripts/export-csv/script.py
# Aggregate changelog entries from various repositories into our Changes section.
changes:
@if [ -z "${GITHUB_TOKEN}" ]; then echo "Please set the GITHUB_TOKEN environment variable"; exit 1; fi
docker run --rm \
--volume=${PWD}/scripts/aggregate-changelogs:/workdir:ro \
--volume=${PWD}/src/content/changes:/output:rw \
--volume=${PWD}/src/data:/data:rw \
-w /workdir \
--env GITHUB_TOKEN \
$(REGISTRY)/$(COMPANY)/docs-scriptrunner:latest \
/workdir/script.py /workdir/config.yaml /output /data
changes-test:
docker run --rm \
--volume=${PWD}/scripts/aggregate-changelogs:/workdir:ro \
-w /workdir \
$(REGISTRY)/$(COMPANY)/docs-scriptrunner:latest \
/workdir/test_script.py foo bar baz
collect-changelog-entries:
docker run --rm \
--volume=${PWD}:/workdir \
-w /workdir \
-e GITHUB_TOKEN \
$(REGISTRY)/$(COMPANY)/docs-scriptrunner:latest \
/workdir/scripts/collect-changelog-entries/script.py
# Generate the reference documentation for the cluster apps.
update-cluster-app-reference:
scripts/update-helm-chart-reference/main.sh
# Generate the reference documentation for the custom resource
# definitions (CRD) used in the Management API.
update-crd-reference:
scripts/update-crd-reference/main.sh
lint: lint-markdown lint-prose validate-front-matter
lint-markdown:
@echo "Pulling image $(MARKDOWNLINT_IMAGE)"
@docker pull --quiet $(MARKDOWNLINT_IMAGE) > /dev/null
@echo "Running markdownlint"
@docker run \
--rm \
-v ${PWD}:/workdir \
-w /workdir \
$(MARKDOWNLINT_IMAGE) \
--config .markdownlint.yaml \
--ignore README.md \
--ignore ./src/content/changes \
--ignore ./src/content/vintage/use-the-api/management-api/crd \
--ignore ./src/content/reference/platform-api/crd \
$$(if [ "$(RUNNING_IN_CI)" = "true" ]; then echo "--output markdownlint.out"; fi) \
./src
lint-prose:
@echo "Pulling image $(VALE_IMAGE)"
@docker pull --quiet $(VALE_IMAGE) > /dev/null
@echo "Running vale"
@docker run \
--rm \
-v ${PWD}:/workdir \
-w /workdir \
$(VALE_IMAGE) \
--config=/workdir/.vale.ini \
--no-wrap \
src/content
# Update vale packages in the .vale/styles directory
lint-prose-update:
@echo "Pulling image $(VALE_IMAGE)"
@docker pull --quiet $(VALE_IMAGE) > /dev/null
@echo "Running vale sync"
@docker run \
--rm \
-v ${PWD}:/workdir \
-w /workdir \
$(VALE_IMAGE) \
--config=/workdir/.vale.ini \
sync
# Validate front matter in all pages.
validate-front-matter:
docker run --rm \
--volume=${PWD}:/workdir:ro \
-w /workdir \
$(REGISTRY)/$(COMPANY)/docs-scriptrunner:latest \
/workdir/scripts/validate-front-matter/script.py
# Validate front matter for last-reviewed date.
validate-last-reviewed:
docker run --rm \
--volume=${PWD}:/workdir:ro \
-w /workdir \
$(REGISTRY)/$(COMPANY)/docs-scriptrunner:latest \
/workdir/scripts/validate-front-matter/script.py \
--validation last-reviewed \
--output json
# Print a report of pages with a last_review_date that's
# too long ago.
validate-last-reviewed:
docker run --rm \
--volume=${PWD}:/workdir:ro \
-w /workdir \
$(REGISTRY)/$(COMPANY)/docs-scriptrunner:latest \
/workdir/scripts/validate-front-matter/script.py --validation last-reviewed
docker-build:
docker build -t $(REGISTRY)/$(COMPANY)/$(PROJECT):latest .
docker-run:
docker run --rm -ti -p 8080:8080 $(REGISTRY)/$(COMPANY)/$(PROJECT):latest
dev:
hugo server \
--source ./src \
--ignoreCache \
--disableFastRender \
--cleanDestinationDir \
--gc \
--noBuildLock \
--noHTTPCache \
--renderToMemory
clean:
rm -rf build
rm -rf vendor
rm -rf .sass-cache
# Verify internal links
linkcheck-internal:
@echo "Checking internal links only\n"
docker run -d --rm --name server -p 8080:8080 -P $(REGISTRY)/$(COMPANY)/$(PROJECT):latest
sleep 2
# We ignore https://docs.giantswarm.io/.* because otherwise we could never add new pages,
# as checks for the "canonical" link would fail.
docker run --rm -ti --name linkchecker \
--link server:server \
linkchecker/linkchecker \
http://server:8080 \
-t 5 \
--no-status \
--ignore-url="^https://docs\.giantswarm\.io/.*" \
--ignore-url=/api/
docker kill server
docker kill linkchecker
update-website-content:
cd ./scripts/update-website-content && \
npm ci && \
npm start
# Verify internal and external links
# based on the currently deployed docs website.
linkcheck:
@echo "Checking all links\n"
docker run --rm -ti --name linkchecker \
-v ${PWD}/volumes/linkchecker:/workdir:rw \
-w /workdir \
ghcr.io/linkchecker/linkchecker \
https://docs.giantswarm.io \
-t 1 \
--file-output csv/linkcheck.csv \
--check-extern \
--verbose \
--ignore-url=/api/ \
--ignore-url="^https://.+.example.com/.*" \
--ignore-url=".*gigantic\.io.*" \
--ignore-url="^https://my-org\.github\.com/.*" \
--ignore-url="^https://github\.com/giantswarm/giantswarm/.*"