travis-lint 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,7 +20,7 @@ module Travis
20
20
  def self.validate(hsh)
21
21
  hsh = Hashr.new hsh
22
22
 
23
- issues = find_validators_for(hsh[:language]).inject([]) do |acc, val|
23
+ find_validators_for(hsh[:language]).inject([]) do |acc, val|
24
24
  acc << val.call(hsh)
25
25
  acc
26
26
  end.reject(&:first).map { |pair| pair[1] }
@@ -87,24 +87,53 @@ module Travis
87
87
  ("ruby" == hsh[:language].to_s.downcase) && hsh[:rvm].is_a?(Array) && !known_ruby_versions?(hsh[:rvm])
88
88
  end
89
89
 
90
- validator_for :node_js, :node_js, "Detected unsupported Node.js versions. For an up-to-date list of supported Node.js versions, see #{DOCS_URL}" do |hsh|
91
- ("node_js" == hsh[:language].to_s.downcase) && hsh[:node_js].is_a?(Array) && !known_node_js_versions?(hsh[:node_js])
90
+ validator_for :ruby, :language, "Language is set to Ruby but node_js key is present. Ruby builder will ignore node_js key." do |hsh|
91
+ hsh[:language].to_s.downcase == "ruby" && ! blank?(hsh[:node_js])
92
92
  end
93
93
 
94
+
95
+ KNOWN_RUBY_VERSIONS = %w(1.8.7 ruby-1.8.7 1.9.2 ruby-1.9.2 1.9.3 ruby-1.9.3 ruby-head jruby jruby-18mode jruby-19mode rbx rbx-18mode rbx-19mode jruby-head ree ree-1.8.7)
96
+ KNOWN_NODE_VERSIONS = %w(0.4 0.6 0.7)
97
+ KNOWN_PHP_VERSIONS = %w(5.2 5.3 5.3.2 5.3.8 5.4)
98
+
99
+ KNOWN_PYTHON_VERSIONS = %w(2.5 2.6 2.7 3.1 3.2)
100
+ KNOWN_PERL_VERSIONS = %w(5.10 5.12 5.14)
101
+
102
+
103
+ #
104
+ # PHP
105
+ #
106
+
94
107
  validator_for :php, :php, "Detected unsupported PHP versions. For an up-to-date list of supported PHP versions, see #{DOCS_URL}" do |hsh|
95
108
  ("php" == hsh[:language].to_s.downcase) && hsh[:php].is_a?(Array) && !known_php_versions?(hsh[:php])
96
109
  end
97
110
 
111
+ #
112
+ # Python
113
+ #
98
114
 
115
+ validator_for :python, :python, "Detected unsupported Python versions. For an up-to-date list of supported Python versions, see #{DOCS_URL}" do |hsh|
116
+ ("python" == hsh[:language].to_s.downcase) && hsh[:python].is_a?(Array) && !known_python_versions?(hsh[:python])
117
+ end
99
118
 
100
- validator_for :ruby, :language, "Language is set to Ruby but node_js key is present. Ruby builder will ignore node_js key." do |hsh|
101
- hsh[:language].to_s.downcase == "ruby" && ! blank?(hsh[:node_js])
119
+ #
120
+ # Perl
121
+ #
122
+
123
+ validator_for :perl, :perl, "Detected unsupported Perl versions. For an up-to-date list of supported Perl versions, see #{DOCS_URL}" do |hsh|
124
+ ("perl" == hsh[:language].to_s.downcase) && hsh[:perl].is_a?(Array) && !known_perl_versions?(hsh[:perl])
125
+ end
126
+
127
+
128
+ #
129
+ # Node.js
130
+ #
131
+
132
+ validator_for :node_js, :node_js, "Detected unsupported Node.js versions. For an up-to-date list of supported Node.js versions, see #{DOCS_URL}" do |hsh|
133
+ ("node_js" == hsh[:language].to_s.downcase) && hsh[:node_js].is_a?(Array) && !known_node_js_versions?(hsh[:node_js])
102
134
  end
103
135
 
104
136
 
105
- KNOWN_RUBY_VERSIONS = %w(1.8.7 ruby-1.8.7 1.9.2 ruby-1.9.2 1.9.3 ruby-1.9.3 ruby-head jruby jruby-18mode jruby-19mode rbx rbx-18mode rbx-19mode jruby-head ree ree-1.8.7)
106
- KNOWN_NODE_VERSIONS = %w(0.4 0.6 0.7)
107
- KNOWN_PHP_VERSIONS = %w(5.2 5.3 5.3.2 5.3.8 5.4)
108
137
 
109
138
  protected
110
139
 
@@ -129,6 +158,20 @@ module Travis
129
158
  unknown.empty?
