forked from rubocop/rubocop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.rb
66 lines (54 loc) · 1.44 KB
/
.travis.rb
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
# frozen_string_literal: true
require 'English'
require 'benchmark'
module RubocopTravis
class << self
def run
run_main_task
report_coverage
documentation
check_requiring_libraries
end
private
# Check requiring libraries successfully.
# See https://github.com/bbatsov/rubocop/pull/4523#issuecomment-309136113
def check_requiring_libraries
sh!("ruby -I lib -r rubocop -e 'exit 0'")
end
# Running YARD under jruby crashes so skip checking the manual.
def documentation
return if jruby?
sh!('bundle exec rake documentation_syntax_check generate_cops_documentation')
end
def jruby?
RUBY_ENGINE == 'jruby'
end
def master?
ENV['TRAVIS_BRANCH'] == 'master' && ENV['TRAVIS_PULL_REQUEST'] == 'false'
end
def report_coverage
sh!('bundle exec codeclimate-test-reporter') if master? && test?
end
# Run main task(RSpec or RuboCop).
def run_main_task
if master? || !test? || jruby?
sh!("bundle exec rake #{ENV['TASK']}")
else
sh!("bundle exec rake parallel:#{ENV['TASK']}")
end
end
def sh!(command)
puts "$ #{command}"
time = Benchmark.realtime do
system(command)
end
puts "#{time} seconds"
puts
raise "`#{command}` is failed" unless $CHILD_STATUS.success?
end
def test?
ENV['TASK'] != 'internal_investigation'
end
end
end
RubocopTravis.run