-
Notifications
You must be signed in to change notification settings - Fork 18
172 lines (148 loc) · 4.76 KB
/
ci.yml
File metadata and controls
172 lines (148 loc) · 4.76 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
name: CI
on:
pull_request:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
OTP_VERSION: "27.2.1"
ELIXIR_VERSION: "1.18.2"
jobs:
lint:
name: Lint
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read
env:
MIX_ENV: dev
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}
- name: Install Hex/Rebar
run: |
set -euo pipefail
mix local.hex --force
mix local.rebar --force
- name: Restore Hex/Mix cache
uses: actions/cache@v5
with:
path: |
~/.hex
~/.mix
key: ${{ runner.os }}-beamtools-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-beamtools-
- name: Restore dependencies cache
uses: actions/cache@v5
id: deps-cache
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-dev-otp${{ env.OTP_VERSION }}-elixir${{ env.ELIXIR_VERSION }}-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-dev-otp${{ env.OTP_VERSION }}-elixir${{ env.ELIXIR_VERSION }}-
- name: Remove cached rebar3 build artifacts in deps
if: steps.deps-cache.outputs.cache-hit != 'true'
run: |
if [ -d deps ]; then
find deps -maxdepth 6 -type d \( -name _build -o -name .rebar3 \) -prune -exec rm -rf {} + || true
find deps -maxdepth 6 -type f -name rebar3.crashdump -delete || true
fi
- name: Install dependencies
run: mix deps.get
- name: Compile dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: mix deps.compile
- name: Run lint checks
run: mix format --check-formatted && mix compile --warnings-as-errors && mix credo --min-priority higher
- name: Check for unused dependencies
run: mix deps.unlock --check-unused
- name: Audit Hex dependencies
run: mix hex.audit
test:
name: Test
runs-on: ubuntu-24.04
timeout-minutes: 15
permissions:
contents: read
env:
MIX_ENV: test
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
services:
postgres:
image: pgvector/pgvector:pg16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: test_db
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U postgres -d test_db"
--health-interval 5s
--health-timeout 3s
--health-retries 20
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Elixir
uses: erlef/setup-beam@v1
with:
otp-version: ${{ env.OTP_VERSION }}
elixir-version: ${{ env.ELIXIR_VERSION }}
- name: Install Hex/Rebar
run: |
set -euo pipefail
mix local.hex --force
mix local.rebar --force
- name: Restore Hex/Mix cache
uses: actions/cache@v5
with:
path: |
~/.hex
~/.mix
key: ${{ runner.os }}-beamtools-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-beamtools-
- name: Restore dependencies cache
uses: actions/cache@v5
id: deps-cache
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-test-otp${{ env.OTP_VERSION }}-elixir${{ env.ELIXIR_VERSION }}-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-mix-test-otp${{ env.OTP_VERSION }}-elixir${{ env.ELIXIR_VERSION }}-
- name: Remove cached rebar3 build artifacts in deps
if: steps.deps-cache.outputs.cache-hit != 'true'
run: |
if [ -d deps ]; then
find deps -maxdepth 6 -type d \( -name _build -o -name .rebar3 \) -prune -exec rm -rf {} + || true
find deps -maxdepth 6 -type f -name rebar3.crashdump -delete || true
fi
- name: Install dependencies
run: mix deps.get
- name: Compile dependencies
if: steps.deps-cache.outputs.cache-hit != 'true'
run: mix deps.compile
- name: Setup database
run: mix ecto.setup
env:
DATABASE_URL: postgres://${{ env.POSTGRES_USER }}:${{ env.POSTGRES_PASSWORD }}@${{ env.POSTGRES_HOST }}:${{ env.POSTGRES_PORT }}/${{ env.POSTGRES_DB }}
- name: Run tests
run: mix test