Skip to content

Commit

Permalink
[WIP] Danger bot outputs test failures in detail in PR (#1430)
Browse files Browse the repository at this point in the history
* Add test reporters and danger reports

* Attempt at messaging out each failure from junit

* Update Dangerfile

* Update Dangerfile

* Update Dangerfile

* Update Dangerfile

* Update Dangerfile

* Update Dangerfile

* Update Dangerfile

* Update Dangerfile

* Update Dangerfile

* Update Dangerfile

* Update Dangerfile

* Update Dangerfile

* Update admin_controller_test.rb

Testing additional failure types

* Update admin_controller_test.rb
  • Loading branch information
ananyo2012 authored and jywarren committed Aug 7, 2017
1 parent 96126c2 commit a95ff07
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public/assets/
production.db
test.db
solr/*
test/reports/

# Ignore NPM
node_modules
Expand Down
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ install:
- docker-compose exec web bash -c "rake db:setup"
- docker-compose exec web bash -c "rake db:migrate"
- docker-compose exec web bower install --allow-root
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then gem install danger; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then gem install danger danger-junit; fi'

script:
- docker-compose run -e CI=TRUE web bash -c "rake test:all"
- docker-compose run -e CI=TRUE web bash -c "GENERATE_REPORT=true rake test:all"
- echo -e '<?xml version="1.0" encoding="UTF-8"?>' > output.xml
- tail -n +2 -q ./test/reports/TEST*.xml >> output.xml
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then danger --verbose; fi'
13 changes: 13 additions & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,16 @@ if github.pr_body.include?("* [ ]") && !github.pr_title.include?("[WIP]")
end

message "Pull Request is marked as Work in Progress" if github.pr_title.include? "[WIP]"

junit.parse "output.xml"
junit.failures.collect(&:nodes).flatten.each do |failure|
failure.nodes.each do |f|
match = f.match(/(test[a-z_\/]+.rb):([0-9]+)/)
source_path = match[1]
line = match[2]
if !source_path.nil? && !line.nil?
f = f.gsub(source_path + ':' + line, "<a href='https://github.com/#{github.pr_author}/plots2/tree/#{github.branch_for_head}/#{source_path}#L#{line}'>#{source_path}:#{line}</a>")
end
fail("There was a test failure at: #{f}")
end
end
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ group :development do
end

# run with `bundle install --without test` to exclude these
group :test do
group :test, :development do
gem 'test-unit'
gem 'rake', '~> 10.5.0'
# gems to test RESTful API
Expand All @@ -47,6 +47,7 @@ group :test do
gem 'jasmine-rails'
gem 'jasmine-jquery-rails'
gem 'coveralls', require: false
gem 'ci_reporter_test_unit'
end

# run with `bundle install --without production` to exclude these
Expand Down
6 changes: 6 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ GEM
thread_safe (~> 0.3, >= 0.3.1)
builder (3.0.4)
byebug (9.0.5)
ci_reporter (2.0.0)
builder (>= 2.1.2)
ci_reporter_test_unit (1.0.1)
ci_reporter (~> 2.0)
test-unit (>= 2.5.5, < 4.0)
climate_control (0.0.3)
activesupport (>= 3.0)
cocaine (0.5.8)
Expand Down Expand Up @@ -309,6 +314,7 @@ PLATFORMS
DEPENDENCIES
authlogic (= 3.2.0)
byebug
ci_reporter_test_unit
coffee-rails (~> 3.2.1)
composite_primary_keys
coveralls
Expand Down
6 changes: 5 additions & 1 deletion lib/tasks/test.rake
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# rake test:all
namespace :test do
desc "Run rails and jasmine tests"
task :all do
task :all => :environment do
require 'coveralls/rake/task'
Coveralls::RakeTask.new
if ENV['GENERATE_REPORT'] == 'true'
require 'ci/reporter/rake/test_unit'
Rake::Task["ci:setup:testunit"].execute
end
puts "Running Rails tests"
Rake::Task["test"].execute
puts "Running Solr-dependent tests"
Expand Down

0 comments on commit a95ff07

Please sign in to comment.