Skip to content

Commit 5c74f01

Browse files
committed
chore(ci): Improve CI lint and test runners
- Reconfigures prettier linting. - Adds .editorconfig to help with consistent editor settings - Refactors test runs: - Removes test configuration from compose.yaml (not suited for this use case). - Splits test runner into test content setup and pytest that can be run separately or together (and with other test runners in the future). - Configuration is in Dockerfiles and command line (`.lintstagedrc.mjs`) - Updates CONTRIBUTING.md - Updates client library write examples in cloud-dedicated and clustered.
1 parent 37dd3ea commit 5c74f01

30 files changed

+3007
-2323
lines changed

.editorconfig

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
charset = utf-8
2+
insert_final_newline = true
3+
end_of_line = lf
4+
indent_style = space
5+
indent_size = 2
6+
max_line_length = 80

.gitignore

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
public
44
.*.swp
55
node_modules
6+
.config*
7+
**/.env*
68
*.log
79
/resources
810
.hugo_build.lock
911
/content/influxdb/*/api/**/*.html
1012
/api-docs/redoc-static.html*
1113
.vscode/*
1214
.idea
13-
package-lock.json
15+
config.toml
16+
package-lock.json
17+
tmp

.husky/pre-commit

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
npx lint-staged --relative --verbose
2-
yarn run test
1+
npx lint-staged --relative

.lintstagedrc.mjs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Lint-staged configuration. This file must export a lint-staged configuration object.
2+
3+
function lintStagedContent(paths, productPath) {
4+
const name = `staged-${productPath.replace(/\//g, '-')}`;
5+
6+
return [
7+
`prettier --write ${paths.join(' ')}`,
8+
9+
`docker build . -f Dockerfile.tests -t influxdata-docs/tests:latest`,
10+
11+
// Remove any existing test container.
12+
`docker rm -f ${name} || true`,
13+
14+
`docker run --name ${name} --mount type=volume,target=/app/content --mount type=bind,src=./content,dst=/src/content --mount type=bind,src=./static/downloads,dst=/app/data
15+
influxdata-docs/tests --files "${paths.join(' ')}"`,
16+
17+
`docker build . -f Dockerfile.pytest -t influxdata-docs/pytest:latest`,
18+
19+
// Run test runners. If tests fail, the container will be removed,
20+
//but the "test-" container will remain until the next run.
21+
`docker run --env-file ${productPath}/.env.test
22+
--volumes-from ${name} --rm
23+
influxdata-docs/pytest --codeblocks ${productPath}/`
24+
];
25+
}
26+
27+
export default {
28+
"*.{js,css}": paths => `prettier --write ${paths.join(' ')}`,
29+
30+
// Don't let prettier check or write Markdown files for now;
31+
// it indents code blocks within list items, which breaks Hugo's rendering.
32+
// "*.md": paths => `prettier --check ${paths.join(' ')}`,
33+
34+
"content/influxdb/cloud-dedicated/**/*.md":
35+
paths => lintStagedContent(paths, 'content/influxdb/cloud-dedicated'),
36+
"content/influxdb/clustered/**/*.md":
37+
paths => lintStagedContent(paths, 'content/influxdb/clustered'),
38+
39+
// "content/influxdb/cloud-serverless/**/*.md": "docker compose run -T lint --config=content/influxdb/cloud-serverless/.vale.ini --minAlertLevel=error",
40+
41+
// "content/influxdb/clustered/**/*.md": "docker compose run -T lint --config=content/influxdb/clustered/.vale.ini --minAlertLevel=error",
42+
43+
// "content/influxdb/{cloud,v2,telegraf}/**/*.md": "docker compose run -T lint --config=.vale.ini --minAlertLevel=error"
44+
}

.prettierignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore Prettier checking for files
2+
**/.git
3+
**/.svn
4+
**/.hg
5+
**/node_modules

.prettierrc.yaml

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
trailingComma: "es5"
2-
tabWidth: 2
1+
# ~/.prettierrc.yaml
2+
printWidth: 80
33
semi: true
44
singleQuote: true
5+
tabWidth: 2
6+
trailingComma: "es5"
7+
useTabs: false
8+
overrides:
9+
- files:
10+
- "*.md"
11+
- "*.markdown"
12+
options:
13+
proseWrap: "preserve"
14+
# Prettier also uses settings, such as indent, specified in .editorconfig

0 commit comments

Comments
 (0)