-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlefthook.yml
More file actions
102 lines (99 loc) · 3.8 KB
/
Copy pathlefthook.yml
File metadata and controls
102 lines (99 loc) · 3.8 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
# Lefthook — Git hooks manager.
# Documentation: https://lefthook.dev/
#
# Install hooks (once, after cloning the repository):
# npx lefthook install
#
# What the hooks check:
# commit-msg → commit message format (Conventional Commits)
# pre-commit → branch name (Conventional Branch) + linters on staged files
# pre-push → fast tests (optional)
commit-msg:
commands:
commitlint:
run: npx --no-install commitlint --edit {1}
pre-commit:
parallel: true
commands:
branch-name:
# Conventional Branch — accepted forms:
# <type>/<slug> feat/conventional-branches
# <type>/<issue#> feat/4
# <type>/#<issue#> feat/#4
# <type>/<issue#>-<slug> feat/9-conventional-branches
# <type>/#<issue#>-<slug> feat/#9-conventional-branches
# release/<MAJOR>.<MINOR>.<PATCH> release/0.2.0
#
# The slug is optional (the issue number alone is fine).
# The '#' prefix before the number is optional (matches GitHub's style).
# master/main/HEAD are skipped — direct commits aren't expected on them.
run: |
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH" = "master" ] || [ "$BRANCH" = "main" ] || [ "$BRANCH" = "HEAD" ]; then
exit 0
fi
# Release branches: dotted versions (release/X.Y.Z or release/X.Y.Z-rc1).
if echo "$BRANCH" | grep -qE '^release/[0-9]+\.[0-9]+\.[0-9]+(-[a-z0-9]+)?$'; then
exit 0
fi
# All other types: <type>/[#]<slug-or-issue>
if echo "$BRANCH" | grep -qE '^(feat|fix|hotfix|chore|docs|refactor|perf|test|ci|build|style|security|deps)/#?[a-z0-9]+(-[a-z0-9]+)*$'; then
exit 0
fi
echo ""
echo "✗ Branch name '$BRANCH' does not match Conventional Branch."
echo ""
echo " Format: <type>/<slug> or"
echo " <type>/<issue#> or"
echo " <type>/#<issue#> or"
echo " <type>/<issue#>-<slug> or"
echo " <type>/#<issue#>-<slug>"
echo ""
echo " Types: feat fix hotfix chore docs refactor perf test ci build style security deps"
echo " release (versions only: release/X.Y.Z)"
echo ""
echo " Examples:"
echo " feat/4"
echo " feat/#4"
echo " feat/9-conventional-branches"
echo " feat/#9-conventional-branches"
echo " fix/12-bitrix-comments-encoding"
echo " chore/update-deps"
echo " release/0.2.0"
echo ""
echo " To rename: git branch -m <new-name>"
echo ""
exit 1
pint:
glob: "backend/**/*.php"
root: "backend/"
run: docker compose exec -T app ./vendor/bin/pint --test {staged_files}
skip:
- merge
- rebase
phpstan:
glob: "backend/**/*.php"
run: docker compose exec -T app ./vendor/bin/phpstan analyse --no-progress
skip:
- merge
- rebase
eslint:
glob: "frontend/**/*.{ts,tsx,js,jsx}"
root: "frontend/"
run: npx eslint {staged_files}
skip:
- merge
- rebase
dockerfile-lint:
# Pinned digest must match the Makefile's HADOLINT_IMAGE.
# MSYS_NO_PATHCONV=1 — Windows/Git Bash path-mangling guard (no-op elsewhere).
glob: ".docker/**/Dockerfile"
run: MSYS_NO_PATHCONV=1 docker run --rm -v "$PWD:/repo:ro" -w /repo ghcr.io/hadolint/hadolint:v2.14.0@sha256:27086352fd5e1907ea2b934eb1023f217c5ae087992eb59fde121dce9c9ff21e hadolint {staged_files}
skip:
- merge
- rebase
# pre-push can be enabled once the tests are stably green.
# pre-push:
# commands:
# phpunit:
# run: docker compose exec -T app ./vendor/bin/phpunit --testsuite=Unit