.gitlab-ci.yml 6.3 KB
Newer Older
rinpatch's avatar
rinpatch committed
1
image: elixir:1.8.1
lain's avatar
lain committed
2
3
4

variables:
  POSTGRES_DB: pleroma_test
Roger Braun's avatar
Roger Braun committed
5
6
  POSTGRES_USER: postgres
  POSTGRES_PASSWORD: postgres
lain's avatar
lain committed
7
  DB_HOST: postgres
8
  MIX_ENV: test
9

rinpatch's avatar
rinpatch committed
10
cache:
11
  key: ${CI_COMMIT_REF_SLUG}
rinpatch's avatar
rinpatch committed
12
13
  paths:
          - deps
Rin Toshaka's avatar
Rin Toshaka committed
14
          - _build
lain's avatar
lain committed
15
stages:
16
  - build
lain's avatar
lain committed
17
  - test
18
  - deploy
rinpatch's avatar
rinpatch committed
19
  - release
lain's avatar
lain committed
20
21

before_script:
lain's avatar
lain committed
22
23
  - mix local.hex --force
  - mix local.rebar --force
lain's avatar
lain committed
24

25
26
build:
  stage: build
lain's avatar
lain committed
27
  script:
rinpatch's avatar
huh    
rinpatch committed
28
  - mix deps.get
29
  - mix compile --force
rinpatch's avatar
rinpatch committed
30

31
docs-build:
32
  stage: build
rinpatch's avatar
rinpatch committed
33
34
35
36
37
  only:
  - master@pleroma/pleroma
  - develop@pleroma/pleroma
  variables:
    MIX_ENV: dev
38
  script:
rinpatch's avatar
rinpatch committed
39
40
41
42
43
44
45
    - mix deps.get
    - mix compile
    - mix docs
  artifacts:
    paths:
      - priv/static/doc

rinpatch's avatar
rinpatch committed
46

47
48
49
unit-testing:
  stage: test
  services:
lain's avatar
lain committed
50
  - name: lainsoykaf/postgres-with-rum
51
    alias: postgres
52
53
    command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
  script:
54
    - mix deps.get
55
56
    - mix ecto.create
    - mix ecto.migrate
57
    - mix coveralls --trace --preload-modules
58

lain's avatar
lain committed
59
unit-testing-rum:
60
  stage: test
lain's avatar
lain committed
61
62
  services:
  - name: lainsoykaf/postgres-with-rum
63
    alias: postgres
lain's avatar
lain committed
64
    command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
65
66
  variables:
    RUM_ENABLED: "true"
lain's avatar
lain committed
67
68
69
70
71
72
73
  script:
    - mix deps.get
    - mix ecto.create
    - mix ecto.migrate
    - "mix ecto.migrate --migrations-path priv/repo/optional_migrations/rum_indexing/"
    - mix test --trace --preload-modules

74
75
76
77
78
79
80
81
lint:
  stage: test
  script:
    - mix format --check-formatted

analysis:
  stage: test
  script:
rinpatch's avatar
rinpatch committed
82
    - mix deps.get
83
84
    - mix credo --strict --only=warnings,todo,fixme,consistency,readability

85
docs-deploy:
86
  stage: deploy
rinpatch's avatar
rinpatch committed
87
88
89
90
91
92
93
94
95
96
97
  image: alpine:3.9
  only:
  - master@pleroma/pleroma
  - develop@pleroma/pleroma
  before_script:
    - apk update && apk add openssh-client rsync
  script:
    - mkdir -p ~/.ssh
    - echo "${SSH_HOST_KEY}" > ~/.ssh/known_hosts
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
98
    - rsync -hrvz --delete -e "ssh -p ${SSH_PORT}" priv/static/doc/ "${SSH_USER_HOST_LOCATION}/${CI_COMMIT_REF_NAME}"
lain's avatar
lain committed
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125

