GitLab steht Mittwoch, den 23. September, zwischen 10:00 und 12:00 Uhr aufgrund von Wartungsarbeiten nicht zur Verfügung.

.gitlab-ci.yml 5.39 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
  - bundle --version
Kamil Trzcinski's avatar
Kamil Trzcinski committed
24
  - '[ "$USE_BUNDLE_INSTALL" != "true" ] || retry bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}"'
Kamil Trzcinski's avatar
Kamil Trzcinski committed
25
  - retry gem install knapsack
Kamil Trzcinski's avatar
Kamil Trzcinski committed
26
  - '[ "$USE_DB" != "true" ] || bundle exec rake db:drop db:create db:schema:load db:migrate'
27

Kamil Trzcinski's avatar
Kamil Trzcinski committed
28
stages:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
29
- prepare
Kamil Trzcinski's avatar
Kamil Trzcinski committed
30
- test
31
- post-test
Kamil Trzcinski's avatar
Kamil Trzcinski committed
32
- notifications
33

Kamil Trzcinski's avatar
Kamil Trzcinski committed
34
precompile:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
35
  stage: prepare
Kamil Trzcinski's avatar
Kamil Trzcinski committed
36 37
  variables:
    USE_DB: "false"
Kamil Trzcinski's avatar
Kamil Trzcinski committed
38
  script:
Kamil Trzcinski's avatar
WIP  
Kamil Trzcinski committed
39
    - bundle exec rake assets:precompile
Kamil Trzcinski's avatar
Kamil Trzcinski committed
40 41
  artifacts:
    paths:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
42
    - public/assets/
Kamil Trzcinski's avatar
Kamil Trzcinski committed
43 44 45 46 47 48 49 50 51 52 53

.knapsack_state: &knapsack_state
  variables:
    USE_DB: "false"
    USE_BUNDLE_INSTALL: "false"
  cache:
    key: "knapsack"
    paths:
    - knapsack/
  artifacts:
    paths:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
54
    - knapsack/
Kamil Trzcinski's avatar
Kamil Trzcinski committed
55

Kamil Trzcinski's avatar
Kamil Trzcinski committed
56
.knapsack: &knapsack
57 58
  stage: test
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
59 60 61
    - JOB_NAME=( $CI_BUILD_NAME )
    - export CI_NODE_INDEX=${JOB_NAME[1]}
    - export CI_NODE_TOTAL=${JOB_NAME[2]}
Kamil Trzcinski's avatar
Kamil Trzcinski committed
62
    - export KNAPSACK_REPORT_PATH=knapsack/${JOB_NAME}_node_${CI_NODE_INDEX}_${CI_NODE_TOTAL}_report.json
Kamil Trzcinski's avatar
Kamil Trzcinski committed
63
    - export KNAPSACK_GENERATE_REPORT=true
Kamil Trzcinski's avatar
Kamil Trzcinski committed
64 65 66 67 68
    - cp knapsack/${JOB_NAME}_report.json ${KNAPSACK_REPORT_PATH}
    - knapsack ${JOB_NAME[0]}
  artifacts:
    paths:
    - knapsack/
69

Kamil Trzcinski's avatar
Kamil Trzcinski committed
70 71 72 73 74 75 76 77 78 79
knapsack:
  <<: *knapsack_state
  stage: prepare
  script:
    - mkdir -p knapsack/
    - '[[ -f knapsack/rspec_report.json ]] || echo "{}" > knapsack/rspec_report.json'
    - '[[ -f knapsack/spinach_report.json ]] || echo "{}" > knapsack/spinach_report.json'

update-knapsack:
  <<: *knapsack_state
