202 lines
7.0 KiB
YAML
202 lines
7.0 KiB
YAML
# Refer for explanation to following link:
|
|
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
|
|
#
|
|
|
|
pre-commit:
|
|
parallel: true
|
|
commands:
|
|
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: |
|
|
# Prepend /workdir/ to staged files since repository is mounted at /workdir in container
|
|
files=$(echo '{staged_files}' | sed 's|^|/workdir/|g; s| | /workdir/|g')
|
|
docker compose run --rm --name remark-lint remark-lint $files --output --quiet || \
|
|
{ echo "⚠️ Remark found formatting issues in instruction files. Automatic formatting applied."; }
|
|
stage_fixed: true
|
|
# Report markdown formatting issues in content/api-docs without auto-fixing
|
|
lint-markdown-content:
|
|
tags: lint
|
|
glob: "{api-docs/**/*.md,content/**/*.md}"
|
|
run: |
|
|
# Prepend /workdir/ to staged files since repository is mounted at /workdir in container
|
|
files=$(echo '{staged_files}' | sed 's|^|/workdir/|g; s| | /workdir/|g')
|
|
# Run remark to check for formatting differences (without --output, shows diff in stdout)
|
|
# If output differs from input, fail the commit
|
|
for file in $files; do
|
|
original=$(cat "${file#/workdir/}")
|
|
formatted=$(docker compose run --rm --name remark-lint-content remark-lint "$file" 2>/dev/null | tail -n +2)
|
|
if [ "$original" != "$formatted" ]; then
|
|
echo "❌ Markdown formatting issues in ${file#/workdir/}"
|
|
echo " Run: docker compose run --rm remark-lint $file --output"
|
|
echo " Or manually fix the formatting to match remark style"
|
|
exit 1
|
|
fi
|
|
done
|
|
echo "✅ All content files are properly formatted"
|
|
# Lint instruction and repository documentation files with generic Vale config
|
|
lint-instructions:
|
|
tags: lint
|
|
glob: "{README.md,*[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
|
|
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."
|
|
pre-push:
|
|
commands:
|
|
packages-audit:
|
|
tags: frontend security
|
|
run: yarn audit
|
|
|
|
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
|
|
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'
|
|
build-pytest-image:
|
|
tags: test
|
|
run: yarn build:pytest:image
|
|
|
|
# Test code blocks in markdown files
|
|
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}' |