-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (81 loc) · 2.59 KB
/
ci.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
name: CI checks
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
checks:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install UV
id: setup-uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"
enable-cache: true
cache-suffix: "${{ runner.os }}-uv"
- name: Check if UV cache was restored
if: steps.setup-uv.outputs.cache-hit == 'true'
run: echo "UV cache was restored!"
- name: Install Python 3.12
run: uv python install 3.12
- name: Upgrade PIP and install Invoke
run: |
python -m pip install --upgrade pip
pip install invoke
- name: Install dependencies
run: inv sync-deps
- name: Ensure local environment variables
run: |
cp .env.template .env
cat .env # display what we have for real there (post-changes if any)
- name: Run tests
id: test
run: inv test
continue-on-error: true
- name: Run format checking
id: format_check
run: inv format-check
continue-on-error: true
- name: Run linting
id: lint
run: inv lint
continue-on-error: true
- name: Run type-checking
id: type_check
run: inv type-check
continue-on-error: true
# Final summary step which checks all the others.
- name: Check results and fail if any previous check failed
if: always()
run: |
# Create an array of step IDs and their outcomes.
declare -A steps
steps["test"]="${{ steps.test.outcome }}"
steps["format_check"]="${{ steps.format_check.outcome }}"
steps["lint"]="${{ steps.lint.outcome }}"
steps["type_check"]="${{ steps.type_check.outcome }}"
# Go through each one of those and check their outcome.
succeeded=0
failed=0
for step_id in ${!steps[@]}; do
outcome=${steps[$step_id]}
if [[ $outcome == "success" ]]; then
echo "✅ $step_id succeeded"
succeeded=$((succeeded + 1))
else
echo "❌ $step_id failed"
failed=$((failed + 1))
fi
done
# Report a final summary and set exit code based on the aggregated results.
echo "Summary: $succeeded succeeded, $failed failed"
if [ $failed -gt 0 ]; then
echo "Some steps failed!"
exit 1
fi