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