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