-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlefthook.yml
More file actions
108 lines (91 loc) · 4.14 KB
/
lefthook.yml
File metadata and controls
108 lines (91 loc) · 4.14 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
# Lefthook configuration for automated quality checks
# pre-commit: runs on staged files before commit
# pre-push: runs full validation before pushing to remote
pre-commit:
parallel: true
commands:
# Format and lint staged PHP files with phpcbf + phpcs.
php-format:
glob: '*.php'
exclude: 'src/Generated/**|vendor/**'
run: vendor/bin/phpcbf --standard=phpcs.xml.dist {staged_files} || true
stage_fixed: true
php-lint:
glob: '*.php'
exclude: 'src/Generated/**|vendor/**'
run: vendor/bin/phpcs --standard=phpcs.xml.dist {staged_files}
# Format JS/CSS/JSON/MD via prettier on staged files only. `npx prettier`
# is preferred over `wp-scripts format` because the latter ignores file
# args and re-formats the whole repo. .prettierignore is read by
# default, so generated outputs and the spec snapshot stay untouched.
js-format:
glob: '*.{js,jsx,ts,tsx,css,scss,json,md,yml,yaml}'
exclude: 'src/Generated/**|blocks/generated/**|build/**|specs/**|vendor/**|node_modules/**|*.min.*'
run: npx prettier --write --ignore-unknown {staged_files}
stage_fixed: true
# Lint JS/CSS via wp-scripts (eslint + stylelint).
js-lint:
glob: '{blocks,assets/js,bin}/**/*.{js,jsx}'
exclude: 'blocks/generated/**|build/**'
run: npx wp-scripts lint-js {staged_files}
css-lint:
glob: '{blocks,assets/css}/**/*.{css,scss}'
exclude: 'build/**'
run: npx wp-scripts lint-style {staged_files}
phpstan:
glob: 'src/**/*.php'
exclude: 'src/Generated/**'
run: vendor/bin/phpstan analyze --no-progress --memory-limit=1G
# Rebuild blocks if source changed.
block-build-check:
glob: 'blocks/**/*.{js,jsx,json,php}'
exclude: 'blocks/generated/**'
run: npm run build:all && git diff --exit-code build/
# Regenerate if generator config changed.
openapi-drift-check:
glob: 'bin/{generate.mjs,ttl-map.json,hero-endpoints.json,hero-config.json,example-overrides.json}'
run: npm run generate:check
pre-push:
parallel: false
commands:
# Full OpenAPI drift check
openapi-drift-check:
run: npm run generate:check
priority: 1
# Full format pass (auto-fix). PHP first, then JS/CSS so each tool
# only touches files it owns.
php-format:
run: vendor/bin/phpcbf --standard=phpcs.xml.dist || true
priority: 2
# Full lint (must pass clean after format).
php-lint:
run: vendor/bin/phpcs --standard=phpcs.xml.dist
priority: 3
# JS/CSS format check — fails the push if any non-ignored file is
# not in canonical form. Run `npm run format` to fix locally.
js-format-check:
run: npx prettier --check .
priority: 3
# JS lint across the whole hand-written surface.
js-lint:
run: npm run lint:js
priority: 3
css-lint:
run: npm run lint:css
priority: 3
# Static analysis
phpstan:
run: vendor/bin/phpstan analyze --no-progress --memory-limit=1G
priority: 4
# PHPUnit. Requires wp-env running locally. Run `npx wp-env start` once per session.
phpunit:
run: |
docker ps --format '{{.Names}}' | grep -q tests-wordpress || { echo "✗ wp-env tests env not running. Run: npx wp-env start"; exit 1; }
npx wp-env run tests-cli --env-cwd=wp-content/plugins/roxyapi-sdk-wordpress vendor/bin/phpunit
priority: 5
# Plugin Check at WP.org submission severity. Requires wp-env running.
plugin-check:
run: |
docker ps --format '{{.Names}}' | grep -q '\-cli$\|wordpress-1$' || { echo "✗ wp-env not running. Run: npx wp-env start"; exit 1; }
npx wp-env run cli wp plugin check roxyapi-sdk-wordpress --severity=5
priority: 6