improve changelog entry
[akkoma] / .gitlab-ci.yml
1 image: elixir:1.9.4
2
3 variables: &global_variables
4 POSTGRES_DB: pleroma_test
5 POSTGRES_USER: postgres
6 POSTGRES_PASSWORD: postgres
7 DB_HOST: postgres
8 MIX_ENV: test
9
10 cache: &global_cache_policy
11 key:
12 files:
13 - mix.lock
14 paths:
15 - deps
16 - _build
17
18 stages:
19 - build
20 - test
21 - benchmark
22 - deploy
23 - release
24 - docker
25
26 before_script:
27 - echo $MIX_ENV
28 - rm -rf _build/*/lib/pleroma
29 - apt-get update && apt-get install -y cmake
30 - mix local.hex --force
31 - mix local.rebar --force
32 - mix deps.get
33 - apt-get -qq update
34 - apt-get install -y libmagic-dev
35
36 after_script:
37 - rm -rf _build/*/lib/pleroma
38
39 build:
40 stage: build
41 only:
42 changes:
43 - "**/*.ex"
44 - "**/*.exs"
45 - "mix.lock"
46 script:
47 - mix compile --force
48
49 spec-build:
50 stage: test
51 only:
52 changes:
53 - "lib/pleroma/web/api_spec/**/*.ex"
54 - "lib/pleroma/web/api_spec.ex"
55 artifacts:
56 paths:
57 - spec.json
58 script:
59 - mix pleroma.openapi_spec spec.json
60
61 benchmark:
62 stage: benchmark
63 when: manual
64 variables:
65 MIX_ENV: benchmark
66 services:
67 - name: postgres:9.6
68 alias: postgres
69 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
70 script:
71 - mix ecto.create
72 - mix ecto.migrate
73 - mix pleroma.load_testing
74
75 unit-testing:
76 stage: test
77 only:
78 changes:
79 - "**/*.ex"
80 - "**/*.exs"
81 - "mix.lock"
82 retry: 2
83 cache: &testing_cache_policy
84 <<: *global_cache_policy
85 policy: pull
86
87 services:
88 - name: postgres:13
89 alias: postgres
90 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
91 script:
92 - apt-get update && apt-get install -y libimage-exiftool-perl ffmpeg
93 - mix ecto.create
94 - mix ecto.migrate
95 - mix coveralls --preload-modules
96
97 # Removed to fix CI issue. In this early state it wasn't adding much value anyway.
98 # TODO Fix and reinstate federated testing
99 # federated-testing:
100 # stage: test
101 # cache: *testing_cache_policy
102 # services:
103 # - name: minibikini/postgres-with-rum:12
104 # alias: postgres
105 # command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
106 # script:
107 # - mix deps.get
108 # - mix ecto.create
109 # - mix ecto.migrate
110 # - epmd -daemon
111 # - mix test --trace --only federated
112
113 unit-testing-rum:
114 stage: test
115 only:
116 changes:
117 - "**/*.ex"
118 - "**/*.exs"
119 - "mix.lock"
120 retry: 2
121 cache: *testing_cache_policy
122 services:
123 - name: minibikini/postgres-with-rum:12
124 alias: postgres
125 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
126 variables:
127 <<: *global_variables
128 RUM_ENABLED: "true"
129 script:
130 - apt-get update && apt-get install -y libimage-exiftool-perl ffmpeg
131 - mix ecto.create
132 - mix ecto.migrate
133 - "mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
134 - mix test --preload-modules
135
136 lint:
137 stage: test
138 only:
139 changes:
140 - "**/*.ex"
141 - "**/*.exs"
142 - "mix.lock"
143 cache: *testing_cache_policy
144 script:
145 - mix format --check-formatted
146
147 analysis:
148 stage: test
149 only:
150 changes:
151 - "**/*.ex"
152 - "**/*.exs"
153 - "mix.lock"
154 cache: *testing_cache_policy
155 script:
156 - mix credo --strict --only=warnings,todo,fixme,consistency,readability
157
158 cycles:
159 stage: test
160 image: elixir:1.11
161 only:
162 changes:
163 - "**/*.ex"
164 - "**/*.exs"
165 - "mix.lock"
166 cache: {}
167 script:
168 - mix deps.get
169 - mix compile
170 - mix xref graph --format cycles --label compile | awk '{print $0} END{exit ($0 != "No cycles found")}'
171
172 docs-deploy:
173 stage: deploy
174 cache: *testing_cache_policy
175 image: alpine:latest
176 only:
177 - stable@pleroma/pleroma
178 - develop@pleroma/pleroma
179 before_script:
180 - apk add curl
181 script:
182 - curl -X POST -F"token=$DOCS_PIPELINE_TRIGGER" -F'ref=master' -F"variables[BRANCH]=$CI_COMMIT_REF_NAME" https://git.pleroma.social/api/v4/projects/673/trigger/pipeline
183 review_app:
184 image: alpine:3.9
185 stage: deploy
186 before_script:
187 - apk update && apk add openssh-client git
188 when: manual
189 environment:
190 name: review/$CI_COMMIT_REF_NAME
191 url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
192 on_stop: stop_review_app
193 only:
194 - branches
195 except:
196 - master
197 - develop
198 script:
199 - echo "$CI_ENVIRONMENT_SLUG"
200 - mkdir -p ~/.ssh
201 - eval $(ssh-agent -s)
202 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
203 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
204 - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
205 - (ssh -t dokku@pleroma.online -- git:set "$CI_ENVIRONMENT_SLUG" keep-git-dir true) || true
206 - ssh -t dokku@pleroma.online -- config:set "$CI_ENVIRONMENT_SLUG" APP_NAME="$CI_ENVIRONMENT_SLUG" APP_HOST="$CI_ENVIRONMENT_SLUG.pleroma.online" MIX_ENV=dokku
207 - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
208 - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
209 - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
210 - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
211
212 spec-deploy:
213 stage: deploy
214 artifacts:
215 paths:
216 - spec.json
217 only:
218 - develop@pleroma/pleroma
219 image: alpine:latest
220 before_script:
221 - apk add curl
222 script:
223 - curl -X POST -F"token=$API_DOCS_PIPELINE_TRIGGER" -F'ref=master' -F"variables[BRANCH]=$CI_COMMIT_REF_NAME" -F"variables[JOB_REF]=$CI_JOB_ID" https://git.pleroma.social/api/v4/projects/1130/trigger/pipeline
224
225
226 stop_review_app:
227 image: alpine:3.9
228 stage: deploy
229 before_script:
230 - apk update && apk add openssh-client git
231 when: manual
232 environment:
233 name: review/$CI_COMMIT_REF_NAME
234 action: stop
235 script:
236 - echo "$CI_ENVIRONMENT_SLUG"
237 - mkdir -p ~/.ssh
238 - eval $(ssh-agent -s)
239 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
240 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
241 - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
242 - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
243
244 amd64:
245 stage: release
246 image: elixir:1.10.3
247 only: &release-only
248 - stable@pleroma/pleroma
249 - develop@pleroma/pleroma
250 - /^maint/.*$/@pleroma/pleroma
251 - /^release/.*$/@pleroma/pleroma
252 artifacts: &release-artifacts
253 name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
254 paths:
255 - release/*
256 # Ideally it would be never for master branch and with the next commit for develop,
257 # but Gitlab does not support neither `only` for artifacts
258 # nor setting it to never from .gitlab-ci.yml
259 # nor expiring with the next commit
260 expire_in: 42 yrs
261
262 cache: &release-cache
263 key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
264 paths:
265 - deps
266 variables: &release-variables
267 MIX_ENV: prod
268 before_script: &before-release
269 - apt-get update && apt-get install -y cmake libmagic-dev
270 - echo "import Mix.Config" > config/prod.secret.exs
271 - mix local.hex --force
272 - mix local.rebar --force
273 script: &release
274 - mix deps.get --only prod
275 - mkdir release
276 - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
277 - mix release --path release
278
279
280 amd64-musl:
281 stage: release
282 artifacts: *release-artifacts
283 only: *release-only
284 image: elixir:1.10.3-alpine
285 cache: *release-cache
286 variables: *release-variables
287 before_script: &before-release-musl
288 - apk add git gcc g++ musl-dev make cmake file-dev
289 - echo "import Mix.Config" > config/prod.secret.exs
290 - mix local.hex --force
291 - mix local.rebar --force
292 script: *release
293
294 arm:
295 stage: release
296 artifacts: *release-artifacts
297 only: *release-only
298 tags:
299 - arm32-specified
300 image: arm32v7/elixir:1.10.3
301 cache: *release-cache
302 variables: *release-variables
303 before_script: *before-release
304 script: *release
305
306 arm-musl:
307 stage: release
308 artifacts: *release-artifacts
309 only: *release-only
310 tags:
311 - arm32-specified
312 image: arm32v7/elixir:1.10.3-alpine
313 cache: *release-cache
314 variables: *release-variables
315 before_script: *before-release-musl
316 script: *release
317
318 arm64:
319 stage: release
320 artifacts: *release-artifacts
321 only: *release-only
322 tags:
323 - arm
324 image: arm64v8/elixir:1.10.3
325 cache: *release-cache
326 variables: *release-variables
327 before_script: *before-release
328 script: *release
329
330 arm64-musl:
331 stage: release
332 artifacts: *release-artifacts
333 only: *release-only
334 tags:
335 - arm
336 image: arm64v8/elixir:1.10.3-alpine
337 cache: *release-cache
338 variables: *release-variables
339 before_script: *before-release-musl
340 script: *release
341
342 docker:
343 stage: docker
344 image: docker:latest
345 cache: {}
346 dependencies: []
347 variables: &docker-variables
348 DOCKER_DRIVER: overlay2
349 DOCKER_HOST: unix:///var/run/docker.sock
350 IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
351 IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
352 IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
353 IMAGE_TAG_LATEST_STABLE: $CI_REGISTRY_IMAGE:latest-stable
354 DOCKER_BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64
355 DOCKER_BUILDX_HASH: 71a7d01439aa8c165a25b59c44d3f016fddbd98b
356 before_script: &before-docker
357 - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
358 - docker pull $IMAGE_TAG_SLUG || true
359 - export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
360 - export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
361 allow_failure: true
362 script:
363 - mkdir -p /root/.docker/cli-plugins
364 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
365 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
366 - chmod +x ~/.docker/cli-plugins/docker-buildx
367 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
368 - docker buildx create --name mbuilder --driver docker-container --use
369 - docker buildx inspect --bootstrap
370 - docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64/v8 --push --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST .
371 tags:
372 - dind
373 only:
374 - develop@pleroma/pleroma
375
376 docker-stable:
377 stage: docker
378 image: docker:latest
379 cache: {}
380 dependencies: []
381 variables: *docker-variables
382 before_script: *before-docker
383 allow_failure: true
384 script:
385 - mkdir -p /root/.docker/cli-plugins
386 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
387 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
388 - chmod +x ~/.docker/cli-plugins/docker-buildx
389 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
390 - docker buildx create --name mbuilder --driver docker-container --use
391 - docker buildx inspect --bootstrap
392 - docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64/v8 --push --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG -t $IMAGE_TAG_LATEST_STABLE .
393 tags:
394 - dind
395 only:
396 - stable@pleroma/pleroma
397
398 docker-release:
399 stage: docker
400 image: docker:latest
401 cache: {}
402 dependencies: []
403 variables: *docker-variables
404 before_script: *before-docker
405 allow_failure: true
406 script:
407 script:
408 - mkdir -p /root/.docker/cli-plugins
409 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
410 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
411 - chmod +x ~/.docker/cli-plugins/docker-buildx
412 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
413 - docker buildx create --name mbuilder --driver docker-container --use
414 - docker buildx inspect --bootstrap
415 - docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64/v8 --push --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG .
416 tags:
417 - dind
418 only:
419 - /^release/.*$/@pleroma/pleroma
420
421 docker-adhoc:
422 stage: docker
423 image: docker:latest
424 cache: {}
425 dependencies: []
426 variables: *docker-variables
427 before_script: *before-docker
428 allow_failure: true
429 script:
430 script:
431 - mkdir -p /root/.docker/cli-plugins
432 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
433 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
434 - chmod +x ~/.docker/cli-plugins/docker-buildx
435 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
436 - docker buildx create --name mbuilder --driver docker-container --use
437 - docker buildx inspect --bootstrap
438 - docker buildx build --platform linux/amd64,linux/arm/v7,linux/arm64/v8 --push --cache-from $IMAGE_TAG_SLUG --build-arg VCS_REF=$CI_VCS_REF --build-arg BUILD_DATE=$CI_JOB_TIMESTAMP -t $IMAGE_TAG -t $IMAGE_TAG_SLUG .
439 tags:
440 - dind
441 only:
442 - /^build-docker/.*$/@pleroma/pleroma