Commit 059d8263 authored by James Lopez's avatar James Lopez

update ci configuration to send slack notifications on failure and added rake task

parent 49402844
...@@ -19,7 +19,12 @@ before_script: ...@@ -19,7 +19,12 @@ before_script:
- bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" - bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}"
- RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load db:migrate - RAILS_ENV=test bundle exec rake db:drop db:create db:schema:load db:migrate
stages:
- test
- notifications
spec:feature: spec:feature:
stage: test
script: script:
- RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:feature - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:feature
...@@ -28,6 +33,7 @@ spec:feature: ...@@ -28,6 +33,7 @@ spec:feature:
- mysql - mysql
spec:api: spec:api:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:api - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:api
tags: tags:
...@@ -35,6 +41,7 @@ spec:api: ...@@ -35,6 +41,7 @@ spec:api:
- mysql - mysql
spec:models: spec:models:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:models - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:models
tags: tags:
...@@ -42,6 +49,7 @@ spec:models: ...@@ -42,6 +49,7 @@ spec:models:
- mysql - mysql
spec:lib: spec:lib:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:lib - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:lib
tags: tags:
...@@ -49,6 +57,7 @@ spec:lib: ...@@ -49,6 +57,7 @@ spec:lib:
- mysql - mysql
spec:services: spec:services:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:services - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:services
tags: tags:
...@@ -56,6 +65,7 @@ spec:services: ...@@ -56,6 +65,7 @@ spec:services:
- mysql - mysql
spec:benchmark: spec:benchmark:
stage: test
script: script:
- RAILS_ENV=test bundle exec rake spec:benchmark - RAILS_ENV=test bundle exec rake spec:benchmark
tags: tags:
...@@ -64,6 +74,7 @@ spec:benchmark: ...@@ -64,6 +74,7 @@ spec:benchmark:
allow_failure: true allow_failure: true
spec:other: spec:other:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:other - RAILS_ENV=test SIMPLECOV=true bundle exec rake spec:other
tags: tags:
...@@ -71,6 +82,7 @@ spec:other: ...@@ -71,6 +82,7 @@ spec:other:
- mysql - mysql
spinach:project:half: spinach:project:half:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:half - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:half
tags: tags:
...@@ -78,6 +90,7 @@ spinach:project:half: ...@@ -78,6 +90,7 @@ spinach:project:half:
- mysql - mysql
spinach:project:rest: spinach:project:rest:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:rest - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:project:rest
tags: tags:
...@@ -85,6 +98,7 @@ spinach:project:rest: ...@@ -85,6 +98,7 @@ spinach:project:rest:
- mysql - mysql
spinach:other: spinach:other:
stage: test
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach:other
tags: tags:
...@@ -92,6 +106,7 @@ spinach:other: ...@@ -92,6 +106,7 @@ spinach:other:
- mysql - mysql
teaspoon: teaspoon:
stage: test
script: script:
- RAILS_ENV=test bundle exec teaspoon - RAILS_ENV=test bundle exec teaspoon
tags: tags:
...@@ -99,6 +114,7 @@ teaspoon: ...@@ -99,6 +114,7 @@ teaspoon:
- mysql - mysql
rubocop: rubocop:
stage: test
script: script:
- bundle exec rubocop - bundle exec rubocop
tags: tags:
...@@ -106,6 +122,7 @@ rubocop: ...@@ -106,6 +122,7 @@ rubocop:
- mysql - mysql
brakeman: brakeman:
stage: test
script: script:
- bundle exec rake brakeman - bundle exec rake brakeman
tags: tags:
...@@ -113,6 +130,7 @@ brakeman: ...@@ -113,6 +130,7 @@ brakeman:
- mysql - mysql
flog: flog:
stage: test
script: script:
- bundle exec rake flog - bundle exec rake flog
tags: tags:
...@@ -120,6 +138,7 @@ flog: ...@@ -120,6 +138,7 @@ flog:
- mysql - mysql
flay: flay:
stage: test
script: script:
- bundle exec rake flay - bundle exec rake flay
tags: tags:
...@@ -127,6 +146,7 @@ flay: ...@@ -127,6 +146,7 @@ flay:
- mysql - mysql
bundler:audit: bundler:audit:
stage: test
script: script:
- "bundle exec bundle-audit update" - "bundle exec bundle-audit update"
- "bundle exec bundle-audit check" - "bundle exec bundle-audit check"
...@@ -135,9 +155,10 @@ bundler:audit: ...@@ -135,9 +155,10 @@ bundler:audit:
- mysql - mysql
allow_failure: true allow_failure: true
# Ruby 2.1 jobs ## Ruby 2.1 jobs
spec:ruby21: spec:ruby21:
stage: test
image: ruby:2.1 image: ruby:2.1
script: script:
- RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null - RAILS_ENV=test bundle exec rake assets:precompile 2>/dev/null
...@@ -149,6 +170,7 @@ spec:ruby21: ...@@ -149,6 +170,7 @@ spec:ruby21:
- master - master
spinach:ruby21: spinach:ruby21:
stage: test
image: ruby:2.1 image: ruby:2.1
script: script:
- RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach - RAILS_ENV=test SIMPLECOV=true bundle exec rake spinach
...@@ -157,3 +179,12 @@ spinach:ruby21: ...@@ -157,3 +179,12 @@ spinach:ruby21:
- mysql - mysql
only: only:
- master - master
notify:slack:
stage: notifications
script:
- bundle exec rake ci:slack
when: on_failure
# only:
# - master
# - tags
\ No newline at end of file
namespace :ci do
namespace :slack do
desc "GitLab CI | Send slack notification on build failure"
task error: :environment do
error_text = 'Build failed for master/tags'
Kernel.system "curl -X POST --data-urlencode 'payload={\"channel\": \"#ci-test\", \"username\": \"gitlab-ci\", \"text\": \"#{error_text}\", \"icon_emoji\": \":gitlab:\"}' $CI_SLACK_WEBHOOK_URL"
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment