3 variables: &global_variables
4 POSTGRES_DB: pleroma_test
5 POSTGRES_USER: postgres
6 POSTGRES_PASSWORD: postgres
10 cache: &global_cache_policy
11 key: ${CI_COMMIT_REF_SLUG}
25 - apt-get update && apt-get install -y cmake
26 - mix local.hex --force
27 - mix local.rebar --force
30 - apt-get install -y libmagic-dev
43 - mix pleroma.openapi_spec spec.json
53 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
57 - mix pleroma.load_testing
62 cache: &testing_cache_policy
63 <<: *global_cache_policy
69 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
71 - apt-get update && apt-get install -y libimage-exiftool-perl ffmpeg
74 - mix coveralls --preload-modules
76 # Removed to fix CI issue. In this early state it wasn't adding much value anyway.
77 # TODO Fix and reinstate federated testing
80 # cache: *testing_cache_policy
82 # - name: minibikini/postgres-with-rum:12
84 # command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
90 # - mix test --trace --only federated
95 cache: *testing_cache_policy
97 - name: minibikini/postgres-with-rum:12
99 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
101 <<: *global_variables
104 - apt-get update && apt-get install -y libimage-exiftool-perl ffmpeg
107 - "mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
108 - mix test --preload-modules
112 cache: *testing_cache_policy
114 - mix format --check-formatted
118 cache: *testing_cache_policy
120 - mix credo --strict --only=warnings,todo,fixme,consistency,readability
124 cache: *testing_cache_policy
127 - stable@pleroma/pleroma
128 - develop@pleroma/pleroma
132 - 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
137 - apk update && apk add openssh-client git
140 name: review/$CI_COMMIT_REF_NAME
141 url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
142 on_stop: stop_review_app
149 - echo "$CI_ENVIRONMENT_SLUG"
151 - eval $(ssh-agent -s)
152 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
153 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
154 - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
155 - (ssh -t dokku@pleroma.online -- git:set "$CI_ENVIRONMENT_SLUG" keep-git-dir true) || true
156 - 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
157 - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
158 - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
159 - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
160 - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
168 - develop@pleroma/pleroma
173 - 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
180 - apk update && apk add openssh-client git
183 name: review/$CI_COMMIT_REF_NAME
186 - echo "$CI_ENVIRONMENT_SLUG"
188 - eval $(ssh-agent -s)
189 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
190 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
191 - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
192 - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
198 - stable@pleroma/pleroma
199 - develop@pleroma/pleroma
200 - /^maint/.*$/@pleroma/pleroma
201 - /^release/.*$/@pleroma/pleroma
202 artifacts: &release-artifacts
203 name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
206 # Ideally it would be never for master branch and with the next commit for develop,
207 # but Gitlab does not support neither `only` for artifacts
208 # nor setting it to never from .gitlab-ci.yml
209 # nor expiring with the next commit
212 cache: &release-cache
213 key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
216 variables: &release-variables
218 before_script: &before-release
219 - apt-get update && apt-get install -y cmake libmagic-dev
220 - echo "import Mix.Config" > config/prod.secret.exs
221 - mix local.hex --force
222 - mix local.rebar --force
224 - mix deps.get --only prod
226 - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
227 - mix release --path release
232 artifacts: *release-artifacts
234 image: elixir:1.10.3-alpine
235 cache: *release-cache
236 variables: *release-variables
237 before_script: &before-release-musl
238 - apk add git gcc g++ musl-dev make cmake file-dev
239 - echo "import Mix.Config" > config/prod.secret.exs
240 - mix local.hex --force
241 - mix local.rebar --force
246 artifacts: *release-artifacts
250 image: arm32v7/elixir:1.10.3
251 cache: *release-cache
252 variables: *release-variables
253 before_script: *before-release
258 artifacts: *release-artifacts
262 image: arm32v7/elixir:1.10.3-alpine
263 cache: *release-cache
264 variables: *release-variables
265 before_script: *before-release-musl
270 artifacts: *release-artifacts
274 image: arm64v8/elixir:1.10.3
275 cache: *release-cache
276 variables: *release-variables
277 before_script: *before-release
282 artifacts: *release-artifacts
286 image: arm64v8/elixir:1.10.3-alpine
287 cache: *release-cache
288 variables: *release-variables
289 before_script: *before-release-musl
297 variables: &docker-variables
298 DOCKER_DRIVER: overlay2
299 DOCKER_HOST: unix:///var/run/docker.sock
300 IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
301 IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
302 IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
303 IMAGE_TAG_LATEST_STABLE: $CI_REGISTRY_IMAGE:latest-stable
304 DOCKER_BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64
305 DOCKER_BUILDX_HASH: 71a7d01439aa8c165a25b59c44d3f016fddbd98b
306 before_script: &before-docker
307 - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
308 - docker pull $IMAGE_TAG_SLUG || true
309 - export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
310 - export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
313 - mkdir -p /root/.docker/cli-plugins
314 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
315 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
316 - chmod +x ~/.docker/cli-plugins/docker-buildx
317 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
318 - docker buildx create --name mbuilder --driver docker-container --use
319 - docker buildx inspect --bootstrap
320 - 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 .
324 - develop@pleroma/pleroma
331 variables: *docker-variables
332 before_script: *before-docker
335 - mkdir -p /root/.docker/cli-plugins
336 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
337 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
338 - chmod +x ~/.docker/cli-plugins/docker-buildx
339 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
340 - docker buildx create --name mbuilder --driver docker-container --use
341 - docker buildx inspect --bootstrap
342 - 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 .
346 - stable@pleroma/pleroma
353 variables: *docker-variables
354 before_script: *before-docker
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 .
369 - /^release/.*$/@pleroma/pleroma
376 variables: *docker-variables
377 before_script: *before-docker
381 - mkdir -p /root/.docker/cli-plugins
382 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
383 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
384 - chmod +x ~/.docker/cli-plugins/docker-buildx
385 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
386 - docker buildx create --name mbuilder --driver docker-container --use
387 - docker buildx inspect --bootstrap
388 - 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 .
392 - /^build-docker/.*$/@pleroma/pleroma