130
159
  end
131
160
 
161
+ def self.known_python_versions?(ary)
162
+ ary = ary.map(&:to_s)
163
+
164
+ unknown = ary - KNOWN_PYTHON_VERSIONS
165
+ unknown.empty?
166
+ end
167
+
168
+ def self.known_perl_versions?(ary)
169
+ ary = ary.map(&:to_s)
170
+
171
+ unknown = ary - KNOWN_PERL_VERSIONS
172
+ unknown.empty?
173
+ end
174
+
132
175
  end
133
176
  end
134
177
  end
@@ -32,6 +32,7 @@ module Travis
32
32
  puts
33
33
  puts
34
34
  end
35
+ quit ".travis.yml at #{@travis_file_path} has issues and thus will be ignored by Travis CI."
35
36
  end
36
37
  end
37
38
 
@@ -47,7 +48,7 @@ module Travis
47
48
  def check_that_travis_yml_file_is_valid_yaml!
48
49
  begin
49
50
  YAML.load_file(@travis_file_path)
50
- rescue ArgumentError, Psych::SyntaxError => e
51
+ rescue ArgumentError, Psych::SyntaxError
51
52
  quit ".travis.yml at #{@travis_file_path} is not a valid YAML file and thus will be ignored by Travis CI."
52
53
  end
53
54
  end
@@ -1,6 +1,6 @@
1
1
  module Travis
2
2
  module Lint
3
- VERSION = "1.2.0"
3
+ VERSION = "1.3.0"
4
4
  Version = VERSION
5
5
  end
6
6
  end
@@ -0,0 +1,7 @@
1
+ language: perl
2
+ perl:
3
+ - "5.6"
4
+ - "5.8"
5
+ - "5.10"
6
+ - "5.12"
7
+ - "5.14"
@@ -0,0 +1,7 @@
1
+ language: python
2
+ python:
3
+ - "2.3"
4
+ - "2.4"
5
+ - "2.5"
6
+ - "2.6"
7
+ - "2.7"
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+ require "stringio"
3
+
4
+ def capture_stdout
5
+ $stdout = StringIO.new
6
+ yield
7
+ ensure
8
+ $stdout = STDOUT
9
+ end
10
+
11
+ describe "A .travis.yml" do
12
+ context "with issues" do
13
+ it "run should exit with non-zero exit status" do
14
+ status = 0
15
+
16
+ begin
17
+ capture_stdout do
18
+ Travis::Lint::Runner.new(["spec/files/no_language_key.yml"]).run()
19
+ end
20
+ rescue SystemExit => e
21
+ status = e.status
22
+ end
23
+
24
+ status.should_not == 0
25
+ end
26
+ end
27
+ end
@@ -29,6 +29,9 @@ describe "A .travis.yml" do
29
29
  { :key => :otp_release, :issue => "Specify OTP releases you want to test against using the \"otp_release\" key" }
30
30
  end
31
31
 
32
+ let(:docs) { "Travis CI documentation at http://bit.ly/travis-ci-environment" }
33
+
34
+
32
35
 
33
36
  def content_of_sample_file(name)
34
37
  path = Pathname.new(File.join("spec", "files", name)).expand_path
@@ -105,8 +108,6 @@ describe "A .travis.yml" do
105
108
  end
106
109
 
107
110
 
108
- let(:docs) { "Travis CI documentation at http://bit.ly/travis-ci-environment" }
109
-
110
111
 
111
112
  context "and uses an unsupported Ruby version" do
112
113
  let(:unsupported_rubies) do
@@ -124,6 +125,20 @@ describe "A .travis.yml" do
124
125
  end
125
126
 
126
127
 
128
+ context "that specifies Ruby as the language but tries to set node_js version" do
129
+ let(:travis_yml) do
130
+ { :language => "ruby", :rvm => ["1.9.3"], :node_js => ["0.6"] }
131
+ end
132
+
133
+ it "is invalid" do
134
+ Travis::Lint::Linter.validate(travis_yml).should include({ :key => :language, :issue => "Language is set to Ruby but node_js key is present. Ruby builder will ignore node_js key." })
135
+ end
136
+ end
137
+ end
138
+
139
+
140
+
141
+ context "that has language set to node_js" do
127
142
  context "and uses an unsupported Node.js version" do
128
143
  let(:unsupported_nodejs) do
129
144
  { :key => :node_js, :issue => "Detected unsupported Node.js versions. For an up-to-date list of supported Node.js versions, see #{docs}" }
@@ -138,7 +153,10 @@ describe "A .travis.yml" do
138
153
  Travis::Lint::Linter.valid?(content_of_sample_file("uses_unsupported_nodejs.yml")).should be_false
139
154
  end
140
155
  end
156
+ end
157
+
141
158
 
159
+ context "that has language set to PHP" do
142
160
  context "and uses an unsupported PHP version" do
143
161
  let(:unsupported_php) do
144
162
  { :key => :php, :issue => "Detected unsupported PHP versions. For an up-to-date list of supported PHP versions, see #{docs}" }
@@ -153,19 +171,50 @@ describe "A .travis.yml" do
153
171
  Travis::Lint::Linter.valid?(content_of_sample_file("uses_unsupported_php.yml")).should be_false
154
172
  end
155
173
  end
174
+ end
156
175
 
157
176
 
158
- context "that specifies Ruby as the language but tries to set node_js version" do
177
+
178
+ context "that has language set to Python" do
179
+ context "and uses an unsupported Python version" do
180
+ let(:unsupported_python) do
181
+ { :key => :python, :issue => "Detected unsupported Python versions. For an up-to-date list of supported Python versions, see #{docs}" }
182
+ end
183
+
159
184
  let(:travis_yml) do
160
- { :language => "ruby", :rvm => ["1.9.3"], :node_js => ["0.6"] }
185
+ { :language => "python", :python => ["stackless-py", "2.4", "2.3"] }
161
186
  end
162
187
 
163
188
  it "is invalid" do
164
- Travis::Lint::Linter.validate(travis_yml).should include({ :key => :language, :issue => "Language is set to Ruby but node_js key is present. Ruby builder will ignore node_js key." })
189
+ Travis::Lint::Linter.validate(travis_yml).should include(unsupported_python)
190
+ Travis::Lint::Linter.valid?(content_of_sample_file("uses_unsupported_python.yml")).should be_false
191
+ end
192
+ end
193
+ end
194
+
195
+
196
+
197
+ context "that has language set to Perl" do
198
+ context "and uses an unsupported Perl version" do
199
+ let(:unsupported_perl) do
200
+ { :key => :perl, :issue => "Detected unsupported Perl versions. For an up-to-date list of supported Perl versions, see #{docs}" }
201
+ end
202
+
203
+ let(:travis_yml) do
204
+ { :language => "perl", :perl => ["5.6", "5.8"] }
205
+ end
206
+
207
+ it "is invalid" do
208
+ Travis::Lint::Linter.validate(travis_yml).should include(unsupported_perl)
209
+ Travis::Lint::Linter.valid?(content_of_sample_file("uses_unsupported_perl.yml")).should be_false
165
210
  end
166
211
  end
167
212
  end
168
213
 
214
+
215
+
216
+
217
+
169
218
  context "that has language set to erlang" do
170
219
  context "but has no \"otp_release\" key" do
171
220
  it "is invalid" do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis-lint
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 1.2.0
10
+ version: 1.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael S. Klishin
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-02-17 00:00:00 Z
19
+ date: 2012-03-06 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: hashr
@@ -80,9 +80,12 @@ files:
80
80
  - spec/files/uses_old_rbx_aliases.yml
81
81
  - spec/files/uses_ruby_as_language_but_tries_to_switch_nodejs.yml
82
82
  - spec/files/uses_unsupported_nodejs.yml
83
+ - spec/files/uses_unsupported_perl.yml
83
84
  - spec/files/uses_unsupported_php.yml
85
+ - spec/files/uses_unsupported_python.yml
84
86
  - spec/files/uses_unsupported_rubies.yml
85
87
  - spec/spec_helper.rb
88
+ - spec/travis_lint_runner_spec.rb
86
89
  - spec/travis_lint_spec.rb
87
90
  - travis-lint.gemspec
88
91
  homepage: http://github.com/travis-ci
@@ -118,5 +121,17 @@ rubygems_version: 1.8.15
118
121
  signing_key:
119
122
  specification_version: 3
120
123
  summary: Checks your .travis.yml for possible issues, deprecations and so on
121
- test_files: []
122
-
124
+ test_files:
125
+ - spec/files/no_language_key.yml
126
+ - spec/files/no_rvm_key.yml
127
+ - spec/files/uses_jruby_instead_of_jruby_in_specific_mode.yml
128
+ - spec/files/uses_old_rbx_aliases.yml
129
+ - spec/files/uses_ruby_as_language_but_tries_to_switch_nodejs.yml
130
+ - spec/files/uses_unsupported_nodejs.yml
131
+ - spec/files/uses_unsupported_perl.yml
132
+ - spec/files/uses_unsupported_php.yml
133
+ - spec/files/uses_unsupported_python.yml
134
+ - spec/files/uses_unsupported_rubies.yml
135
+ - spec/spec_helper.rb
136
+ - spec/travis_lint_runner_spec.rb
137
+ - spec/travis_lint_spec.rb