summaryrefslogtreecommitdiff
path: root/.gitlab-ci.yml
blob: b1771a5789824277e955157456efdfbdd9f662d0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
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
stages:
  - setup
  - test
  - format
  - credo
  - dialyzer
  - docs

image: bitwalker/alpine-elixir:1.10.4

cache: &global_cache
  key: cache-test
  when: always
  policy: pull
  paths:
    - _build
    - deps

variables:
  MIX_ENV: test


prepare_test:
  stage: setup
  script:
    - mix deps.get
    - mix compile
  cache:
    <<: *global_cache
    policy: pull-push

test:
  stage: test
  needs:
    - prepare_test
  services:
    - postgres:latest
  variables:
    POSTGRES_DB: matrix_app_service_test
    POSTGRES_USER: postgres
    POSTGRES_PASSWORD: postgres
    POSTGRES_HOST: postgres
    POSTGRES_HOST_AUTH_METHOD: trust
    MIX_ENV: test
  before_script:
    - mix ecto.create
    - mix ecto.migrate
  script:
    - mix test --cover
  artifacts:
    when: always
    paths:
      - cover
    reports:
      junit: _build/test/lib/matrix_app_service/test-junit-report.xml
      cobertura: coverage.xml

format:
  stage: format
  needs:
    - prepare_test
  script:
    - mix format --check-formatted

credo:
  stage: credo
  needs:
    - prepare_test
  script:
    - mix credo suggest --only readability | tee credo.log
  artifacts:
    when: always
    paths:
      - "credo.log"

dialyzer:
  stage: dialyzer
  needs:
    - prepare_test
  script:
    - mix dialyzer
  cache: 
    <<: *global_cache
    policy: pull-push
    paths:
      - _build
      - deps
      - priv/plts


# Doc generation

prepare_dev:
  stage: setup
  only:
    - master
  variables:
    MIX_ENV: dev
  script:
    - mix deps.get
    - mix compile
  cache:
    <<: *global_cache
    policy: pull-push
    key: cache-dev

pages:
  stage: docs
  only:
    - master
  needs:
    - prepare_dev
  variables:
    MIX_ENV: dev
  script:
    - mix docs -o public
  cache:
    <<: *global_cache
    key: cache-dev
  artifacts:
    paths:
      - public