Merge branch 'chore/changelog-sync-' into 'develop'
[akkoma] / .gitlab-ci.yml
1 image: elixir:1.8.1
2
3 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:
11 key: ${CI_COMMIT_REF_SLUG}
12 paths:
13 - deps
14 - _build
15 stages:
16 - build
17 - test
18 - benchmark
19 - deploy
20 - release
21
22 before_script:
23 - mix local.hex --force
24 - mix local.rebar --force
25
26 build:
27 stage: build
28 script:
29 - mix deps.get
30 - mix compile --force
31
32 benchmark:
33 stage: benchmark
34 variables:
35 MIX_ENV: benchmark
36 services:
37 - name: postgres:9.6
38 alias: postgres
39 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
40 script:
41 - mix deps.get
42 - mix ecto.create
43 - mix ecto.migrate
44 - mix pleroma.load_testing
45
46 unit-testing:
47 stage: test
48 services:
49 - name: postgres:9.6
50 alias: postgres
51 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
52 script:
53 - mix deps.get
54 - mix ecto.create
55 - mix ecto.migrate
56 - mix coveralls --preload-modules
57
58 unit-testing-rum:
59 stage: test
60 services:
61 - name: minibikini/postgres-with-rum:12
62 alias: postgres
63 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
64 variables:
65 RUM_ENABLED: "true"
66 script:
67 - mix deps.get
68 - mix ecto.create
69 - mix ecto.migrate
70 - "mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
71 - mix test --preload-modules
72
73 lint:
74 stage: test
75 script:
76 - mix format --check-formatted
77
78 analysis:
79 stage: test
80 script:
81 - mix deps.get
82 - mix credo --strict --only=warnings,todo,fixme,consistency,readability
83
84 docs-deploy:
85 stage: deploy
86 image: alpine:latest
87 only:
88 - stable@pleroma/pleroma
89 - develop@pleroma/pleroma
90 before_script:
91 - apk add curl
92 script:
93 - 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
94 review_app:
95 image: alpine:3.9
96 stage: deploy
97 before_script:
98 - apk update && apk add openssh-client git
99 when: manual
100 environment:
101 name: review/$CI_COMMIT_REF_NAME
102 url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
103 on_stop: stop_review_app
104 only:
105 - branches
106 except:
107 - master
108 - develop
109 script:
110 - echo "$CI_ENVIRONMENT_SLUG"
111 - mkdir -p ~/.ssh
112 - eval $(ssh-agent -s)
113 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
114 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
115 - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
116 - (ssh -t dokku@pleroma.online -- git:set "$CI_ENVIRONMENT_SLUG" keep-git-dir true) || true
117 - 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
118 - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
119 - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
120 - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
121 - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
122
123 stop_review_app:
124 image: alpine:3.9
125 stage: deploy
126 before_script:
127 - apk update && apk add openssh-client git
128 when: manual
129 environment:
130 name: review/$CI_COMMIT_REF_NAME
131 action: stop
132 script:
133 - echo "$CI_ENVIRONMENT_SLUG"
134 - mkdir -p ~/.ssh
135 - eval $(ssh-agent -s)
136 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
137 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
138 - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
139 - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
140
141 amd64:
142 stage: release
143 # TODO: Replace with upstream image when 1.9.0 comes out
144 image: rinpatch/elixir:1.9.0-rc.0
145 only: &release-only
146 - stable@pleroma/pleroma
147 - develop@pleroma/pleroma
148 - /^maint/.*$/@pleroma/pleroma
149 - /^release/.*$/@pleroma/pleroma
150 artifacts: &release-artifacts
151 name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
152 paths:
153 - release/*
154 # Ideally it would be never for master branch and with the next commit for develop,
155 # but Gitlab does not support neither `only` for artifacts
156 # nor setting it to never from .gitlab-ci.yml
157 # nor expiring with the next commit
158 expire_in: 42 yrs
159
160 cache: &release-cache
161 key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
162 paths:
163 - deps
164 variables: &release-variables
165 MIX_ENV: prod
166 before_script: &before-release
167 - echo "import Mix.Config" > config/prod.secret.exs
168 - mix local.hex --force
169 - mix local.rebar --force
170 script: &release
171 - mix deps.get --only prod
172 - mkdir release
173 - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
174 - mix release --path release
175
176
177 amd64-musl:
178 stage: release
179 artifacts: *release-artifacts
180 only: *release-only
181 # TODO: Replace with upstream image when 1.9.0 comes out
182 image: rinpatch/elixir:1.9.0-rc.0-alpine
183 cache: *release-cache
184 variables: *release-variables
185 before_script: &before-release-musl
186 - apk add git gcc g++ musl-dev make
187 - echo "import Mix.Config" > config/prod.secret.exs
188 - mix local.hex --force
189 - mix local.rebar --force
190 script: *release
191
192 arm:
193 stage: release
194 artifacts: *release-artifacts
195 only: *release-only
196 tags:
197 - arm32
198 # TODO: Replace with upstream image when 1.9.0 comes out
199 image: rinpatch/elixir:1.9.0-rc.0-arm
200 cache: *release-cache
201 variables: *release-variables
202 before_script: *before-release
203 script: *release
204
205 arm-musl:
206 stage: release
207 artifacts: *release-artifacts
208 only: *release-only
209 tags:
210 - arm32
211 # TODO: Replace with upstream image when 1.9.0 comes out
212 image: rinpatch/elixir:1.9.0-rc.0-arm-alpine
213 cache: *release-cache
214 variables: *release-variables
215 before_script: *before-release-musl
216 script: *release
217
218 arm64:
219 stage: release
220 artifacts: *release-artifacts
221 only: *release-only
222 tags:
223 - arm
224 # TODO: Replace with upstream image when 1.9.0 comes out
225 image: rinpatch/elixir:1.9.0-rc.0-arm64
226 cache: *release-cache
227 variables: *release-variables
228 before_script: *before-release
229 script: *release
230
231 arm64-musl:
232 stage: release
233 artifacts: *release-artifacts
234 only: *release-only
235 tags:
236 - arm
237 # TODO: Replace with upstream image when 1.9.0 comes out
238 image: rinpatch/elixir:1.9.0-rc.0-arm64-alpine
239 cache: *release-cache
240 variables: *release-variables
241 before_script: *before-release-musl
242 script: *release