review_app:
  image: alpine:3.9
  stage: deploy
  before_script:
    - apk update && apk add openssh-client git
  when: manual
  environment:
    name: review/$CI_COMMIT_REF_NAME
    url: https://$CI_ENVIRONMENT_SLUG.pleroma.online/
    on_stop: stop_review_app
  only:
    - branches
  except:
    - master
    - develop
  script:
    - echo "$CI_ENVIRONMENT_SLUG"
    - mkdir -p ~/.ssh
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
    - (ssh -t dokku@pleroma.online -- apps:create "$CI_ENVIRONMENT_SLUG") || true
    - 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
    - (ssh -t dokku@pleroma.online -- postgres:create $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db) || true
    - (ssh -t dokku@pleroma.online -- postgres:link $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db "$CI_ENVIRONMENT_SLUG") || true
    - (ssh -t dokku@pleroma.online -- certs:add "$CI_ENVIRONMENT_SLUG" /home/dokku/server.crt /home/dokku/server.key) || true
lain's avatar
lain committed
126
    - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
lain's avatar
lain committed
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

stop_review_app:
  image: alpine:3.9
  stage: deploy
  before_script:
    - apk update && apk add openssh-client git
  when: manual
  environment:
    name: review/$CI_COMMIT_REF_NAME
    action: stop
  script:
    - echo "$CI_ENVIRONMENT_SLUG"
    - mkdir -p ~/.ssh
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - ssh-keyscan -H "pleroma.online" >> ~/.ssh/known_hosts
    - ssh -t dokku@pleroma.online -- --force apps:destroy "$CI_ENVIRONMENT_SLUG"
    - ssh -t dokku@pleroma.online -- --force postgres:destroy $(echo $CI_ENVIRONMENT_SLUG | sed -e 's/-/_/g')_db
rinpatch's avatar
rinpatch committed
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241

# TODO: Restrict to master and develop

amd64:
  stage: release 
  # TODO: Replace with upstream image when 1.9.0 comes out
  image: rinpatch/elixir:1.9.0-rc.0
  only: &release-only
  - master@pleroma/pleroma
  - develop@pleroma/pleroma
  - feature/ci-release-build@pleroma/pleroma
  artifacts: &release-artifacts
    name: "pleroma-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHORT_SHA-$CI_JOB_NAME"
    paths:
      - release/*
  cache: &release-cache
    key: $CI_COMMIT_REF_NAME-$CI_JOB_NAME
    paths:
          - deps
  variables: &release-variables
    MIX_ENV: prod
  before_script: &before-release
  - echo "import Mix.Config" > config/prod.secret.exs
  - mix local.hex --force
  - mix local.rebar --force
  script: &release
    - mix deps.get --only prod
    - mkdir release
    - mix release --path release


amd64-musl:
  stage: release
  artifacts: *release-artifacts
  only: *release-only
  # TODO: Replace with upstream image when 1.9.0 comes out
  image: rinpatch/elixir:1.9.0-rc.0-alpine
  cache: *release-cache
  variables: *release-variables
  before_script: &before-release-musl
  - apk add git gcc g++ musl-dev make
  - echo "import Mix.Config" > config/prod.secret.exs
  - mix local.hex --force
  - mix local.rebar --force
  script: *release

arm:
  stage: release
  artifacts: *release-artifacts
  only: *release-only
  tags:
    - arm32
  # TODO: Replace with upstream image when 1.9.0 comes out
  image: rinpatch/elixir:1.9.0-rc.0-arm
  cache: *release-cache
  variables: *release-variables
  before_script: *before-release
  script: *release

arm-musl:
  stage: release
  artifacts: *release-artifacts
  only: *release-only
  tags:
    - arm32
  # TODO: Replace with upstream image when 1.9.0 comes out
  image: rinpatch/elixir:1.9.0-rc.0-arm-alpine
  cache: *release-cache
  variables: *release-variables
  before_script: *before-release-musl
  script: *release

arm64:
  stage: release
  artifacts: *release-artifacts
  only: *release-only
  tags:
    - arm
  # TODO: Replace with upstream image when 1.9.0 comes out
  image: rinpatch/elixir:1.9.0-rc.0-arm64
  cache: *release-cache
  variables: *release-variables
  before_script: *before-release
  script: *release

arm64-musl:
  stage: release
  artifacts: *release-artifacts
  only: *release-only
  tags:
    - arm
  # TODO: Replace with upstream image when 1.9.0 comes out
  image: rinpatch/elixir:1.9.0-rc.0-arm64-alpine
  cache: *release-cache
  variables: *release-variables
  before_script: *before-release-musl
  script: *release