forked from aaronrenner/zone-meal-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
218 lines (204 loc) · 5.45 KB
/
.gitlab-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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
image: registry.gitlab.com/aaronrenner/docker-asdf:alpine
variables:
LANG: C.UTF-8
MIX_HOME: "$CI_PROJECT_DIR/.mix"
ASDF_DATA_DIR: "$CI_PROJECT_DIR/.asdf"
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_HOST: postgres
stages:
- install
- build
- test
before_script:
- . ~/.asdf/asdf.sh
# Ensure the timestamp doesn't change from when the repo was
# originally checked out, so we don't have to recompile for each job.
- |
if [ -f ".cloned_at" ]; then
git ls-files | xargs touch --date "$(cat .cloned_at)";
fi
install_asdf_env_and_deps:
image: registry.gitlab.com/aaronrenner/docker-asdf:bionic
stage: install
variables:
NODEJS_CHECK_SIGNATURES: "no"
cache:
key: install
paths:
- $ASDF_DATA_DIR
- $MIX_HOME
script:
- asdf plugin-add erlang || true
- asdf plugin-add elixir || true
- asdf plugin-add nodejs || true
# Have to run twice due to: https://github.com/asdf-vm/asdf-erlang/issues/57
- asdf install && asdf install
# Setting up elixir and erlang
- mix local.hex --force
- mix local.rebar --force
# Cache the timestamp the repo was originally checked out, so it can
# be set back to this in later jobs and allows us to skip unnecessary
# recompiles.
- date "+%Y-%m-%d %H:%M:%S" -r README.md > .cloned_at
artifacts:
expire_in: 2 hrs
paths:
- $ASDF_DATA_DIR
- $MIX_HOME
- .cloned_at
install_asdf_env_and_deps_alpine:
stage: install
image: registry.gitlab.com/aaronrenner/docker-asdf:alpine
variables:
NODEJS_CHECK_SIGNATURES: "no"
BUILD_CACHE_VERSION: 1
cache:
key: install-alpine-$BUILD_CACHE_VERSION
paths:
- $ASDF_DATA_DIR
- $MIX_HOME
script:
- asdf plugin-add erlang || true
- asdf plugin-add elixir || true
- asdf plugin-add nodejs || true
# Have to run twice due to: https://github.com/asdf-vm/asdf-erlang/issues/57
- asdf install && asdf install
# Setting up elixir and erlang
- mix local.hex --force
- mix local.rebar --force
# Cache the timestamp the repo was originally checked out, so it can
# be set back to this in later jobs and allows us to skip unnecessary
# recompiles.
- date "+%Y-%m-%d %H:%M:%S" -r README.md > .cloned_at
artifacts:
expire_in: 2 hrs
paths:
- $ASDF_DATA_DIR
- $MIX_HOME
- .cloned_at
.build:
stage: build
variables:
BUILD_CACHE_VERSION: 1
cache:
key: $CI_JOB_NAME-$BUILD_CACHE_VERSION
paths:
- "_build"
- "deps"
script:
- mix do deps.get, compile --warnings-as-errors
dependencies:
- install_asdf_env_and_deps_alpine
artifacts:
expire_in: 2 hrs
paths:
- "_build"
- "deps"
build:dev:
extends: .build
build:test:
extends: .build
variables:
MIX_ENV: test
build:integration_tester:
stage: build
image: registry.gitlab.com/aaronrenner/docker-asdf:bionic
cache:
key: $CI_JOB_NAME
paths:
- "integration_tester/_build"
- "integration_tester/deps"
variables:
MIX_ENV: test
dependencies:
- install_asdf_env_and_deps
script:
- |
pushd apps/zone_meal_tracker_web/assets && \
npm install && \
popd
- |
pushd apps/zone_meal_tracker_web && \
mix deps.get && \
npm run deploy --prefix ./assets && \
popd
- |
pushd integration_tester && \
mix do deps.get, compile --warnings-as-errors && \
popd
dependencies:
- install_asdf_env_and_deps
artifacts:
expire_in: 2 hrs
paths:
- "integration_tester/_build"
- "integration_tester/deps"
- "apps/zone_meal_tracker_web/priv/static"
unit_tests:
stage: test
script: mix test
services:
- postgres:11.5-alpine
dependencies:
- install_asdf_env_and_deps_alpine
- build:test
integration_tests:
stage: test
image: registry.gitlab.com/aaronrenner/docker-asdf:bionic
script:
- |
mkdir /tmp/chromedriver && \
pushd /tmp/chromedriver && \
curl -O https://chromedriver.storage.googleapis.com/77.0.3865.40/chromedriver_linux64.zip && \
unzip chromedriver_linux64.zip && \
mv chromedriver /usr/local/bin &&
popd
- |
pushd /tmp && \
curl -O https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb && \
apt-get update && \
(dpkg -i google-chrome-stable_current_amd64.deb || true) && \
apt-get -f -y install && \
popd
- cd integration_tester
- MIX_ENV=test mix test
services:
- postgres:11.5-alpine
dependencies:
- install_asdf_env_and_deps
- build:integration_tester
integration_test_linters:
stage: test
script:
- cd integration_tester
- mix format --check-formatted
# Check for unused dependencies
- mix deps.unlock --unused && git diff --exit-code
dependencies:
- install_asdf_env_and_deps_alpine
- build:integration_tester
linters:
stage: test
script:
- mix format --check-formatted
- mix credo --strict
# Check for unused dependencies
- mix deps.unlock --unused && git diff --exit-code
dependencies:
- install_asdf_env_and_deps_alpine
- build:dev
dialyzer:
stage: test
variables:
DIALYZER_CACHE_VERSION: 1
script: mix dialyzer --format short
cache:
key: $CI_JOB_NAME-$DIALYZER_CACHE_VERSION
paths:
- "_build/dev/*.plt"
- "_build/dev/*.plt.hash"
- $MIX_HOME/*.plt
dependencies:
- install_asdf_env_and_deps_alpine
- build:dev