-
Notifications
You must be signed in to change notification settings - Fork 323
Expand file tree
/
Copy pathlefthook.yml
More file actions
280 lines (276 loc) · 10.5 KB
/
lefthook.yml
File metadata and controls
280 lines (276 loc) · 10.5 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
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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
# Refer for explanation to following link:
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
#
pre-commit:
parallel: true
commands:
deprecated-markdown-patterns:
tags: lint
glob: "content/**/*.md"
run: |
errors=0
# Check for deprecated code-placeholders shortcode
if grep -l '{{% code-placeholders' {staged_files} 2>/dev/null; then
echo "❌ Found deprecated {{% code-placeholders %}} shortcode."
echo " Use \`\`\`language { placeholders=\"...\" } instead."
errors=1
fi
# Check for abbreviated 'py' language identifier
if grep -lE '^\s*```py(\s|$)' {staged_files} 2>/dev/null; then
echo "❌ Found abbreviated 'py' code fence language."
echo " Use 'python' instead of 'py' for code fences."
errors=1
fi
exit $errors
fail_text: "Deprecated markdown patterns found. See messages above for details."
check-support-links:
tags: lint
glob: "content/**/*.md"
run: .ci/scripts/check-support-links.sh {staged_files}
check-source-paths:
tags: lint
glob: "content/**/*.md"
run: .ci/scripts/check-source-paths.sh {staged_files}
fail_text: "source: values must start with /shared/ (see DOCS-CONTRIBUTING.md § Shared Content)"
check-render-hook-whitespace:
tags: lint
glob: "layouts/_default/_markup/render-*.html"
run: .ci/scripts/check-render-hook-whitespace.sh {staged_files}
fail_text: "Render hook has bare {{ ... }} action(s). Use {{- ... -}} trimming to prevent whitespace leaks (see influxdata/docs-v2#7079)."
check-feedback-links:
tags: lint
glob:
- "data/products.yml"
- "layouts/partials/article/feedback.html"
run: node .ci/scripts/check-feedback-links.js
fail_text: "Feedback button check failed (see influxdata/docs-v2#7089). Every product with content_path needs product_issue_url in data/products.yml, and the template must not hardcode product URLs. CI also runs Layer 2 (rendered HTML grep)."
eslint-debug-check:
glob: "assets/js/*.js"
run: yarn eslint {staged_files}
fail_text: "Debug helpers found! Remove debug imports and calls before committing."
build-agent-instructions:
glob: "data/products.yml"
run: yarn build:agent:instructions
# Auto-fix markdown formatting for instruction and README files (like prettier)
lint-markdown-instructions:
tags: lint
glob:
- "README.md"
- "[A-Z]*.md"
- ".github/**/*.md"
- ".claude/**/*.md"
run: |
# Filter out content and layout files (shortcode .md files contain Hugo template syntax
# that remark-lint would escape), then prepend /workdir/ to each remaining file
files=$(echo '{staged_files}' | tr ' ' '\n' | grep -v '^content/' | grep -v '^layouts/' | sed 's|^|/workdir/|' | tr '\n' ' ' | sed 's/ $//')
if [ -n "$files" ]; then
docker compose run --rm --name remark-lint remark-lint $files --output --quiet || \
{ echo "⚠️ Remark found formatting issues in instruction files. Automatic formatting applied."; }
fi
stage_fixed: true
# Lint instruction and repository documentation files with generic Vale config
lint-instructions:
tags: lint
glob: "{[A-Z]*.md,.github/**/*.md,.claude/**/*.md,api-docs/README.md}"
run: '.ci/vale/vale.sh
--config=.vale-instructions.ini
--minAlertLevel=warning {staged_files}'
cloud-lint:
tags: lint,v2
glob: 'content/influxdb/cloud/*.md'
run: '.ci/vale/vale.sh
--config=.vale.ini
--minAlertLevel=error {staged_files}'
cloud-dedicated-lint:
tags: lint,v3
glob:
- 'content/influxdb3/cloud-dedicated/*.md'
- 'content/shared/*.md'
run: '.ci/vale/vale.sh
--config=content/influxdb3/cloud-dedicated/.vale.ini
--minAlertLevel=error {staged_files}'
cloud-serverless-lint:
tags: lint,v3
glob:
- 'content/influxdb3/cloud-serverless/*.md'
- 'content/shared/*.md'
run: '.ci/vale/vale.sh
--config=content/influxdb3/cloud-serverless/.vale.ini
--minAlertLevel=error {staged_files}'
clustered-lint:
tags: lint,v3
glob:
- 'content/influxdb3/clustered/*.md'
- 'content/shared/*.md'
run: '.ci/vale/vale.sh
--config=content/influxdb3/cloud-serverless/.vale.ini
--minAlertLevel=error {staged_files}'
core-lint:
tags: lint,v3
glob:
- 'content/influxdb3/core/*.md'
- 'content/shared/*.md'
run: '.ci/vale/vale.sh
--config=.vale.ini
--minAlertLevel=error {staged_files}'
enterprise-lint:
tags: lint,v3
glob:
- 'content/influxdb3/enterprise/*.md'
- 'content/shared/*.md'
run: '.ci/vale/vale.sh
--config=.vale.ini
--minAlertLevel=error {staged_files}'
explorer-lint:
tags: lint,clients
glob: 'content/influxdb3/explorer/*.md'
run: '.ci/vale/vale.sh
--config=.vale.ini
--minAlertLevel=error {staged_files}'
telegraf-lint:
tags: lint,clients
glob: 'content/telegraf/*.md'
run: '.ci/vale/vale.sh
--config=.vale.ini
--minAlertLevel=error {staged_files}'
v2-lint:
tags: lint,v2
glob: 'content/influxdb/v2/*.md'
run: '.ci/vale/vale.sh
--config=content/influxdb/v2/.vale.ini
--minAlertLevel=error {staged_files}'
build-typescript:
glob: "assets/js/*.ts"
run: yarn build:ts
stage_fixed: true
build-api-docs-scripts:
glob: "api-docs/scripts/**/*.ts"
run: yarn build:api-docs:scripts
prettier:
tags: [frontend, style]
glob: '*.{css,js,ts,jsx,tsx}'
run: |
yarn prettier --write --loglevel silent "{staged_files}" > /dev/null 2>&1 ||
{ echo "⚠️ Prettier found formatting issues. Automatic formatting applied."
git add {staged_files}
}
lint-js:
glob: "assets/js/*.{js,ts}"
run: yarn eslint {staged_files}
fail_text: "JavaScript linting failed. Fix errors before committing."
shellcheck:
tags: lint
glob: "*.sh"
exclude:
- "shared/text/**/*.sh"
- "layouts/shortcodes/**/*.sh"
- "node_modules/**"
run: .ci/shellcheck/shellcheck.sh {staged_files}
fail_text: "ShellCheck found issues in shell scripts. Fix errors before committing."
pre-push:
commands:
packages-audit:
tags: frontend security
run: |
default_branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@') || default_branch="master"
current_branch=$(git branch --show-current)
yarn audit; status=$?
if [ $status -ne 0 ] && [ "$current_branch" != "$default_branch" ]; then
echo "⚠️ yarn audit found vulnerabilities (warning only — non-default branch '$current_branch')"
echo " Create an issue: https://github.com/influxdata/docs-v2/issues/new?title=yarn+audit+vulnerabilities&labels=security"
exit 0
fi
exit $status
e2e-shortcode-examples:
tags: [frontend, test]
glob:
- assets/*.{js,mjs,css,scss}
- layouts/*.html
- content/example.md
run: |
echo "Running shortcode examples test due to changes in: {staged_files}"
node cypress/support/run-e2e-specs.js --spec "cypress/e2e/content/index.cy.js" content/example.md
exit $?
# Manage Docker containers
# Disabled: original task fails when docker is not installed or running.
# Replaced by list-legacy-containers below, which exits 0 when docker
# is unavailable so the push is not blocked.
# prune-legacy-containers:
# priority: 1
# tags: test
# run: '(docker container ls --format "{{.ID}}"
# --filter label=tag=influxdata-docs
# --filter status=exited | xargs docker rm)
# || true'
list-legacy-containers:
tags: test
run: |
if ! command -v docker >/dev/null 2>&1; then
exit 0
fi
if ! docker info >/dev/null 2>&1; then
exit 0
fi
legacy=$(docker container ls -a \
--format "{{.ID}} {{.Names}}" \
--filter label=tag=influxdata-docs \
--filter status=exited 2>/dev/null)
if [ -n "$legacy" ]; then
echo "Note: exited influxdata-docs containers found (push not blocked):"
echo "$legacy" | sed 's/^/ /'
echo "Prune with: docker container prune --filter label=tag=influxdata-docs"
fi
exit 0
# Disabled: builds the pytest image used by the *-pytest tasks below.
# Now that those tasks are disabled, this task is dead weight and fails
# when docker is not installed. Run `yarn build:pytest:image` manually
# before invoking `yarn test:codeblocks:*` if you need a fresh image.
# build-pytest-image:
# tags: test
# run: yarn build:pytest:image
# Test code blocks in markdown files
# Disabled: codeblock tests require docker and a configured product
# environment. Run them on demand instead:
# yarn test:codeblocks:all
# yarn test:codeblocks:<product>
# cloud-pytest:
# glob: content/influxdb/cloud/*.md
# tags: test,codeblocks,v2
# env:
# SERVICE: cloud-pytest
# run: yarn test:codeblocks:cloud '{staged_files}'
#
# cloud-dedicated-pytest:
# tags: test,codeblocks,v3
# glob: content/influxdb3/cloud-dedicated/*.md
# run: |
# yarn test:codeblocks:cloud-dedicated '{staged_files}' &&
# ./test/scripts/monitor-tests.sh stop cloud-dedicated-pytest
#
# cloud-serverless-pytest:
# tags: test,codeblocks,v3
# glob: content/influxdb3/cloud-serverless/*.md
# env:
# SERVICE: cloud-serverless-pytest
# run: yarn test:codeblocks:cloud-serverless '{staged_files}'
#
# clustered-pytest:
# tags: test,codeblocks,v3
# glob: content/influxdb3/clustered/*.md
# run: |
# yarn test:codeblocks:clustered '{staged_files}' &&
# ./test/scripts/monitor-tests.sh stop clustered-pytest
#
# telegraf-pytest:
# tags: test,codeblocks
# glob: content/telegraf/*.md
# env:
# SERVICE: telegraf-pytest
# run: yarn test:codeblocks:telegraf '{staged_files}'
#
# v2-pytest:
# tags: test,codeblocks,v2
# glob: content/influxdb/v2/*.md
# env:
# SERVICE: v2-pytest
# run: yarn test:codeblocks:v2 '{staged_files}'