.gitlab-ci.yml 3.84 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
lain's avatar
lain committed
19
20

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

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

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

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

lain's avatar
lain committed
57
unit-testing-rum:
58
  stage: test
lain's avatar
lain committed
59
60
  services:
  - name: lainsoykaf/postgres-with-rum
61
    alias: postgres
lain's avatar
lain committed
62
    command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
63
64
  variables:
    RUM_ENABLED: "true"
lain's avatar
lain committed
65
66
67
68
69
70
71
  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

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

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

83
docs-deploy:
84
  stage: deploy
rinpatch's avatar
rinpatch committed
85
86
87
88
89
90
91
92
93
94
95
  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 -
96
    - rsync -hrvz --delete -e "ssh -p ${SSH_PORT}" priv/static/doc/ "${SSH_USER_HOST_LOCATION}/${CI_COMMIT_REF_NAME}"
lain's avatar
lain committed
97
98
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

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
124
    - git push -f dokku@pleroma.online:$CI_ENVIRONMENT_SLUG $CI_COMMIT_SHA:refs/heads/master
lain's avatar
lain committed
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

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