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
144 cache: *testing_cache_policy
146 - mix format --check-formatted
155 cache: *testing_cache_policy
157 - mix credo --strict --only=warnings,todo,fixme,consistency,readability
171 - mix xref graph --format cycles --label compile | awk '{print $0} END{exit ($0 != "No cycles found")}'
175 cache: *testing_cache_policy
178 - stable@pleroma/pleroma
179 - develop@pleroma/pleroma
183 - 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
188 - apk update && apk add openssh-client git
191 name: review/$CI_COMMIT_REF_NAME
192 url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
193 on_stop: stop_review_app
200 - echo "$CI_ENVIRONMENT_SLUG"
202 - eval $(ssh-agent -s)
203 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
204 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
205 - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
206 - (ssh -t dokku@pleroma.online -- git:set "$CI_ENVIRONMENT_SLUG" keep-git-dir true) || true
207 - 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
208 - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
209 - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
210 - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
211 - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
219 - develop@pleroma/pleroma
224 - 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
231 - apk update && apk add openssh-client git
234 name: review/$CI_COMMIT_REF_NAME
237 - echo "$CI_ENVIRONMENT_SLUG"
239 - eval $(ssh-agent -s)
240 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
241 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
242 - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
243 - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
249 - stable@pleroma/pleroma
250 - develop@pleroma/pleroma
251 - /^maint/.*$/@pleroma/pleroma
252 - /^release/.*$/@pleroma/pleroma
253 artifacts: &release-artifacts
254 name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
257 # Ideally it would be never for master branch and with the next commit for develop,
258 # but Gitlab does not support neither `only` for artifacts
259 # nor setting it to never from .gitlab-ci.yml
260 # nor expiring with the next commit
263 cache: &release-cache
264 key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
267 variables: &release-variables
269 before_script: &before-release
270 - apt-get update && apt-get install -y cmake libmagic-dev
271 - echo "import Mix.Config" > config/prod.secret.exs
272 - mix local.hex --force
273 - mix local.rebar --force
275 - mix deps.get --only prod
277 - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
278 - mix release --path release
283 artifacts: *release-artifacts
285 image: elixir:1.10.3-alpine
286 cache: *release-cache
287 variables: *release-variables
288 before_script: &before-release-musl
289 - apk add git gcc g++ musl-dev make cmake file-dev
290 - echo "import Mix.Config" > config/prod.secret.exs
291 - mix local.hex --force
292 - mix local.rebar --force
297 artifacts: *release-artifacts
301 image: arm32v7/elixir:1.10.3
302 cache: *release-cache
303 variables: *release-variables
304 before_script: *before-release
309 artifacts: *release-artifacts
313 image: arm32v7/elixir:1.10.3-alpine
314 cache: *release-cache
315 variables: *release-variables
316 before_script: *before-release-musl
321 artifacts: *release-artifacts
325 image: arm64v8/elixir:1.10.3
326 cache: *release-cache
327 variables: *release-variables
328 before_script: *before-release
333 artifacts: *release-artifacts
337 image: arm64v8/elixir:1.10.3-alpine
338 cache: *release-cache
339 variables: *release-variables
340 before_script: *before-release-musl
348 variables: &docker-variables
349 DOCKER_DRIVER: overlay2
350 DOCKER_HOST: unix:///var/run/docker.sock
351 IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
352 IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
353 IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
354 IMAGE_TAG_LATEST_STABLE: $CI_REGISTRY_IMAGE:latest-stable
355 DOCKER_BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.6.3/buildx-v0.6.3.linux-amd64
356 DOCKER_BUILDX_HASH: 980e6b9655f971991fbbb5fd6cd19f1672386195
357 before_script: &before-docker
358 - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
359 - docker pull $IMAGE_TAG_SLUG || true
360 - export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
361 - export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
364 - mkdir -p /root/.docker/cli-plugins
365 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
366 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
367 - chmod +x ~/.docker/cli-plugins/docker-buildx
368 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
369 - docker buildx create --name mbuilder --driver docker-container --use
370 - docker buildx inspect --bootstrap
371 - 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 .
375 - develop@pleroma/pleroma
382 variables: *docker-variables
383 before_script: *before-docker
386 - mkdir -p /root/.docker/cli-plugins
387 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
388 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
389 - chmod +x ~/.docker/cli-plugins/docker-buildx
390 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
391 - docker buildx create --name mbuilder --driver docker-container --use
392 - docker buildx inspect --bootstrap
393 - 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 .
397 - stable@pleroma/pleroma
404 variables: *docker-variables
405 before_script: *before-docker
409 - mkdir -p /root/.docker/cli-plugins
410 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
411 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
412 - chmod +x ~/.docker/cli-plugins/docker-buildx
413 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
414 - docker buildx create --name mbuilder --driver docker-container --use
415 - docker buildx inspect --bootstrap
416 - 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 .
420 - /^release/.*$/@pleroma/pleroma
427 variables: *docker-variables
428 before_script: *before-docker
432 - mkdir -p /root/.docker/cli-plugins
433 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
434 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
435 - chmod +x ~/.docker/cli-plugins/docker-buildx
436 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
437 - docker buildx create --name mbuilder --driver docker-container --use
438 - docker buildx inspect --bootstrap
439 - 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 .
443 - /^build-docker/.*$/@pleroma/pleroma