-
Notifications
You must be signed in to change notification settings - Fork 0
/
.lefthook.yml
90 lines (88 loc) · 2.42 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
pre-commit:
piped: true
commands:
start_containers:
priority: 1
run: docker compose up -d
wait_for_web:
priority: 2
run: |
for i in {1..30}; do
if curl -s http://localhost:8000/up >/dev/null; then
echo "Web service is up!"
exit 0
fi
echo "Waiting for web service... (attempt $i)"
sleep 1
done
echo "Web service did not come up in time. Checking logs:"
docker logs portfolio-web-1
exit 1
format_elixir:
priority: 3
glob: "*.{ex,exs}"
run: |
echo "Current user: $(id)"
echo "Current directory: $(pwd)"
echo "Staged files: {staged_files}"
./run mix format {staged_files}
# format_js:
# glob: "*.{js,jsx,ts,tsx}"
# run: ./run yarn:build:js
# stop_containers:
# run: docker compose down
pre-push-check:
parallel: false
commands:
check_web_container:
run: docker ps --filter name=portfolio-web-1 --quiet
glob: ""
check_js_container:
run: docker ps --filter name=portfolio-js-1 --quiet
glob: ""
check_css_container:
run: docker ps --filter name=portfolio-css-1 --quiet
glob: ""
start_containers:
priority: 1
run: docker compose up -d
wait_for_web:
priority: 2
run: |
for i in {1..30}; do
if curl -s http://localhost:8000/up >/dev/null; then
echo "Web service is up!"
exit 0
fi
echo "Waiting for web service... (attempt $i)"
sleep 1
done
echo "Web service did not come up in time. Checking logs:"
docker logs portfolio-web-1
exit 1
glob: ""
format_check_elixir:
glob: "*.{ex,exs}"
run: ./run mix format
lint_elixir:
glob: "*.{ex,exs}"
run: ./run mix credo
test_elixir:
glob: "*.{ex,exs}"
run: ./run test
# format_check_js:
# run: ./run yarn prettier --check .
# lint_js:
# run: ./run yarn eslint .
# test_js:
# run: ./run yarn test
stop_containers:
run: |
if [ -z "$(lefthook exec check_web_container)" ] && [ -z "$(lefthook exec check_js_container)" ]; then
docker compose down
fi
pre-push:
parallel: false
commands:
run_checks:
run: lefthook run pre-push-check || echo "Checks failed, but push will proceed. Please fix issues before merging."