Added translation using Weblate (Chinese (Simplified))
[akkoma] / .gitlab-ci.yml
1 image: elixir:1.9.4
2
3 variables: &global_variables
4 POSTGRES_DB: pleroma_test
5 POSTGRES_USER: postgres
6 POSTGRES_PASSWORD: postgres
7 DB_HOST: postgres
8 MIX_ENV: test
9
10 cache: &global_cache_policy
11 key: ${CI_COMMIT_REF_SLUG}
12 paths:
13 - deps
14 - _build
15
16 stages:
17 - build
18 - test
19 - benchmark
20 - deploy
21 - release
22 - docker
23
24 before_script:
25 - apt-get update && apt-get install -y cmake
26 - mix local.hex --force
27 - mix local.rebar --force
28
29 build:
30 stage: build
31 script:
32 - mix deps.get
33 - mix compile --force
34
35 benchmark:
36 stage: benchmark
37 when: manual
38 variables:
39 MIX_ENV: benchmark
40 services:
41 - name: postgres:9.6
42 alias: postgres
43 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
44 script:
45 - mix deps.get
46 - mix ecto.create
47 - mix ecto.migrate
48 - mix pleroma.load_testing
49
50 unit-testing:
51 stage: test
52 retry: 2
53 cache: &testing_cache_policy
54 <<: *global_cache_policy
55 policy: pull
56
57 services:
58 - name: postgres:9.6
59 alias: postgres
60 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
61 script:
62 - apt-get update && apt-get install -y libimage-exiftool-perl
63 - mix deps.get
64 - mix ecto.create
65 - mix ecto.migrate
66 - mix coveralls --preload-modules
67
68 # Removed to fix CI issue. In this early state it wasn't adding much value anyway.
69 # TODO Fix and reinstate federated testing
70 # federated-testing:
71 # stage: test
72 # cache: *testing_cache_policy
73 # services:
74 # - name: minibikini/postgres-with-rum:12
75 # alias: postgres
76 # command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
77 # script:
78 # - mix deps.get
79 # - mix ecto.create
80 # - mix ecto.migrate
81 # - epmd -daemon
82 # - mix test --trace --only federated
83
84 unit-testing-rum:
85 stage: test
86 retry: 2
87 cache: *testing_cache_policy
88 services:
89 - name: minibikini/postgres-with-rum:12
90 alias: postgres
91 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
92 variables:
93 <<: *global_variables
94 RUM_ENABLED: "true"
95 script:
96 - apt-get update && apt-get install -y libimage-exiftool-perl
97 - mix deps.get
98 - mix ecto.create
99 - mix ecto.migrate
100 - "mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
101 - mix test --preload-modules
102
103 lint:
104 stage: test
105 cache: *testing_cache_policy
106 script:
107 - mix format --check-formatted
108
109 analysis:
110 stage: test
111 cache: *testing_cache_policy
112 script:
113 - mix deps.get
114 - mix credo --strict --only=warnings,todo,fixme,consistency,readability
115
116 docs-deploy:
117 stage: deploy
118 cache: *testing_cache_policy
119 image: alpine:latest
120 only:
121 - stable@pleroma/pleroma
122 - develop@pleroma/pleroma
123 before_script:
124 - apk add curl
125 script:
126 - 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
127 review_app:
128 image: alpine:3.9
129 stage: deploy
130 before_script:
131 - apk update && apk add openssh-client git
132 when: manual
133 environment:
134 name: review/$CI_COMMIT_REF_NAME
135 url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
136 on_stop: stop_review_app
137 only:
138 - branches
139 except:
140 - master
141 - develop
142 script:
143 - echo "$CI_ENVIRONMENT_SLUG"
144 - mkdir -p ~/.ssh
145 - eval $(ssh-agent -s)
146 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
147 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
148 - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
149 - (ssh -t dokku@pleroma.online -- git:set "$CI_ENVIRONMENT_SLUG" keep-git-dir true) || true
150 - 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
151 - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
152 - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
153 - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
154 - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
155
156 stop_review_app:
157 image: alpine:3.9
158 stage: deploy
159 before_script:
160 - apk update && apk add openssh-client git
161 when: manual
162 environment:
163 name: review/$CI_COMMIT_REF_NAME
164 action: stop
165 script:
166 - echo "$CI_ENVIRONMENT_SLUG"
167 - mkdir -p ~/.ssh
168 - eval $(ssh-agent -s)
169 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
170 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
171 - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
172 - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
173
174 amd64:
175 stage: release
176 image: elixir:1.10.3
177 only: &release-only
178 - stable@pleroma/pleroma
179 - develop@pleroma/pleroma
180 - /^maint/.*$/@pleroma/pleroma
181 - /^release/.*$/@pleroma/pleroma
182 artifacts: &release-artifacts
183 name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
184 paths:
185 - release/*
186 # Ideally it would be never for master branch and with the next commit for develop,
187 # but Gitlab does not support neither `only` for artifacts
188 # nor setting it to never from .gitlab-ci.yml
189 # nor expiring with the next commit
190 expire_in: 42 yrs
191
192 cache: &release-cache
193 key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
194 paths:
195 - deps
196 variables: &release-variables
197 MIX_ENV: prod
198 before_script: &before-release
199 - apt-get update && apt-get install -y cmake
200 - echo "import Mix.Config" > config/prod.secret.exs
201 - mix local.hex --force
202 - mix local.rebar --force
203 script: &release
204 - mix deps.get --only prod
205 - mkdir release
206 - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
207 - mix release --path release
208
209
210 amd64-musl:
211 stage: release
212 artifacts: *release-artifacts
213 only: *release-only
214 image: elixir:1.10.3-alpine
215 cache: *release-cache
216 variables: *release-variables
217 before_script: &before-release-musl
218 - apk add git gcc g++ musl-dev make cmake
219 - echo "import Mix.Config" > config/prod.secret.exs
220 - mix local.hex --force
221 - mix local.rebar --force
222 script: *release
223
224 arm:
225 stage: release
226 artifacts: *release-artifacts
227 only: *release-only
228 tags:
229 - arm32
230 image: elixir:1.10.3
231 cache: *release-cache
232 variables: *release-variables
233 before_script: *before-release
234 script: *release
235
236 arm-musl:
237 stage: release
238 artifacts: *release-artifacts
239 only: *release-only
240 tags:
241 - arm32
242 image: elixir:1.10.3-alpine
243 cache: *release-cache
244 variables: *release-variables
245 before_script: *before-release-musl
246 script: *release
247
248 arm64:
249 stage: release
250 artifacts: *release-artifacts
251 only: *release-only
252 tags:
253 - arm
254 image: elixir:1.10.3
255 cache: *release-cache
256 variables: *release-variables
257 before_script: *before-release
258 script: *release
259
260 arm64-musl:
261 stage: release
262 artifacts: *release-artifacts
263 only: *release-only
264 tags:
265 - arm
266 # TODO: Replace with upstream image when 1.9.0 comes out
267 image: elixir:1.10.3-alpine
268 cache: *release-cache
269 variables: *release-variables
270 before_script: *before-release-musl
271 script: *release
272
273 docker:
274 stage: docker
275 image: docker:latest
276 cache: {}
277 dependencies: []
278 variables: &docker-variables
279 DOCKER_DRIVER: overlay2
280 DOCKER_HOST: unix:///var/run/docker.sock
281 IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_SHORT_SHA
282 IMAGE_TAG_SLUG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
283 IMAGE_TAG_LATEST: $CI_REGISTRY_IMAGE:latest
284 IMAGE_TAG_LATEST_STABLE: $CI_REGISTRY_IMAGE:latest-stable
285 DOCKER_BUILDX_URL: https://github.com/docker/buildx/releases/download/v0.4.1/buildx-v0.4.1.linux-amd64
286 DOCKER_BUILDX_HASH: 71a7d01439aa8c165a25b59c44d3f016fddbd98b
287 before_script: &before-docker
288 - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
289 - docker pull $IMAGE_TAG_SLUG || true
290 - export CI_JOB_TIMESTAMP=$(date --utc -Iseconds)
291 - export CI_VCS_REF=$CI_COMMIT_SHORT_SHA
292 allow_failure: true
293 script:
294 - mkdir -p /root/.docker/cli-plugins
295 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
296 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
297 - chmod +x ~/.docker/cli-plugins/docker-buildx
298 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
299 - docker buildx create --name mbuilder --driver docker-container --use
300 - docker buildx inspect --bootstrap
301 - 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 .
302 tags:
303 - dind
304 only:
305 - develop@pleroma/pleroma
306
307 docker-stable:
308 stage: docker
309 image: docker:latest
310 cache: {}
311 dependencies: []
312 variables: *docker-variables
313 before_script: *before-docker
314 allow_failure: true
315 script:
316 - mkdir -p /root/.docker/cli-plugins
317 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
318 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
319 - chmod +x ~/.docker/cli-plugins/docker-buildx
320 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
321 - docker buildx create --name mbuilder --driver docker-container --use
322 - docker buildx inspect --bootstrap
323 - 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 .
324 tags:
325 - dind
326 only:
327 - stable@pleroma/pleroma
328
329 docker-release:
330 stage: docker
331 image: docker:latest
332 cache: {}
333 dependencies: []
334 variables: *docker-variables
335 before_script: *before-docker
336 allow_failure: true
337 script:
338 script:
339 - mkdir -p /root/.docker/cli-plugins
340 - wget "${DOCKER_BUILDX_URL}" -O ~/.docker/cli-plugins/docker-buildx
341 - echo "${DOCKER_BUILDX_HASH} /root/.docker/cli-plugins/docker-buildx" | sha1sum -c
342 - chmod +x ~/.docker/cli-plugins/docker-buildx
343 - docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
344 - docker buildx create --name mbuilder --driver docker-container --use
345 - docker buildx inspect --bootstrap
346 - 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 .
347 tags:
348 - dind
349 only:
350 - /^release/.*$/@pleroma/pleroma