Gitlab: Run benchmark in CI.
[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:3.9
103 only:
104 - master@pleroma/pleroma
105 - develop@pleroma/pleroma
106 before_script:
107 - apk update && apk add openssh-client rsync
108 script:
109 - mkdir -p ~/.ssh
110 - echo "${SSH_HOST_KEY}" > ~/.ssh/known_hosts
111 - eval $(ssh-agent -s)
112 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
113 - rsync -hrvz --delete -e "ssh -p ${SSH_PORT}" priv/static/doc/ "${SSH_USER_HOST_LOCATION}/${CI_COMMIT_REF_NAME}"
114
115 review_app:
116 image: alpine:3.9
117 stage: deploy
118 before_script:
119 - apk update && apk add openssh-client git
120 when: manual
121 environment:
122 name: review/$CI_COMMIT_REF_NAME
123 url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
124 on_stop: stop_review_app
125 only:
126 - branches
127 except:
128 - master
129 - develop
130 script:
131 - echo "$CI_ENVIRONMENT_SLUG"
132 - mkdir -p ~/.ssh
133 - eval $(ssh-agent -s)
134 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
135 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
136 - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
137 - 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
138 - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
139 - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
140 - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
141 - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
142
143 stop_review_app:
144 image: alpine:3.9
145 stage: deploy
146 before_script:
147 - apk update && apk add openssh-client git
148 when: manual
149 environment:
150 name: review/$CI_COMMIT_REF_NAME
151 action: stop
152 script:
153 - echo "$CI_ENVIRONMENT_SLUG"
154 - mkdir -p ~/.ssh
155 - eval $(ssh-agent -s)
156 - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
157 - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
158 - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
159 - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
160
161 amd64:
162 stage: release
163 # TODO: Replace with upstream image when 1.9.0 comes out
164 image: rinpatch/elixir:1.9.0-rc.0
165 only: &release-only
166 - master@pleroma/pleroma
167 - develop@pleroma/pleroma
168 artifacts: &release-artifacts
169 name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
170 paths:
171 - release/*
172 # Ideally it would be never for master branch and with the next commit for develop,
173 # but Gitlab does not support neither `only` for artifacts
174 # nor setting it to never from .gitlab-ci.yml
175 # nor expiring with the next commit
176 expire_in: 42 yrs
177
178 cache: &release-cache
179 key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
180 paths:
181 - deps
182 variables: &release-variables
183 MIX_ENV: prod
184 before_script: &before-release
185 - echo "import Mix.Config" > config/prod.secret.exs
186 - mix local.hex --force
187 - mix local.rebar --force
188 script: &release
189 - mix deps.get --only prod
190 - mkdir release
191 - export PLEROMA_BUILD_BRANCH=$CI_COMMIT_REF_NAME
192 - mix release --path release
193
194
195 amd64-musl:
196 stage: release
197 artifacts: *release-artifacts
198 only: *release-only
199 # TODO: Replace with upstream image when 1.9.0 comes out
200 image: rinpatch/elixir:1.9.0-rc.0-alpine
201 cache: *release-cache
202 variables: *release-variables
203 before_script: &before-release-musl
204 - apk add git gcc g++ musl-dev make
205 - echo "import Mix.Config" > config/prod.secret.exs
206 - mix local.hex --force
207 - mix local.rebar --force
208 script: *release
209
210 arm:
211 stage: release
212 artifacts: *release-artifacts
213 only: *release-only
214 tags:
215 - arm32
216 # TODO: Replace with upstream image when 1.9.0 comes out
217 image: rinpatch/elixir:1.9.0-rc.0-arm
218 cache: *release-cache
219 variables: *release-variables
220 before_script: *before-release
221 script: *release
222
223 arm-musl:
224 stage: release
225 artifacts: *release-artifacts
226 only: *release-only
227 tags:
228 - arm32
229 # TODO: Replace with upstream image when 1.9.0 comes out
230 image: rinpatch/elixir:1.9.0-rc.0-arm-alpine
231 cache: *release-cache
232 variables: *release-variables
233 before_script: *before-release-musl
234 script: *release
235
236 arm64:
237 stage: release
238 artifacts: *release-artifacts
239 only: *release-only
240 tags:
241 - arm
242 # TODO: Replace with upstream image when 1.9.0 comes out
243 image: rinpatch/elixir:1.9.0-rc.0-arm64
244 cache: *release-cache
245 variables: *release-variables
246 before_script: *before-release
247 script: *release
248
249 arm64-musl:
250 stage: release
251 artifacts: *release-artifacts
252 only: *release-only
253 tags:
254 - arm
255 # TODO: Replace with upstream image when 1.9.0 comes out
256 image: rinpatch/elixir:1.9.0-rc.0-arm64-alpine
257 cache: *release-cache
258 variables: *release-variables
259 before_script: *before-release-musl
260 script: *release