-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlefthook.yml
142 lines (140 loc) · 4.39 KB
/
lefthook.yml
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
# EXAMPLE USAGE
# Refer for explanation to following link:
# https://evilmartians.github.io/lefthook/configuration/no_tty.html
#
shell:
pty: false
verbose: false
pre-push:
pre-command: git add . && git stash
post-command: |
if [[ -n $(git ls-files --others --exclude-standard) ]]; then
echo "❌ Error: New files were generated during the pre-push hook:"
git ls-files --others --exclude-standard
echo "Please commit these files before pushing."
exit 1
fi
commands:
test-next:
tags: backend
run: CI=true RAILS_ENV=test bin/setup-next &&
CI=true RAILS_ENV=test HEADLESS=true CUPRITE=true APP_HOST='127.0.0.1' next rails test
gems-audit:
tags: backend security
run: bundle audit update && bundle audit check
javascript-audit:
tags: frontend security
run: yarn npm audit --all
importmaps-audit:
tags: frontend security
run: bin/importmap audit
rubocop:
tags: backend style
files: git diff --name-only develop
glob: '*.rb'
run: bundle exec rubocop --force-exclusion -A {files}
brakeman:
tags: backend security
run: bundle exec brakeman --no-pager
rails-system-tests:
tags: backend tests
run: CI=true RAILS_ENV=test bin/setup --skip-server &&
CI=true RAILS_ENV=test bin/rails test:prepare --trace &&
CI=true RAILS_ENV=test HEADLESS=true CUPRITE=true APP_HOST='127.0.0.1' CUPRITE_JS_ERRORS=true bin/rails test:system
verify_ci_ready:
run: bin/container-healthcheck.sh && echo "✓ CI-ready environment" || { echo "✗ Environment mismatch detected"; exit 1; }
tags: ci
pre-commit:
fail_fast: true
pre-command: git stash --keep-index
parallel: false
commands:
debug:
run: mise env && ruby -v && bundle exec ruby -v
js:
glob: '*.{js,ts}'
run: yarn prettier --write {staged_files}
stage_fixed: true
rubocop:
tags: backend style
glob: '*.rb'
exclude: 'application.rb|routes.rb'
run: bundle exec rubocop -a --force-exclusion {all_files}
stage_fixed: true
erb-lint:
tags: frontend style
files: git diff --name-only develop
glob: '*.erb'
run: bundle exec erb_lint --lint-all {staged_files}
yaml-lint:
tags: frontend style
files: git diff --name-only develop
glob: '*.yml'
run: bundle exec yaml-lint {staged_files}
stage_fixed: true
rails-tests:
tags: backend tests
run: CI=true RAILS_ENV=test bin/setup --skip-server &&
CI=true RAILS_ENV=test bin/rails test:prepare --trace &&
CI=true RAILS_ENV=test HEADLESS=true CUPRITE=true APP_HOST='127.0.0.1' bin/rails test
verify_environment:
run: bin/container-healthcheck.sh && { echo "✓ Environment valid"; exit 0; } || { echo "✗ Environment invalid - run bin/setup-environment.sh"; exit 1; }
tags: validation
skip:
- merge
- rebase
fixer:
verbose: false
pty: false
parallel: true
commands:
ruby-fixer:
glob: '**/*.rb'
run: bundle exec rubocop --autocorrect-all --force-exclusion {all_files}
stage_fixed: true
js-fixer:
glob: 'app/javascript/**/*.{js,ts,jsx,tsx}'
run: yarn prettier --write {all_files}
stage_fixed: true
ruby-prettier:
glob: 'app/**/*.rb'
run: bundle exec rbprettier --write {files}
stage_fixed: true
erb_lint:
glob: 'app/views/**/*.erb'
run: bundle exec erb_lint --autocorrect {all_files}
stage_fixed: true
yaml-lint:
glob: '**/*.yml'
run: bundle exec yaml-lint {all_files}
stage_fixed: true
brakeman:
run: bundle exec brakeman --no-pager
yarn-audit:
tags: frontend security
run: yarn npm audit
gems-audit:
tags: backend security
run: bundle audit update && bundle audit check
i18n-tasks:
run: bundle exec i18n-tasks health || bundle exec i18n-tasks normalize
stage_fixed: true
yarn-lint:
tags: frontend updates
glob: '{app/javascript/**/*.{js,ts,jsx,tsx},**/*.{css,scss,sass,md,json}}'
run: yarn prettier --write {all_files}
stage_fixed: true
importmaps-audit:
tags: frontend security
run: bin/importmap outdated
# scripts:
# "hello.js":
# runner: node
# "any.go":
# runner: go run
# "any.py":
# runner: python
# "any.rb":
# runner: ruby
# "any.sh":
# runner: bash