3 variables: &global_variables
4 POSTGRES_DB: pleroma_test
5 POSTGRES_USER: postgres
6 POSTGRES_PASSWORD: postgres
10 cache: &global_cache_policy
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
34 - apt-get install -y libmagic-dev
37 - rm -rf _build/*/lib/pleroma
53 - "lib/pleroma/web/api_spec/**/*.ex"
54 - "lib/pleroma/web/api_spec.ex"
59 - mix pleroma.openapi_spec spec.json
69 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
73 - mix pleroma.load_testing
83 cache: &testing_cache_policy
84 <<: *global_cache_policy
90 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
92 - apt-get update && apt-get install -y libimage-exiftool-perl ffmpeg
95 - mix coveralls --preload-modules
97 # Removed to fix CI issue. In this early state it wasn't adding much value anyway.
98 # TODO Fix and reinstate federated testing
101 # cache: *testing_cache_policy
103 # - name: minibikini/postgres-with-rum:12
105 # command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
111 # - mix test --trace --only federated
121 cache: *testing_cache_policy
123 - name: minibikini/postgres-with-rum:12
125 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
127 <<: *global_variables
130 - apt-get update && apt-get install -y libimage-exiftool-perl ffmpeg
133 - "mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
134 - mix test --preload-modules
143 cache: *testing_cache_policy
145 - mix format --check-formatted
154 cache: *testing_cache_policy
156 - mix credo --strict --only=warnings,todo,fixme,consistency,readability
165 - mix xref graph --format cycles --label compile | awk '{print $0} END{exit ($0 != "No cycles found")}'
169 cache: *testing_cache_policy
172 - stable@pleroma/pleroma
173 - develop@pleroma/pleroma
177 - 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
182 - apk update && apk add openssh-client git
185 name: review/$CI_COMMIT_REF_NAME
186 url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
187 on_stop: stop_review_app
194 - echo "$CI_ENVIRONMENT_SLUG"
196 - eval $(ssh-agent -s)
197 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
198 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
199 - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
200 - (ssh -t dokku@pleroma.online -- git:set "$CI_ENVIRONMENT_SLUG" keep-git-dir true) || true
201 - 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
202 - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
203 - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
204 - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
205 - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
213 - develop@pleroma/pleroma
218 - 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
225 - apk update && apk add openssh-client git
228 name: review/$CI_COMMIT_REF_NAME
231 - echo "$CI_ENVIRONMENT_SLUG"
233 - eval $(ssh-agent -s)
234 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
235 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
236 - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
237 - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
243 - stable@pleroma/pleroma
244 - develop@pleroma/pleroma
245 - /^maint/.*$/@pleroma/pleroma
246 - /^release/.*$/@pleroma/pleroma
247 artifacts: &release-artifacts
248 name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
251 # Ideally it would be never for master branch and with the next commit for develop,
252 # but Gitlab does not support neither `only` for artifacts
253 # nor setting it to never from .gitlab-ci.yml
254 # nor expiring with the next commit
257 cache: &release-cache
258 key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
261 variables: &release-variables
263 before_script: &before-release
264 - apt-get update && apt-get install -y cmake libmagic-dev
265 - echo "import Mix.Config" > config/prod.secret.exs
266 - mix local.hex --force
267 - mix local.rebar --force
269 - mix deps.get --only prod
271 - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
272 - mix release --path release
277 artifacts: *release-artifacts
279 image: elixir:1.10.3-alpine
280 cache: *release-cache
281 variables: *release-variables
282 before_script: &before-release-musl
283 - apk add git gcc g++ musl-dev make cmake file-dev
284 - echo "import Mix.Config" > config/prod.secret.exs
285 - mix local.hex --force
286 - mix local.rebar --force
291 artifacts: *release-artifacts
295 image: arm32v7/elixir:1.10.3
296 cache: *release-cache
297 variables: *release-variables
298 before_script: *before-release
303 artifacts: *release-artifacts
307 image: arm32v7/elixir:1.10.3-alpine
308 cache: *release-cache
309 variables: *release-variables
310 before_script: *before-release-musl
315 artifacts: *release-artifacts
319 image: arm64v8/elixir:1.10.3
320 cache: *release-cache
321 variables: *release-variables
322 before_script: *before-release
327 artifacts: *release-artifacts
331 image: arm64v8/elixir:1.10.3-alpine
332 cache: *release-cache
333 variables: *release-variables
334 before_script: *before-release-musl
342 variables: &docker-variables
343 DOCKER_DRIVER: overlay2
344 DOCKER_HOST: unix:///var/run/docker.sock
345 IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
346 IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
347 IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
348 IMAGE_TAG_LATEST_STABLE: $CI_REGISTRY_IMAGE:latest-stable
349 DOCKER_BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64
350 DOCKER_BUILDX_HASH: 71a7d01439aa8c165a25b59c44d3f016fddbd98b
351 before_script: &before-docker
352 - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
353 - docker pull $IMAGE_TAG_SLUG || true
354 - export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
355 - export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
358 - mkdir -p /root/.docker/cli-plugins
359 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
360 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
361 - chmod +x ~/.docker/cli-plugins/docker-buildx
362 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
363 - docker buildx create --name mbuilder --driver docker-container --use
364 - docker buildx inspect --bootstrap
365 - 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 .
369 - develop@pleroma/pleroma
376 variables: *docker-variables
377 before_script: *before-docker
380 - mkdir -p /root/.docker/cli-plugins
381 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
382 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
383 - chmod +x ~/.docker/cli-plugins/docker-buildx
384 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
385 - docker buildx create --name mbuilder --driver docker-container --use
386 - docker buildx inspect --bootstrap
387 - 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 .
391 - stable@pleroma/pleroma
398 variables: *docker-variables
399 before_script: *before-docker
403 - mkdir -p /root/.docker/cli-plugins
404 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
405 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
406 - chmod +x ~/.docker/cli-plugins/docker-buildx
407 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
408 - docker buildx create --name mbuilder --driver docker-container --use
409 - docker buildx inspect --bootstrap
410 - 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 .
414 - /^release/.*$/@pleroma/pleroma
421 variables: *docker-variables
422 before_script: *before-docker
426 - mkdir -p /root/.docker/cli-plugins
427 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
428 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
429 - chmod +x ~/.docker/cli-plugins/docker-buildx
430 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
431 - docker buildx create --name mbuilder --driver docker-container --use
432 - docker buildx inspect --bootstrap
433 - 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 .
437 - /^build-docker/.*$/@pleroma/pleroma