-
Notifications
You must be signed in to change notification settings - Fork 1
188 lines (149 loc) · 4.85 KB
/
Copy pathci.yml
File metadata and controls
188 lines (149 loc) · 4.85 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
MIX_ENV: test
ELIXIR_VERSION: "1.19.5"
OTP_VERSION: "28.4.1"
NODE_VERSION: "24"
jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:17
env:
POSTGRES_PASSWORD: postgres
POSTGRES_DB: aludel_test
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Validate Docker Compose security defaults
run: |
cp .env.example .env
if docker compose config --quiet 2>/dev/null; then
echo "Docker Compose accepted a blank database password"
exit 1
fi
POSTGRES_PASSWORD=ci-only-password docker compose config --quiet
- name: Setup Elixir
uses: ./.github/actions/setup-elixir
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
- name: Setup Node.js
uses: ./.github/actions/setup-node
with:
node-version: ${{ env.NODE_VERSION }}
- name: Check formatting
run: mix format --check-formatted
- name: Compile (test)
run: mix compile --warnings-as-errors
- name: Build assets
run: mix assets.build
- name: Run frontend tests
working-directory: assets
run: npm test
- name: Create and migrate database
run: mix ecto.create && mix ecto.migrate
- name: Run tests with coverage
run: mix coveralls.json
- name: Test standalone application
working-directory: standalone
run: mix deps.get && mix compile --warnings-as-errors && mix test --no-start
# Only upload coverage when the PR can access repository secrets.
# Dependabot and fork PRs should not fail CI on the upload step.
- name: Upload coverage to Codecov
if: github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]')
uses: codecov/codecov-action@v7
with:
files: ./cover/excoveralls.json
flags: elixir
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
credo:
name: Code Quality (Credo)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Elixir
uses: ./.github/actions/setup-elixir
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
- name: Compile (dev)
run: MIX_ENV=dev mix compile
- name: Run Credo
run: mix credo --strict
quality-gates:
name: Package Quality Gates
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Elixir
uses: ./.github/actions/setup-elixir
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
- name: Check compile dependency cycles
run: mix xref graph --format cycles --label compile-connected --fail-above 0
- name: Check duplicate code budget
run: mix quality.ex_dna
- name: Check documentation coverage
run: mix doctor --raise
- name: Build documentation
env:
MIX_ENV: dev
run: mix docs
dialyzer:
name: Static Analysis (Dialyzer)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Elixir
uses: ./.github/actions/setup-elixir
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
- name: Restore PLT cache
uses: actions/cache@v6
with:
path: priv/plts
key: ${{ runner.os }}-dialyzer-v2-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-${{ hashFiles('**/mix.lock') }}
restore-keys: |
${{ runner.os }}-dialyzer-v2-${{ env.OTP_VERSION }}-${{ env.ELIXIR_VERSION }}-
- name: Compile (dev)
run: MIX_ENV=dev mix compile
- name: Run Dialyzer
run: mix dialyzer
unused-deps:
name: Check Unused Dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Elixir
uses: ./.github/actions/setup-elixir
with:
elixir-version: ${{ env.ELIXIR_VERSION }}
otp-version: ${{ env.OTP_VERSION }}
- name: Check for unused dependencies
run: mix deps.unlock --check-unused