-
Notifications
You must be signed in to change notification settings - Fork 1
198 lines (157 loc) · 5.11 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
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
name: Docker Image CI
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
NODE_VERSION: "18.12.1"
OTP_VERSION: "26.2.1"
ELIXIR_VERSION: "1.15.7"
jobs:
build_deps:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install node and elixir
uses: ./.github/actions/setup-composite-action
with:
node-version: ${{env.NODE_VERSION}}
otp-version: ${{env.OTP_VERSION}}
elixir-version: ${{env.ELIXIR_VERSION}}
- uses: actions/cache@v3
id: cache-mix
with:
path: deps
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-v1
- uses: actions/cache@v3
id: cache-npm
with:
path: frontend/node_modules
key: ${{ runner.os }}-npm-v1-${{ hashFiles('**/frontend/package-lock.json') }}
restore-keys: ${{ runner.os }}-npm-v1
wordcharts-frontend-lint:
runs-on: ubuntu-latest
needs: build_deps
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache-npm
with:
path: deps
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-npm-v1
- uses: actions/setup-node@v3
with:
node-version: ${{env.NODE_VERSION}}
- run: npm --prefix frontend ci
- run: npm --prefix frontend run lint
wordcharts-frontend-check-types:
runs-on: ubuntu-latest
needs: build_deps
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache-npm
with:
path: deps
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-npm-v1
- uses: actions/setup-node@v3
with:
node-version: ${{env.NODE_VERSION}}
- run: npm --prefix frontend ci
- run: npm --prefix frontend run check-types
wordcharts-frontend-test:
runs-on: ubuntu-latest
needs: build_deps
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache-npm
with:
path: deps
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-npm-v1
- uses: actions/setup-node@v3
with:
node-version: ${{env.NODE_VERSION}}
- run: npm --prefix frontend ci
- run: npm --prefix frontend run test
wordcharts-backend-lint:
runs-on: ubuntu-latest
needs: build_deps
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
id: cache-mix
with:
path: deps
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-v1
- uses: erlef/setup-beam@v1
with:
otp-version: ${{env.OTP_VERSION}}
elixir-version: ${{env.ELIXIR_VERSION}}
- run: mix format
# See https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers
wordcharts-backend-test:
runs-on: ubuntu-latest
needs: build_deps
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
image: postgres:latest
env:
# These env variables are required by the postgres service (see above)
POSTGRES_DB: wordcharts_test
POSTGRES_HOST: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
ports:
- 5432:5432
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
env:
# These env vars are required by our application
# Unfortunately, github workflow does not support yaml anchors ;-(
TEST_DATABASE_HOST: localhost
TEST_DATABASE_NAME: wordcharts_test
TEST_DATABASE_USER: postgres
TEST_DATABASE_USER_PASSWORD: postgres
MIX_ENV: "test"
steps:
# Downloads a copy of the code in your repository before running CI tests
- uses: actions/checkout@v3
- name: Install node and elixir
uses: ./.github/actions/setup-composite-action
with:
node-version: ${{env.NODE_VERSION}}
otp-version: ${{env.OTP_VERSION}}
elixir-version: ${{env.ELIXIR_VERSION}}
- uses: actions/cache@v3
id: cache-mix
with:
path: deps
key: ${{ runner.os }}-mix-v1-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-v1
- uses: actions/cache@v3
id: cache-npm
with:
path: frontend/node_modules
key: ${{ runner.os }}-npm-v1-${{ hashFiles('**/frontend/package-lock.json') }}
restore-keys: ${{ runner.os }}-npm-v1
# install hex:
- run: mix local.hex --force && mix local.rebar --force
- run: mix compile
- run: mix ecto.create
- run: mix ecto.migrate
- run: mix test