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