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