3 variables: &global_variables
4 POSTGRES_DB: pleroma_test
5 POSTGRES_USER: postgres
6 POSTGRES_PASSWORD: postgres
10 cache: &global_cache_policy
27 - rm -rf _build/*/lib/pleroma
28 - apt-get update && apt-get install -y cmake
29 - mix local.hex --force
30 - mix local.rebar --force
33 - apt-get install -y libmagic-dev
36 - rm -rf _build/*/lib/pleroma
49 - mix pleroma.openapi_spec spec.json
59 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
63 - mix pleroma.load_testing
68 cache: &testing_cache_policy
69 <<: *global_cache_policy
75 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
77 - apt-get update && apt-get install -y libimage-exiftool-perl ffmpeg
80 - mix coveralls --preload-modules
82 # Removed to fix CI issue. In this early state it wasn't adding much value anyway.
83 # TODO Fix and reinstate federated testing
86 # cache: *testing_cache_policy
88 # - name: minibikini/postgres-with-rum:12
90 # command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
96 # - mix test --trace --only federated
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"]
107 <<: *global_variables
110 - apt-get update && apt-get install -y libimage-exiftool-perl ffmpeg
113 - "mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
114 - mix test --preload-modules
118 cache: *testing_cache_policy
120 - mix format --check-formatted
124 cache: *testing_cache_policy
126 - mix credo --strict --only=warnings,todo,fixme,consistency,readability
130 cache: *testing_cache_policy
133 - stable@pleroma/pleroma
134 - develop@pleroma/pleroma
138 - 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
143 - apk update && apk add openssh-client git
146 name: review/$CI_COMMIT_REF_NAME
147 url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
148 on_stop: stop_review_app
155 - echo "$CI_ENVIRONMENT_SLUG"
157 - eval $(ssh-agent -s)
158 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
159 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
160 - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
161 - (ssh -t dokku@pleroma.online -- git:set "$CI_ENVIRONMENT_SLUG" keep-git-dir true) || true
162 - 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
163 - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
164 - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
165 - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
166 - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
174 - develop@pleroma/pleroma
179 - 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
186 - apk update && apk add openssh-client git
189 name: review/$CI_COMMIT_REF_NAME
192 - echo "$CI_ENVIRONMENT_SLUG"
194 - eval $(ssh-agent -s)
195 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
196 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
197 - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
198 - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
204 - stable@pleroma/pleroma
205 - develop@pleroma/pleroma
206 - /^maint/.*$/@pleroma/pleroma
207 - /^release/.*$/@pleroma/pleroma
208 artifacts: &release-artifacts
209 name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
212 # Ideally it would be never for master branch and with the next commit for develop,
213 # but Gitlab does not support neither `only` for artifacts
214 # nor setting it to never from .gitlab-ci.yml
215 # nor expiring with the next commit
218 cache: &release-cache
219 key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
222 variables: &release-variables
224 before_script: &before-release
225 - apt-get update && apt-get install -y cmake libmagic-dev
226 - echo "import Mix.Config" > config/prod.secret.exs
227 - mix local.hex --force
228 - mix local.rebar --force
230 - mix deps.get --only prod
232 - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
233 - mix release --path release
238 artifacts: *release-artifacts
240 image: elixir:1.10.3-alpine
241 cache: *release-cache
242 variables: *release-variables
243 before_script: &before-release-musl
244 - apk add git gcc g++ musl-dev make cmake file-dev
245 - echo "import Mix.Config" > config/prod.secret.exs
246 - mix local.hex --force
247 - mix local.rebar --force
252 artifacts: *release-artifacts
256 image: arm32v7/elixir:1.10.3
257 cache: *release-cache
258 variables: *release-variables
259 before_script: *before-release
264 artifacts: *release-artifacts
268 image: arm32v7/elixir:1.10.3-alpine
269 cache: *release-cache
270 variables: *release-variables
271 before_script: *before-release-musl
276 artifacts: *release-artifacts
280 image: arm64v8/elixir:1.10.3
281 cache: *release-cache
282 variables: *release-variables
283 before_script: *before-release
288 artifacts: *release-artifacts
292 image: arm64v8/elixir:1.10.3-alpine
293 cache: *release-cache
294 variables: *release-variables
295 before_script: *before-release-musl
303 variables: &docker-variables
304 DOCKER_DRIVER: overlay2
305 DOCKER_HOST: unix:///var/run/docker.sock
306 IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
307 IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
308 IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
309 IMAGE_TAG_LATEST_STABLE: $CI_REGISTRY_IMAGE:latest-stable
310 DOCKER_BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64
311 DOCKER_BUILDX_HASH: 71a7d01439aa8c165a25b59c44d3f016fddbd98b
312 before_script: &before-docker
313 - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
314 - docker pull $IMAGE_TAG_SLUG || true
315 - export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
316 - export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
319 - mkdir -p /root/.docker/cli-plugins
320 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
321 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
322 - chmod +x ~/.docker/cli-plugins/docker-buildx
323 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
324 - docker buildx create --name mbuilder --driver docker-container --use
325 - docker buildx inspect --bootstrap
326 - 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 .
330 - develop@pleroma/pleroma
337 variables: *docker-variables
338 before_script: *before-docker
341 - mkdir -p /root/.docker/cli-plugins
342 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
343 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
344 - chmod +x ~/.docker/cli-plugins/docker-buildx
345 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
346 - docker buildx create --name mbuilder --driver docker-container --use
347 - docker buildx inspect --bootstrap
348 - 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 .
352 - stable@pleroma/pleroma
359 variables: *docker-variables
360 before_script: *before-docker
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 .
375 - /^release/.*$/@pleroma/pleroma
382 variables: *docker-variables
383 before_script: *before-docker
387 - mkdir -p /root/.docker/cli-plugins
388 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
389 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
390 - chmod +x ~/.docker/cli-plugins/docker-buildx
391 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
392 - docker buildx create --name mbuilder --driver docker-container --use
393 - docker buildx inspect --bootstrap
394 - 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 .
398 - /^build-docker/.*$/@pleroma/pleroma