80 81 82 83 84 85
  stage: post-test
  script:
    - scripts/merge-reports knapsack/rspec_report.json knapsack/rspec_node_*.json
    - scripts/merge-reports knapsack/spinach_report.json knapsack/spinach_node_*.json
    - rm -f knapsack/*_node_*.json

Kamil Trzcinski's avatar
Kamil Trzcinski committed
86
.exec: &exec
87 88
  stage: test
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
89 90
    - bundle exec $CI_BUILD_NAME

Kamil Trzcinski's avatar
Kamil Trzcinski committed
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
rspec 0 20: *knapsack
rspec 1 20: *knapsack
rspec 2 20: *knapsack
rspec 3 20: *knapsack
rspec 4 20: *knapsack
rspec 5 20: *knapsack
rspec 6 20: *knapsack
rspec 7 20: *knapsack
rspec 8 20: *knapsack
rspec 9 20: *knapsack
rspec 10 20: *knapsack
rspec 11 20: *knapsack
rspec 12 20: *knapsack
rspec 13 20: *knapsack
rspec 14 20: *knapsack
rspec 15 20: *knapsack
rspec 16 20: *knapsack
rspec 17 20: *knapsack
rspec 18 20: *knapsack
rspec 19 20: *knapsack
Kamil Trzcinski's avatar
Kamil Trzcinski committed
111

Kamil Trzcinski's avatar
Kamil Trzcinski committed
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
spinach 0 20: *knapsack
spinach 1 20: *knapsack
spinach 2 20: *knapsack
spinach 3 20: *knapsack
spinach 4 20: *knapsack
spinach 5 20: *knapsack
spinach 6 20: *knapsack
spinach 7 20: *knapsack
spinach 8 20: *knapsack
spinach 9 20: *knapsack
spinach 10 20: *knapsack
spinach 11 20: *knapsack
spinach 12 20: *knapsack
spinach 13 20: *knapsack
spinach 14 20: *knapsack
spinach 15 20: *knapsack
spinach 16 20: *knapsack
spinach 17 20: *knapsack
spinach 18 20: *knapsack
spinach 19 20: *knapsack
Kamil Trzcinski's avatar
Kamil Trzcinski committed
132 133 134 135 136 137 138 139

teaspoon: *exec
rubocop: *exec
rake scss_lint: *exec
rake brakeman: *exec
rake flog: *exec
rake flay: *exec
rake db:migrate:reset: *exec
140 141 142

bundler:audit:
  stage: test
143 144
  only:
    - master
145
  script:
146
    - "bundle exec bundle-audit check --update --ignore OSVDB-115941"
147 148 149 150 151 152 153

# Ruby 2.2 jobs

spec:feature:ruby22:
  stage: test
  image: ruby:2.2
  only:
154
    - master
155
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
156 157
    - bundle exec rake assets:precompile 2>/dev/null
    - bundle exec rake spec:feature
158 159 160 161 162 163 164 165 166 167 168
  cache:
    key: "ruby22"
    paths:
    - vendor

spec:api:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
169
    - bundle exec rake spec:api
170 171 172 173 174 175 176 177 178 179 180
  cache:
    key: "ruby22"
    paths:
    - vendor

spec:models:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
181
    - bundle exec rake spec:models
182 183 184 185 186 187 188 189 190 191 192
  cache:
    key: "ruby22"
    paths:
    - vendor

spec:lib:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
193
    - bundle exec rake spec:lib
194 195 196 197 198 199 200 201 202 203 204
  cache:
    key: "ruby22"
    paths:
    - vendor

spec:services:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
205
    - bundle exec rake spec:services
206 207 208 209 210 211 212 213 214 215 216
  cache:
    key: "ruby22"
    paths:
    - vendor

spec:other:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
217
    - bundle exec rake spec:other
218 219 220 221 222 223 224 225 226 227 228
  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
229 230
    - bundle exec rake assets:precompile 2>/dev/null
    - bundle exec rake spinach:project:half
231 232 233 234 235 236 237 238 239 240 241
  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
242 243
    - bundle exec rake assets:precompile 2>/dev/null
    - bundle exec rake spinach:project:rest
244 245 246 247 248 249 250 251 252 253 254
  cache:
    key: "ruby22"
    paths:
    - vendor

spinach:other:ruby22:
  stage: test
  image: ruby:2.2
  only:
  - master
  script:
Kamil Trzcinski's avatar
Kamil Trzcinski committed
255 256
    - bundle exec rake assets:precompile 2>/dev/null
    - bundle exec rake spinach:other
257 258 259 260
  cache:
    key: "ruby22"
    paths:
    - vendor
261 262 263 264

notify:slack:
  stage: notifications
  script:
James Lopez's avatar
James Lopez committed
265
    - ./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>"
266 267 268 269 270
  when: on_failure
  only:
    - master@gitlab-org/gitlab-ce
    - tags@gitlab-org/gitlab-ce
    - master@gitlab-org/gitlab-ee
271
    - tags@gitlab-org/gitlab-ee