Merge remote-tracking branch 'origin/develop' into benchmark-finishing
[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 docs-build:
33 stage: build
34 only:
35 - master@pleroma/pleroma
36 - develop@pleroma/pleroma
37 variables:
38 MIX_ENV: dev
39 PLEROMA_BUILD_ENV: prod
40 script:
41 - mix deps.get
42 - mix compile
43 - mix docs
44 artifacts:
45 paths:
46 - priv/static/doc
47
48 benchmark:
49 stage: benchmark
50 variables:
51 MIX_ENV: benchmark
52 services:
53 - name: lainsoykaf/postgres-with-rum
54 alias: postgres
55 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
56 script:
57 - mix deps.get
58 - mix ecto.create
59 - mix ecto.migrate
60 - mix pleroma.benchmark
61
62 unit-testing:
63 stage: test
64 services:
65 - name: lainsoykaf/postgres-with-rum
66 alias: postgres
67 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
68 script:
69 - mix deps.get
70 - mix ecto.create
71 - mix ecto.migrate
72 - mix coveralls --trace --preload-modules
73
74 unit-testing-rum:
75 stage: test
76 services:
77 - name: lainsoykaf/postgres-with-rum
78 alias: postgres
79 command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
80 variables:
81 RUM_ENABLED: "true"
82 script:
83 - mix deps.get
84 - mix ecto.create
85 - mix ecto.migrate
86 - "mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
87 - mix test --trace --preload-modules
88
89 lint:
90 stage: test
91 script:
92 - mix format --check-formatted
93
94 analysis:
95 stage: test
96 script:
97 - mix deps.get
98 - mix credo --strict --only=warnings,todo,fixme,consistency,readability
99
100 docs-deploy:
101 stage: deploy
102 image: alpine:latest
103 only:
104 - master@pleroma/pleroma
105 - develop@pleroma/pleroma
106 before_script:
107 - apk add curl
108 script:
109 - 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
110 review_app:
111 image: alpine:3.9
112 stage: deploy
113 before_script:
114 - apk update && apk add openssh-client git
115 when: manual
116 environment:
117 name: review/$CI_COMMIT_REF_NAME
118 url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
119 on_stop: stop_review_app
120 only:
121 - branches
122 except:
123 - master
124 - develop
125 script:
126 - echo "$CI_ENVIRONMENT_SLUG"
127 - mkdir -p ~/.ssh
128 - eval $(ssh-agent -s)
129 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
130 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
131 - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
132 - 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
133 - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
134 - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
135 - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
136 - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
137
138 stop_review_app:
139 image: alpine:3.9
140 stage: deploy
141 before_script:
142 - apk update && apk add openssh-client git
143 when: manual
144 environment:
145 name: review/$CI_COMMIT_REF_NAME
146 action: stop
147 script:
148 - echo "$CI_ENVIRONMENT_SLUG"
149 - mkdir -p ~/.ssh
150 - eval $(ssh-agent -s)
151 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
152 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
153 - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
154 - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
155
156 amd64:
157 stage: release
158 # TODO: Replace with upstream image when 1.9.0 comes out
159 image: rinpatch/elixir:1.9.0-rc.0
160 only: &release-only
161 - master@pleroma/pleroma
162 - develop@pleroma/pleroma
163 - /^maint/.*$/@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