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