.gitlab-ci.yml 4.19 KB
Newer Older
James Lopez's avatar
James Lopez committed
1
image: "ruby:2.1"
2 3 4 5 6

services:
  - mysql:latest
  - redis:latest

7
cache:
8
  key: "ruby21"
9 10 11
  paths:
  - vendor

12 13
variables:
  MYSQL_ALLOW_EMPTY_PASSWORD: "1"
Kamil Trzcinski's avatar
Kamil Trzcinski committed
14 15
  # retry tests only in CI environment
  RSPEC_RETRY_RETRY_COUNT: "3"
Kamil Trzcinski's avatar
Kamil Trzcinski committed
16 17
  RAILS_ENV: "test"
  SIMPLECOV: "true"
Kamil Trzcinski's avatar
Kamil Trzcinski committed
18
  USE_DB: "true"
19

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
20
before_script:
21
  - source ./scripts/prepare_build.sh
Valery Sizov's avatar
Valery Sizov committed
22
  - cp config/gitlab.yml.example config/gitlab.yml
Kamil Trzcinski's avatar
Test  
Kamil Trzcinski committed
23
  #- retry gem install bundler
Kamil Trzcinski's avatar
Kamil Trzcinski committed
24
  - retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}"
Kamil Trzcinski's avatar
Kamil Trzcinski committed
25
  - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate'
26

Kamil Trzcinski's avatar
Kamil Trzcinski committed
27
stages:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
28
- build
Kamil Trzcinski's avatar
Kamil Trzcinski committed
29 30
- test
- notifications
31

Kamil Trzcinski's avatar
Test  
Kamil Trzcinski committed
32 33
test-bundler:
  stage: build
Kamil Trzcinski's avatar
Test  
Kamil Trzcinski committed
34 35
  variables:
    USE_DB: "false"
Kamil Trzcinski's avatar
Test  
Kamil Trzcinski committed
36
  script:
Kamil Trzcinski's avatar
Test  
Kamil Trzcinski committed
37
    - retry gem install bundler
Kamil Trzcinski's avatar
Test  
Kamil Trzcinski committed
38 39
    - bundle exec bundle --version

Kamil Trzcinski's avatar
Kamil Trzcinski committed
40 41
prepare:
  stage: build
Kamil Trzcinski's avatar
Kamil Trzcinski committed
42 43
  variables:
    USE_DB: "false"
Kamil Trzcinski's avatar
Kamil Trzcinski committed
44 45 46 47 48 49
  script:
    - bundle exec rake assets:precompile
    - echo "{}" > knapsack_rspec_report.json
    - echo "{}" > knapsack_cucumber_report.json
  artifacts:
    paths:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
50
    - public/assets/
Kamil Trzcinski's avatar
Kamil Trzcinski committed
51 52 53
    - knapsack_rspec_report.json
    - knapsack_cucumber_report.json

Kamil Trzcinski's avatar
Kamil Trzcinski committed
54
.knapsack: &knapsack
55 56
  stage: test
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
57 58 59 60
    - JOB_NAME=( $CI_BUILD_NAME )
    - export CI_NODE_INDEX=${JOB_NAME[1]}
    - export CI_NODE_TOTAL=${JOB_NAME[2]}
    - bundle exec rake knapsack:${JOB_NAME[0]}
61

Kamil Trzcinski's avatar
Kamil Trzcinski committed
62
.exec: &exec
63 64
  stage: test
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
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
    - bundle exec $CI_BUILD_NAME

rspec 0 10: *knapsack
rspec 1 10: *knapsack
rspec 2 10: *knapsack
rspec 3 10: *knapsack
rspec 4 10: *knapsack
rspec 5 10: *knapsack
rspec 6 10: *knapsack
rspec 7 10: *knapsack
rspec 8 10: *knapsack
rspec 9 10: *knapsack

spinach 0 10: *knapsack
spinach 1 10: *knapsack
spinach 2 10: *knapsack
spinach 3 10: *knapsack
spinach 4 10: *knapsack
spinach 5 10: *knapsack
spinach 6 10: *knapsack
spinach 7 10: *knapsack
spinach 8 10: *knapsack
spinach 9 10: *knapsack

teaspoon: *exec
rubocop: *exec
rake scss_lint: *exec
rake brakeman: *exec
rake flog: *exec
rake flay: *exec
rake db:migrate:reset: *exec
96 97 98

bundler:audit:
  stage: test
99 100
  only:
    - master
101
  script:
102
    - "bundle exec bundle-audit check --update --ignore OSVDB-115941"
103 104 105 106 107 108 109

# Ruby 2.2 jobs

spec:feature:ruby22:
  stage: test
  image: ruby:2.2
  only:
110
    - master
111
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
112 113
    - bundle exec rake assets:precompile 2>/dev/null
    - bundle exec rake spec:feature
114 115 116 117 118 119 120 121 122 123 124
  cache:
    key: "ruby22"
    paths:
    - vendor

spec:api:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
125
    - bundle exec rake spec:api
126 127 128 129 130 131 132 133 134 135 136
  cache:
    key: "ruby22"
    paths:
    - vendor

spec:models:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
137
    - bundle exec rake spec:models
138 139 140 141 142 143 144 145 146 147 148
  cache:
    key: "ruby22"
    paths:
    - vendor

spec:lib:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
149
    - bundle exec rake spec:lib
150 151 152 153 154 155 156 157 158 159 160
  cache:
    key: "ruby22"
    paths:
    - vendor

spec:services:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
161
    - bundle exec rake spec:services
162 163 164 165 166 167 168 169 170 171 172
  cache:
    key: "ruby22"
    paths:
    - vendor

spec:other:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
173
    - bundle exec rake spec:other
174 175 176 177 178 179 180 181 182 183 184
  cache:
    key: "ruby22"
    paths:
    - vendor

spinach:project:half:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
185 186
    - bundle exec rake assets:precompile 2>/dev/null
    - bundle exec rake spinach:project:half
187 188 189 190 191 192 193 194 195 196 197
  cache:
    key: "ruby22"
    paths:
    - vendor

spinach:project:rest:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
198 199
    - bundle exec rake assets:precompile 2>/dev/null
    - bundle exec rake spinach:project:rest
200 201 202 203 204 205 206 207 208 209 210
  cache:
    key: "ruby22"
    paths:
    - vendor

spinach:other:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
211 212
    - bundle exec rake assets:precompile 2>/dev/null
    - bundle exec rake spinach:other
213 214 215 216
  cache:
    key: "ruby22"
    paths:
    - vendor
217 218 219 220

notify:slack:
  stage: notifications
  script:
James Lopez's avatar
James Lopez committed
221
    - ./scripts/notify_slack.sh "#builds" "Build on \`$CI_BUILD_REF_NAME\` failed! Commit \`$(git log -1 --oneline)\` See <https://gitlab.com/gitlab-org/$(basename "$PWD")/commit/"$CI_BUILD_REF"/builds>"
222 223 224 225 226
  when: on_failure
  only:
    - master@gitlab-org/gitlab-ce
    - tags@gitlab-org/gitlab-ce
    - master@gitlab-org/gitlab-ee
227
    - tags@gitlab-org/gitlab-ee