-
-
Notifications
You must be signed in to change notification settings - Fork 18
237 lines (213 loc) · 7.7 KB
/
autofix.yml
File metadata and controls
237 lines (213 loc) · 7.7 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
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
name: autofix.ci
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-openapi
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
on:
pull_request:
branches: [ main ]
paths:
- 'server/src/**'
pull_request_target:
types: [ labeled ]
branches: [ main ]
permissions: {}
jobs:
update-server-snapshots:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Setup | Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with: {persist-credentials: false}
- name: Install cargo-insta
uses: taiki-e/install-action@fa0dd4cd0a40696e6f9766370614a5ce482e6aa8 # v2.77.5
with:
tool: cargo-insta
- name: Update server snapshots
run: cargo insta test --accept
continue-on-error: true
- uses: autofix-ci/action@c5b2d67aa2274e7b5a18224e8171550871fc7e4a # v1.3.4
with:
commit-message: "chore: Update server snapshots"
sort-cargo-toml:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Setup | Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with: {persist-credentials: false}
- name: Install cargo-sort
uses: taiki-e/install-action@fa0dd4cd0a40696e6f9766370614a5ce482e6aa8 # v2.77.5
with:
tool: cargo-sort
- name: Sort Cargo.toml
run: cargo sort
- uses: autofix-ci/action@c5b2d67aa2274e7b5a18224e8171550871fc7e4a # v1.3.4
with:
commit-message: "chore: sort Cargo.toml"
update-screenshots:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'bless')
permissions:
contents: read
steps:
- uses: BRAINSia/free-disk-space@7048ffbf50819342ac964ef3998a51c2564a8a75 # v2.1.3
with:
tool-cache: false
mandb: true
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: true
- name: Setup | Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with: {persist-credentials: false}
- name: Setup | Pull Docker images
run: docker compose pull
- name: Setup | Build Docker images
run: docker compose -f compose.local.yml build
- name: Setup | pnpm
uses: pnpm/action-setup@08c4be7e2e672a47d11bd04269e27e5f3e8529cb # v6.0.0
with:
version: 10.14.0
package_json_file: tests/package.json
run_install: |
- cwd: tests
args: [--frozen-lockfile]
- name: Install Browser
working-directory: tests
run: pnpm exec playwright install --with-deps chromium
- name: Setup | Create .env file for docker-compose
run: |
cat > .env << EOF
POSTGRES_PASSWORD=test_password
POSTGRES_USER=postgres
POSTGRES_DB=navigatum_test
MEILI_MASTER_KEY=test_master_key
LOG_LEVEL=debug
EOF
- name: Setup | Start Docker services
run: |
docker compose -f compose.local.yml up -d
echo "Waiting for services to be healthy..."
timeout 120 bash -c 'until curl -f http://localhost:3003/api/locations/mi; do sleep 2; done'
timeout 120 bash -c 'until curl -f http://localhost:3003/api/search?q=MI; do sleep 2; done'
timeout 120 bash -c 'until curl -f http://localhost:3000/; do sleep 2; done'
- name: Update | Screenshots
run: pnpm run update-screenshots
working-directory: tests
env:
BASE_URL: http://localhost:3000
SKIP_WEBSERVER: true
- name: Restore | Discard test-only side-effects (.env, lockfile)
run: git checkout -- .env tests/pnpm-lock.yaml
- uses: autofix-ci/action@c5b2d67aa2274e7b5a18224e8171550871fc7e4a # v1.3.4
with:
commit-message: "chore: update screenshots"
update-openapi:
runs-on: ubuntu-latest
permissions:
contents: read
services:
postgres:
image: postgis/postgis:18-3.6
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
POSTGRES_DB: navigatum
ports:
- 5432:5432
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
steps:
- run: rustup update stable && rustup default stable
- name: Setup | Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with: {persist-credentials: false}
- name: Setup | Rust-Cache
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
with:
workspaces: |
server
- name: Setup | Install yq for YAML conversion
run: |
curl -L https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -o /usr/local/bin/yq
sudo chmod +x /usr/local/bin/yq
- name: Setup | pnpm
uses: pnpm/action-setup@08c4be7e2e672a47d11bd04269e27e5f3e8529cb # v6.0.0
with:
version: 10.14.0
package_json_file: webclient/package.json
run_install: |
- cwd: webclient
args: [--frozen-lockfile]
- name: Build | Compile server
working-directory: server
run: cargo build
env:
CARGO_INCREMENTAL: 0
- name: Run | Start server in background
working-directory: server
run: cargo run &
env:
CARGO_INCREMENTAL: 0
SKIP_MS_SETUP: true
SKIP_DB_SETUP: true
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_URL: localhost
POSTGRES_DB: navigatum
LOG_LEVEL: info
- name: Wait | Server startup
run: |
echo "Waiting for server to start..."
timeout=60
count=0
until curl -f http://localhost:3003/api/status > /dev/null 2>&1; do
if [ $count -ge $timeout ]; then
echo "Server failed to start within $timeout seconds"
exit 1
fi
echo "Waiting for server to be ready... ($count/$timeout)"
sleep 1
count=$((count + 1))
done
echo "Server is ready!"
- name: Fetch | Download OpenAPI spec
run: |
echo "Fetching OpenAPI spec from server..."
curl -f http://localhost:3003/api/openapi.json -o openapi.json
echo "Converting JSON to YAML..."
yq -Poy openapi.json > data/output/openapi.yaml
echo "Cleaning up temporary file..."
rm openapi.json
- name: Update | Refresh types
run: pnpm run type-refresh
working-directory: webclient
continue-on-error: true
- name: Restore | Discard lockfile side-effects from pnpm
run: git checkout -- webclient/pnpm-lock.yaml
- uses: autofix-ci/action@c5b2d67aa2274e7b5a18224e8171550871fc7e4a # v1.3.4
with:
commit-message: "chore: Update OpenAPI spec and types"
# This final step is needed to mark the whole workflow as successful
# Don't change its name - it is used by the merge protection rules
done:
name: Finished autofix
runs-on: ubuntu-latest
needs: [ update-server-snapshots, sort-cargo-toml, update-openapi, update-screenshots ]
if: always()
permissions: {}
steps:
- name: Result of the needed steps
run: echo "${{ toJSON(needs) }}" # zizmor: ignore[template-injection]
- if: ${{ contains(needs.*.result, 'failure') }}
name: CI Result
run: exit 1