CI: Remove the docs-build job
[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: lainsoykaf/postgres-with-rum
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: lainsoykaf/postgres-with-rum
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 --trace --preload-modules
57
58 unit-testing-rum:
59 stage: test
60 services:
61 - name: lainsoykaf/postgres-with-rum
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 --trace --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 -- config:set "$CI_ENVIRONMENT_SLUG" APP_NAME="$CI_ENVIRONMENT_SLUG" APP_HOST="$CI_ENVIRONMENT_SLUG.pleroma.online" MIX_ENV=dokku
117 - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
118 - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
119 - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
120 - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
121
122 stop_review_app:
123 image: alpine:3.9
124 stage: deploy
125 before_script:
126 - apk update && apk add openssh-client git
127 when: manual
128 environment:
129 name: review/$CI_COMMIT_REF_NAME
130 action: stop
131 script:
132 - echo "$CI_ENVIRONMENT_SLUG"
133 - mkdir -p ~/.ssh
134 - eval $(ssh-agent -s)
135 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
136 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
137 - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
138 - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
139
140 amd64:
141 stage: release
142 # TODO: Replace with upstream image when 1.9.0 comes out
143 image: rinpatch/elixir:1.9.0-rc.0
144 only: &release-only
145 - stable@pleroma/pleroma
146 - develop@pleroma/pleroma
147 - /^maint/.*$/@pleroma/pleroma
148 - /^release/.*$/@pleroma/pleroma
149 artifacts: &release-artifacts
150 name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
151 paths:
152 - release/*
153 # Ideally it would be never for master branch and with the next commit for develop,
154 # but Gitlab does not support neither `only` for artifacts
155 # nor setting it to never from .gitlab-ci.yml
156 # nor expiring with the next commit
157 expire_in: 42 yrs
158
159 cache: &release-cache
160 key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
161 paths:
162 - deps
163 variables: &release-variables
164 MIX_ENV: prod
165 before_script: &before-release
166 - echo "import Mix.Config" > config/prod.secret.exs
167 - mix local.hex --force
168 - mix local.rebar --force
169 script: &release
170 - mix deps.get --only prod
171 - mkdir release
172 - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
173 - mix release --path release
174
175
176 amd64-musl:
177 stage: release
178 artifacts: *release-artifacts
179 only: *release-only
180 # TODO: Replace with upstream image when 1.9.0 comes out
181 image: rinpatch/elixir:1.9.0-rc.0-alpine
182 cache: *release-cache
183 variables: *release-variables
184 before_script: &before-release-musl
185 - apk add git gcc g++ musl-dev make
186 - echo "import Mix.Config" > config/prod.secret.exs
187 - mix local.hex --force
188 - mix local.rebar --force
189 script: *release
190
191 arm:
192 stage: release
193 artifacts: *release-artifacts
194 only: *release-only
195 tags:
196 - arm32
197 # TODO: Replace with upstream image when 1.9.0 comes out
198 image: rinpatch/elixir:1.9.0-rc.0-arm
199 cache: *release-cache
200 variables: *release-variables
201 before_script: *before-release
202 script: *release
203
204 arm-musl:
205 stage: release
206 artifacts: *release-artifacts
207 only: *release-only
208 tags:
209 - arm32
210 # TODO: Replace with upstream image when 1.9.0 comes out
211 image: rinpatch/elixir:1.9.0-rc.0-arm-alpine
212 cache: *release-cache
213 variables: *release-variables
214 before_script: *before-release-musl
215 script: *release
216
217 arm64:
218 stage: release
219 artifacts: *release-artifacts
220 only: *release-only
221 tags:
222 - arm
223 # TODO: Replace with upstream image when 1.9.0 comes out
224 image: rinpatch/elixir:1.9.0-rc.0-arm64
225 cache: *release-cache
226 variables: *release-variables
227 before_script: *before-release
228 script: *release
229
230 arm64-musl:
231 stage: release
232 artifacts: *release-artifacts
233 only: *release-only
234 tags:
235 - arm
236 # TODO: Replace with upstream image when 1.9.0 comes out
237 image: rinpatch/elixir:1.9.0-rc.0-arm64-alpine
238 cache: *release-cache
239 variables: *release-variables
240 before_script: *before-release-musl
241 script: *release