fix link on docs-develop.pleroma.social
[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.load_testing
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 - stable@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 - stable@pleroma/pleroma
162 - develop@pleroma/pleroma
163 - /^maint/.*$/@pleroma/pleroma
164 - /^release/.*$/@pleroma/pleroma
165 artifacts: &release-artifacts
166 name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
167 paths:
168 - release/*
169 # Ideally it would be never for master branch and with the next commit for develop,
170 # but Gitlab does not support neither `only` for artifacts
171 # nor setting it to never from .gitlab-ci.yml
172 # nor expiring with the next commit
173 expire_in: 42 yrs
174
175 cache: &release-cache
176 key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
177 paths:
178 - deps
179 variables: &release-variables
180 MIX_ENV: prod
181 before_script: &before-release
182 - echo "import Mix.Config" > config/prod.secret.exs
183 - mix local.hex --force
184 - mix local.rebar --force
185 script: &release
186 - mix deps.get --only prod
187 - mkdir release
188 - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
189 - mix release --path release
190
191
192 amd64-musl:
193 stage: release
194 artifacts: *release-artifacts
195 only: *release-only
196 # TODO: Replace with upstream image when 1.9.0 comes out
197 image: rinpatch/elixir:1.9.0-rc.0-alpine
198 cache: *release-cache
199 variables: *release-variables
200 before_script: &before-release-musl
201 - apk add git gcc g++ musl-dev make
202 - echo "import Mix.Config" > config/prod.secret.exs
203 - mix local.hex --force
204 - mix local.rebar --force
205 script: *release
206
207 arm:
208 stage: release
209 artifacts: *release-artifacts
210 only: *release-only
211 tags:
212 - arm32
213 # TODO: Replace with upstream image when 1.9.0 comes out
214 image: rinpatch/elixir:1.9.0-rc.0-arm
215 cache: *release-cache
216 variables: *release-variables
217 before_script: *before-release
218 script: *release
219
220 arm-musl:
221 stage: release
222 artifacts: *release-artifacts
223 only: *release-only
224 tags:
225 - arm32
226 # TODO: Replace with upstream image when 1.9.0 comes out
227 image: rinpatch/elixir:1.9.0-rc.0-arm-alpine
228 cache: *release-cache
229 variables: *release-variables
230 before_script: *before-release-musl
231 script: *release
232
233 arm64:
234 stage: release
235 artifacts: *release-artifacts
236 only: *release-only
237 tags:
238 - arm
239 # TODO: Replace with upstream image when 1.9.0 comes out
240 image: rinpatch/elixir:1.9.0-rc.0-arm64
241 cache: *release-cache
242 variables: *release-variables
243 before_script: *before-release
244 script: *release
245
246 arm64-musl:
247 stage: release
248 artifacts: *release-artifacts
249 only: *release-only
250 tags:
251 - arm
252 # TODO: Replace with upstream image when 1.9.0 comes out
253 image: rinpatch/elixir:1.9.0-rc.0-arm64-alpine
254 cache: *release-cache
255 variables: *release-variables
256 before_script: *before-release-musl
257 script: *release