1 image: git.pleroma.social:5050/pleroma/pleroma/ci-base
3 variables: &global_variables
4 POSTGRES_DB: pleroma_test
5 POSTGRES_USER: postgres
6 POSTGRES_PASSWORD: postgres
11 cache: &global_cache_policy
29 - rm -rf _build/*/lib/pleroma
33 - rm -rf _build/*/lib/pleroma
44 changes: &build_changes_policy
59 - "lib/pleroma/web/api_spec/**/*.ex"
60 - "lib/pleroma/web/api_spec.ex"
65 - mix pleroma.openapi_spec spec.json
75 - name: postgres:9.6-alpine
77 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
81 - mix pleroma.load_testing
88 changes: *build_changes_policy
89 cache: &testing_cache_policy
90 <<: *global_cache_policy
94 - name: postgres:13-alpine
96 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
100 - mix test --cover --preload-modules
101 coverage: '/^Line total: ([^ ]*%)$/'
105 coverage_format: cobertura
108 unit-testing-erratic:
115 changes: *build_changes_policy
116 cache: &testing_cache_policy
117 <<: *global_cache_policy
121 - name: postgres:13-alpine
123 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
127 - mix test --only=erratic
129 # Removed to fix CI issue. In this early state it wasn't adding much value anyway.
130 # TODO Fix and reinstate federated testing
133 # cache: *testing_cache_policy
135 # - name: minibikini/postgres-with-rum:12
137 # command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
143 # - mix test --trace --only federated
150 changes: *build_changes_policy
151 cache: *testing_cache_policy
153 - name: minibikini/postgres-with-rum:12
155 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
157 <<: *global_variables
162 - "mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
163 - mix test --preload-modules
166 image: ¤t_elixir elixir:1.12-alpine
169 changes: *build_changes_policy
170 cache: *testing_cache_policy
171 before_script: ¤t_bfr_script
173 - apk add build-base cmake file-dev git openssl
174 - mix local.hex --force
175 - mix local.rebar --force
178 - mix format --check-formatted
185 changes: *build_changes_policy
186 cache: *testing_cache_policy
188 - mix credo --strict --only=warnings,todo,fixme,consistency,readability
191 image: *current_elixir
194 changes: *build_changes_policy
196 before_script: *current_bfr_script
199 - mix xref graph --format cycles --label compile | awk '{print $0} END{exit ($0 != "No cycles found")}'
203 cache: *testing_cache_policy
206 - stable@pleroma/pleroma
207 - develop@pleroma/pleroma
211 - 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
216 - apk update && apk add openssh-client git
219 name: review/$CI_COMMIT_REF_NAME
220 url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
221 on_stop: stop_review_app
228 - echo "$CI_ENVIRONMENT_SLUG"
230 - eval $(ssh-agent -s)
231 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
232 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
233 - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
234 - (ssh -t dokku@pleroma.online -- git:set "$CI_ENVIRONMENT_SLUG" keep-git-dir true) || true
235 - 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
236 - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
237 - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
238 - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
239 - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
247 - develop@pleroma/pleroma
252 - 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
259 - apk update && apk add openssh-client git
262 name: review/$CI_COMMIT_REF_NAME
265 - echo "$CI_ENVIRONMENT_SLUG"
267 - eval $(ssh-agent -s)
268 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
269 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
270 - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
271 - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
277 - stable@pleroma/pleroma
278 - develop@pleroma/pleroma
279 - /^maint/.*$/@pleroma/pleroma
280 - /^release/.*$/@pleroma/pleroma
283 artifacts: &release-artifacts
284 name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
287 # Ideally it would be never for master branch and with the next commit for develop,
288 # but Gitlab does not support neither `only` for artifacts
289 # nor setting it to never from .gitlab-ci.yml
290 # nor expiring with the next commit
293 cache: &release-cache
294 key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
297 variables: &release-variables
299 before_script: &before-release
300 - apt-get update && apt-get install -y cmake libmagic-dev
301 - echo "import Config" > config/prod.secret.exs
302 - mix local.hex --force
303 - mix local.rebar --force
305 - mix deps.get --only prod
307 - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
308 - mix release --path release
313 artifacts: *release-artifacts
315 image: elixir:1.11.4-alpine
318 cache: *release-cache
319 variables: *release-variables
320 before_script: &before-release-musl
321 - apk add git build-base cmake file-dev openssl
322 - echo "import Config" > config/prod.secret.exs
323 - mix local.hex --force
324 - mix local.rebar --force
329 artifacts: *release-artifacts
333 image: arm32v7/elixir:1.11.4
334 cache: *release-cache
335 variables: *release-variables
336 before_script: *before-release
341 artifacts: *release-artifacts
345 image: arm32v7/elixir:1.11.4-alpine
346 cache: *release-cache
347 variables: *release-variables
348 before_script: *before-release-musl
353 artifacts: *release-artifacts
357 image: arm64v8/elixir:1.11.4
358 cache: *release-cache
359 variables: *release-variables
360 before_script: *before-release
365 artifacts: *release-artifacts
369 image: arm64v8/elixir:1.11.4-alpine
370 cache: *release-cache
371 variables: *release-variables
372 before_script: *before-release-musl
380 variables: &docker-variables
381 DOCKER_DRIVER: overlay2
382 DOCKER_HOST: unix:///var/run/docker.sock
383 IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
384 IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
385 IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
386 IMAGE_TAG_LATEST_STABLE: $CI_REGISTRY_IMAGE:latest-stable
387 DOCKER_BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.6.3/buildx-v0.6.3.linux-amd64
388 DOCKER_BUILDX_HASH: 980e6b9655f971991fbbb5fd6cd19f1672386195
389 before_script: &before-docker
390 - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
391 - docker pull $IMAGE_TAG_SLUG || true
392 - export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
393 - export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
396 - mkdir -p /root/.docker/cli-plugins
397 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
398 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
399 - chmod +x ~/.docker/cli-plugins/docker-buildx
400 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
401 - docker buildx create --name mbuilder --driver docker-container --use
402 - docker buildx inspect --bootstrap
403 - 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 .
407 - develop@pleroma/pleroma
414 variables: *docker-variables
415 before_script: *before-docker
418 - mkdir -p /root/.docker/cli-plugins
419 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
420 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
421 - chmod +x ~/.docker/cli-plugins/docker-buildx
422 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
423 - docker buildx create --name mbuilder --driver docker-container --use
424 - docker buildx inspect --bootstrap
425 - 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 .
429 - stable@pleroma/pleroma
436 variables: *docker-variables
437 before_script: *before-docker
441 - mkdir -p /root/.docker/cli-plugins
442 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
443 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
444 - chmod +x ~/.docker/cli-plugins/docker-buildx
445 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
446 - docker buildx create --name mbuilder --driver docker-container --use
447 - docker buildx inspect --bootstrap
448 - 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 .
452 - /^release/.*$/@pleroma/pleroma
459 variables: *docker-variables
460 before_script: *before-docker
464 - mkdir -p /root/.docker/cli-plugins
465 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
466 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
467 - chmod +x ~/.docker/cli-plugins/docker-buildx
468 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
469 - docker buildx create --name mbuilder --driver docker-container --use
470 - docker buildx inspect --bootstrap
471 - 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 .
475 - /^build-docker/.*$/@pleroma/pleroma