-
Notifications
You must be signed in to change notification settings - Fork 13
427 lines (412 loc) · 14.8 KB
/
Copy pathci.yaml
File metadata and controls
427 lines (412 loc) · 14.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
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
name: Continous Integration
on:
push:
branches:
- main
paths-ignore:
- "VERSION"
- "CHANGELOG.md"
pull_request:
paths-ignore:
- "VERSION"
workflow_dispatch:
workflow_call:
repository_dispatch:
types: [start-ci]
env:
MIX_ENV: test
ELIXIR_BC: "1.15.7-otp-26"
ERLANG_BC: "26.2.1"
jobs:
setup-matrix-env:
runs-on: ubuntu-24.04
outputs:
ELIXIR_DEV: ${{ env.ELIXIR_VERSION }}
ERLANG_DEV: ${{ env.ERLANG_VERSION }}
RUST_DEV: ${{ env.RUST_VERSION }}
ELIXIR_BC: ${{ env.ELIXIR_BC }}
ERLANG_BC: ${{ env.ERLANG_BC }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: gather versions
uses: endorama/asdf-parse-tool-versions@v1
- name: Compute matrix
run: |
echo "ELIXIR_DEV=${{ env.ELIXIR_VERSION }}" >> $GITHUB_OUTPUT
echo "ERLANG_DEV=${{ env.ERLANG_VERSION }}" >> $GITHUB_OUTPUT
echo "RUST_DEV=${{ env.RUST_VERSION }}" >> $GITHUB_OUTPUT
echo "ELIXIR_BC=${{ env.ELIXIR_BC }}" >> $GITHUB_OUTPUT
echo "ERLANG_BC=${{ env.ERLANG_BC }}" >> $GITHUB_OUTPUT
elixir-deps:
name: Elixir dependencies
uses: ./.github/workflows/deps.yaml
static-code-analysis:
name: Static Code Analysis
needs: [setup-matrix-env, elixir-deps]
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.13.1
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup
id: setup-elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Retrieve Elixir Cached Dependencies
uses: actions/cache@v5
id: mix-cache
with:
path: |
deps
_build/test
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-rust-${{ needs.setup-matrix-env.outputs.RUST_DEV }}-${{ hashFiles('mix.lock') }}
- name: Check for Unused Dependencies
run: mix deps.unlock --check-unused
- name: Check Code Format
run: mix format --check-formatted
- name: Run Credo
run: mix credo --strict
- name: Run Dialyzer
run: mix dialyzer
test:
name: Test
needs: [setup-matrix-env, elixir-deps]
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
services:
postgres:
image: postgres
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: wanda_test
ports:
- 5434:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
rabbitmq:
image: rabbitmq
env:
RABBITMQ_DEFAULT_USER: wanda
RABBITMQ_DEFAULT_PASS: wanda
ports:
- 5674:5672
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.13.1
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup
id: setup-elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Retrieve Cached Dependencies
uses: actions/cache@v5
id: mix-cache
with:
path: |
deps
_build/test
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-rust-${{ needs.setup-matrix-env.outputs.RUST_DEV }}-${{ hashFiles('mix.lock') }}
- name: Compile
run: mix compile --warnings-as-errors
- name: Run test
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mix coveralls.github --warnings-as-errors --color --trace
main-branch-deps:
name: main branch dependencies
if: github.event_name == 'pull_request'
uses: ./.github/workflows/deps.yaml
with:
checkout_ref: main
target-branch-deps:
name: Rebuild target branch dependencies
needs: [setup-matrix-env]
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
if: github.event_name == 'pull_request'
steps:
- name: Checkout target branch
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.base.ref }}
- name: Set up Elixir
id: setup-elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Retrieve Elixir Cached Dependencies - target branch
uses: actions/cache@v5
id: mix-cache-target
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-${{ hashFiles('mix.lock') }}-${{ env.MIX_ENV }}
- name: Install missing dependencies
if: steps.mix-cache-target.outputs.cache-hit != 'true'
run: |
mkdir -p priv/plts
mix local.rebar --force
mix local.hex --force
mix deps.get
mix deps.compile --warnings-as-errors
mix dialyzer --plt
api-docs-check:
name: API docs check
needs: [setup-matrix-env, elixir-deps]
if: github.event_name == 'pull_request' && !failure() && !cancelled()
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.13.1
with:
access_token: ${{ github.token }}
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Elixir
id: setup-elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Retrieve Cached Dependencies - current branch
uses: actions/cache@v5
id: mix-cache-current
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-rust-${{ needs.setup-matrix-env.outputs.RUST_DEV }}-${{ hashFiles('mix.lock') }}
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 22.15.1
- name: Install API linting tools
run: |
npm install -g @redocly/cli@latest
npm install -g @quobix/vacuum@latest
npm install -g @stoplight/spectral-cli
- name: Run API docs check
run: ./hack/api_docs_check.sh
api-bc-check:
name: API bc check
needs: [setup-matrix-env, elixir-deps, target-branch-deps]
if: github.event_name == 'pull_request' && !failure() && !cancelled()
runs-on: ubuntu-24.04
strategy:
matrix:
include:
- version: Unversioned
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- version: Unversioned
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
- version: V1
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- version: V1
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
- version: V2
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- version: V2
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
- version: V3
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_BC }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_BC }}
- version: V3
elixir: ${{ needs.setup-matrix-env.outputs.ELIXIR_DEV }}
otp: ${{ needs.setup-matrix-env.outputs.ERLANG_DEV }}
steps:
- name: Cancel Previous Runs
uses: styfle/cancel-workflow-action@0.13.1
with:
access_token: ${{ github.token }}
- name: Checkout current branch
uses: actions/checkout@v6
- name: Set up Elixir
id: setup-elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ matrix.otp }}
elixir-version: ${{ matrix.elixir }}
- name: Retrieve Cached Dependencies - current branch
uses: actions/cache@v5
id: mix-cache-current
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-rust-${{ needs.setup-matrix-env.outputs.RUST_DEV }}-${{ hashFiles('mix.lock') }}
- name: Generate current openapi.json
run: |
mix openapi.spec.json --start-app=false --spec WandaWeb.Schemas.${{ matrix.version }}.ApiSpec /tmp/specs/current-spec.json
- name: Checkout target branch
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.base.ref || github.ref_name }}
- name: Retrieve Elixir Cached Dependencies - target branch
uses: actions/cache@v5
id: mix-cache-target
with:
path: |
deps
_build/${{ env.MIX_ENV }}
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-rust-${{ needs.setup-matrix-env.outputs.RUST_DEV }}-${{ hashFiles('mix.lock') }}
- name: Generate target openapi.json
run: |
mix openapi.spec.json --start-app=false --spec WandaWeb.Schemas.${{ matrix.version }}.ApiSpec /tmp/specs/target-spec.json
- name: Locate generated specs
run: mv /tmp/specs .
- name: Find difference between OpenAPI specifications
run: |
docker run -v "$(pwd)/specs:/specs" --rm openapitools/openapi-diff:2.0.1 \
/specs/target-spec.json \
/specs/current-spec.json \
--fail-on-incompatible \
--markdown /specs/changes.md \
--text /specs/changes.txt \
--html /specs/changes.html
- name: Upload OpenAPI diff report
uses: actions/upload-artifact@v7
if: failure()
with:
name: openapi-diff-report-${{ matrix.version }}
path: specs/
build-containers:
name: Build containers
needs:
- static-code-analysis
- test
if: (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch'
strategy:
matrix:
include:
- mix_env: prod
tag: "${{ (github.event_name == 'push' && github.ref_name == 'main' && 'rolling') || github.sha }}"
- mix_env: demo
tag: demo
uses: trento-project/.github/.github/workflows/publish-containers.yaml@98e2a3d821253d603d16fd53fb10bcf85f64b395
with:
image_name: trento-wanda
tag: ${{ matrix.tag }}
extra_build_args: |
MIX_ENV=${{ matrix.mix_env }}
secrets:
gh_token: ${{ secrets.TRENTOBOT_GH_PAT }}
ssh_key: ${{ secrets.TRENTOBOT_SSH_KEY }}
deploy-demo:
runs-on: ubuntu-24.04
if: vars.DEPLOY_DEMO == 'true'
needs:
- build-containers
steps:
- name: Remotely trigger trento-web demo deployment
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.WEB_REPO_DISPATCH_PAT }}
repository: ${{ github.repository_owner }}/${{ vars.DEMO_TRIGGER_TARGET || 'web' }}
event-type: deploy-demo
generate-docs:
name: Generate project documentation
runs-on: ubuntu-24.04
if: github.event_name == 'push' && github.ref_name == 'main'
steps:
- uses: actions/checkout@v6
- name: Set up Elixir
id: setup-elixir
uses: erlef/setup-beam@v1
with:
version-file: .tool-versions
version-type: strict
- name: Retrieve Cached Dependencies
uses: actions/cache@v5
id: mix-cache
with:
path: |
deps
_build/test
priv/plts
key: erlang-${{ steps.setup-elixir.outputs.otp-version }}-elixir-${{ steps.setup-elixir.outputs.elixir-version }}-rust-${{ needs.setup-matrix-env.outputs.RUST_DEV }}-${{ hashFiles('mix.lock') }}
- name: Build docs
uses: lee-dohm/generate-elixir-docs@v1
- name: Generate openapi.json
run: mix openapi.spec.json --start-app=false --spec WandaWeb.Schemas.All.ApiSpec
- name: Generate Swagger UI
uses: Legion2/swagger-ui-action@v1
with:
output: ./doc/swaggerui
spec-file: openapi.json
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to Pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doc
obs-sync:
name: OBS sync
if: vars.OBS_ENABLED == 'true' && (github.event_name == 'push' && github.ref_name == 'main') || github.event_name == 'workflow_dispatch'
uses: ./.github/workflows/obs.yaml
needs:
- static-code-analysis
- test
secrets: inherit
with:
obs_project: ${{ vars.OBS_PROJECT_ROLLING }}