travis-lint 1.8.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c90e5a5967d9959dbb6679288e5268f47b9cb9b5
4
- data.tar.gz: 25d78a63add59c86018b58d2394ba23613656875
3
+ metadata.gz: 0caba50cb092c71ffae98a0aa63a3c707065f94d
4
+ data.tar.gz: c436f7b7bb4d5bb1168e1084f6c1ab7fd4464a85
5
5
  SHA512:
6
- metadata.gz: 6eed0e5956ff097a76f34fb935612c33101ca3f8f2afe993f62307946f427c7d36eabb824eff32930301dab16234158c1b201c3c6c3271b7fcbe1f79994ce34a
7
- data.tar.gz: 834b2b41ffd8f1e23d36bca9a864d8e3b0733959f6edeb1cbc2c98327094da3c0af74653606512b41eb13549203662e8cff770636e092098629fc627de6b3126
6
+ metadata.gz: 92bb27047fafb37c40d136644048130339ff6a195b7e7c4828b29b918173b89f0475ec2d1d6de56a1cd73e27290933abaf7597e1cd84cea0324ec3b4a559fc02
7
+ data.tar.gz: a4f36c68ba75ae83af8adf4e802cbe090bc41c2a1e915ccfd332bc8c2eede603315c148aa1dc25354a76275de27994435312f2d862b471b23707b472f98051f9
@@ -1,31 +1,24 @@
1
1
  #!/usr/bin/env ruby
2
-
3
- begin
4
- require 'travis/lint'
5
-
6
- runner = Travis::Lint::Runner.new(ARGV)
7
- runner.run
8
- rescue LoadError => e
9
- $stderr.puts <<-EOS
10
- #{'*'*50}
11
- Could not find 'travis/lint'
12
-
13
- This may happen if you're using rubygems as your package manager, but it is not
14
- being required through some mechanism before executing the travis-lint command.
15
-
16
- You may need to do one of the following in your shell:
17
-
18
- # for bash/zsh
19
- export RUBYOPT=rubygems
20
-
21
- # for csh, etc.
22
- set RUBYOPT=rubygems
23
-
24
- For background, please see http://gist.github.com/54177.
25
- #{'*'*50}
26
- EOS
27
-
28
- raise e
29
-
30
- exit(1)
2
+ require 'timeout'
3
+
4
+ Timeout.timeout(5) do
5
+ require 'uri'
6
+ require 'net/https'
7
+ require 'json'
8
+
9
+ path = ARGV[0] || '.travis.yml'
10
+ http = Net::HTTP.new('api.travis-ci.org', 443)
11
+ http.use_ssl = true
12
+ request = Net::HTTP::Post.new('/lint')
13
+ request.body = path == '-' ? $stdin.read : File.read(path)
14
+ response = http.request(request)
15
+
16
+ response.value
17
+ warnings = JSON.load(response.body)['lint']['warnings']
18
+ warnings.reverse.each do |warning|
19
+ prefix = " " << warning['key'].join('.') << ":" if warning['key'].any?
20
+ puts "-#{prefix} #{warning['message']}"
21
+ end
22
+
23
+ exit 1 if warnings.any?
31
24
  end
metadata CHANGED
@@ -1,99 +1,40 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: travis-lint
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Michael S. Klishin
8
- - Travis CI Development Team
7
+ - Travis CI GmbH
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-03-13 00:00:00.000000000 Z
11
+ date: 2014-07-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: hashr
14
+ name: json
16
15
  requirement: !ruby/object:Gem::Requirement
17
16
  requirements:
18
- - - "~>"
17
+ - - ">="
19
18
  - !ruby/object:Gem::Version
20
- version: 0.0.22
19
+ version: '0'
21
20
  type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
- - - "~>"
24
+ - - ">="
26
25
  - !ruby/object:Gem::Version
27
- version: 0.0.22
28
- - !ruby/object:Gem::Dependency
29
- name: safe_yaml
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - "~>"
33
- - !ruby/object:Gem::Version
34
- version: 0.9.0
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - "~>"
40
- - !ruby/object:Gem::Version
41
- version: 0.9.0
42
- - !ruby/object:Gem::Dependency
43
- name: rspec
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - "~>"
47
- - !ruby/object:Gem::Version
48
- version: '2.8'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - "~>"
54
- - !ruby/object:Gem::Version
55
- version: '2.8'
56
- description: travis-lint is a tool that check your .travis.yml for possible issues,
57
- deprecations and so on. Recommended for all travis-ci.org users.
58
- email:
59
- - michaelklishin@me.com
60
- - michael@novemberain.com
26
+ version: '0'
27
+ description: 'DEPRECATED: Use `travis lint` (from travis gem) instead'
28
+ email: support@travis-ci.com
61
29
  executables:
62
30
  - travis-lint
63
31
  extensions: []
64
32
  extra_rdoc_files: []
65
33
  files:
66
- - ".gitignore"
67
- - ".rspec"
68
- - ".travis.yml"
69
- - Gemfile
70
- - LICENSE
71
- - README.md
72
34
  - bin/travis-lint
73
- - lib/travis/lint.rb
74
- - lib/travis/lint/dsl.rb
75
- - lib/travis/lint/linter.rb
76
- - lib/travis/lint/runner.rb
77
- - lib/travis/lint/validator.rb
78
- - lib/travis/lint/version.rb
79
- - spec/files/contains_exploit.yml
80
- - spec/files/invalid_language_key.yml
81
- - spec/files/no_language_key.yml
82
- - spec/files/no_rvm_key.yml
83
- - spec/files/uses_jruby_instead_of_jruby_in_specific_mode.yml
84
- - spec/files/uses_old_rbx_aliases.yml
85
- - spec/files/uses_ruby_as_language_but_tries_to_switch_nodejs.yml
86
- - spec/files/uses_unsupported_nodejs.yml
87
- - spec/files/uses_unsupported_perl.yml
88
- - spec/files/uses_unsupported_php.yml
89
- - spec/files/uses_unsupported_python.yml
90
- - spec/files/uses_unsupported_rubies.yml
91
- - spec/spec_helper.rb
92
- - spec/travis_lint_runner_spec.rb
93
- - spec/travis_lint_spec.rb
94
- - travis-lint.gemspec
95
- homepage: http://github.com/travis-ci
96
- licenses: []
35
+ homepage: https://travis-ci.com
36
+ licenses:
37
+ - MIT
97
38
  metadata: {}
98
39
  post_install_message:
99
40
  rdoc_options: []
@@ -115,19 +56,5 @@ rubygems_version: 2.2.2
115
56
  signing_key:
116
57
  specification_version: 4
117
58
  summary: Checks your .travis.yml for possible issues, deprecations and so on
118
- test_files:
119
- - spec/files/contains_exploit.yml
120
- - spec/files/invalid_language_key.yml
121
- - spec/files/no_language_key.yml
122
- - spec/files/no_rvm_key.yml
123
- - spec/files/uses_jruby_instead_of_jruby_in_specific_mode.yml
124
- - spec/files/uses_old_rbx_aliases.yml
125
- - spec/files/uses_ruby_as_language_but_tries_to_switch_nodejs.yml
126
- - spec/files/uses_unsupported_nodejs.yml
127
- - spec/files/uses_unsupported_perl.yml
128
- - spec/files/uses_unsupported_php.yml
129
- - spec/files/uses_unsupported_python.yml
130
- - spec/files/uses_unsupported_rubies.yml
131
- - spec/spec_helper.rb
132
- - spec/travis_lint_runner_spec.rb
133
- - spec/travis_lint_spec.rb
59
+ test_files: []
60
+ has_rdoc:
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- #~
2
- *.gem
3
- *.swp
4
- *~
5
- .DS_Store
6
- /.rvmrc
7
- /Gemfile.lock
8
- /TAGS
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --format
3
- progress
@@ -1,24 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.2
4
- - 1.9.3
5
- - 2.0.0
6
- - jruby-18mode
7
- - jruby-19mode
8
- - rbx
9
- - jruby-head
10
- - ruby-head
11
- - 1.8.7
12
- matrix:
13
- allow_failures:
14
- - rvm: jruby-head
15
- - rvm: ruby-head
16
- before_install:
17
- - 'ruby -e ''puts RUBY_VERSION'' | grep ^1\.8 && gem update --system 2.1.11 || true'
18
- script: bundle exec rspec -c spec
19
- notifications:
20
- irc: "irc.freenode.org#travis"
21
- email:
22
- recepients:
23
- - michaelklishin@me.com
24
-
data/Gemfile DELETED
@@ -1,7 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- gemspec
4
-
5
- platforms :rbx do
6
- gem 'rubysl', '~> 2.0'
7
- end
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- MIT LICENSE
2
-
3
- Copyright (c) 2012 Travis CI Development Team <contact@travis-ci.org>
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
22
-
data/README.md DELETED
@@ -1,38 +0,0 @@
1
- # What is travis-lint
2
-
3
- `travis-lint` is a tool that checks your `.travis.yml` file for possible issues, deprecations and so on.
4
- Supporting the gem, there's also an online version of this tool at [lint.travis-ci.org](http://lint.travis-ci.org).
5
-
6
- [![Continuous Integration status](https://secure.travis-ci.org/travis-ci/travis-lint.png)](http://travis-ci.org/travis-ci/travis-lint)
7
-
8
-
9
- ## Installation
10
-
11
- gem install travis-lint
12
-
13
-
14
- ## Usage
15
-
16
- travis-lint # inside a dir with .travis.yml
17
- travis-lint ./.travis.yml
18
- travis-lint ~/your/project/.travis.yml
19
-
20
-
21
- ## Development
22
-
23
- Install dependencies with
24
-
25
- bundle install
26
-
27
- then run tests with
28
-
29
- bundle exec rspec spec
30
-
31
- Once you are done with your changes, push a branch and submit a pull request.
32
-
33
-
34
- ## License & Copyright
35
-
36
- Copyright 2014 (c) Travis CI Development Team.
37
-
38
- Released under the MIT license.
@@ -1,4 +0,0 @@
1
- require "travis/lint/version"
2
-
3
- require "travis/lint/runner"
4
- require "travis/lint/linter"
@@ -1,32 +0,0 @@
1
- require "travis/lint/validator"
2
-
3
- module Travis
4
- module Lint
5
- module DSL
6
- def blank? object
7
- # This implementation is based on rails' activesupport. It is used
8
- # under the MIT license.
9
- object.respond_to?(:empty?) ? object.empty? : !object
10
- end
11
-
12
- @@validators = []
13
-
14
- def validator_for(language, key, message, &validator)
15
- @@validators << Validator.new(language, key, message, validator)
16
- end
17
-
18
-
19
- def validators_for_language(language)
20
- @@validators.select { |v| v.language.to_s.downcase == language.to_s.downcase }
21
- end
22
-
23
- def generic_validators
24
- @@validators.select { |v| v.language.to_s.downcase == :all.to_s }
25
- end
26
-
27
- def find_validators_for(language)
28
- generic_validators + validators_for_language(language)
29
- end
30
- end
31
- end
32
- end
@@ -1,185 +0,0 @@
1
- require "travis/lint/dsl"
2
-
3
- require "hashr"
4
-
5
- module Travis
6
- module Lint
7
- class Linter
8
-
9
- #
10
- # Behaviors
11
- #
12
-
13
- extend Lint::DSL
14
-
15
-
16
- #
17
- # API
18
- #
19
-
20
- def self.validate(hsh)
21
- hsh = Hashr.new hsh
22
-
23
- find_validators_for(hsh[:language]).inject([]) do |acc, val|
24
- acc << val.call(hsh)
25
- acc
26
- end.reject(&:first).map { |pair| pair[1] }
27
- end
28
-
29
- def self.valid?(hsh)
30
- validate(hsh).empty?
31
- end
32
-
33
- #
34
- # Erlang
35
- #
36
-
37
- validator_for :erlang, :otp_release, "Specify OTP releases you want to test against using the \"otp_release\" key" do |hsh|
38
- hsh[:language].to_s.downcase == "erlang" && blank?(hsh[:otp_release])
39
- end
40
-
41
-
42
- #
43
- # Ruby
44
- #
45
-
46
- validator_for :ruby, :rvm, "Specify Ruby versions/implementations you want to test against using the \"rvm\" key" do |hsh|
47
- hsh[:language].to_s.downcase == "ruby" && blank?(hsh[:rvm])
48
- end
49
-
50
- validator_for :ruby, :rvm, "Prefer jruby-18mode RVM alias to jruby" do |hsh|
51
- hsh[:rvm].is_a?(Array) && hsh[:rvm].include?("jruby")
52
- end
53
-
54
- validator_for :ruby, :rvm, "rbx-18mode RVM alias is no longer provide. Please use one of rbx, rbx-X, rbx-X.Y, or rbx-X.Y.Z depending on your desired version" do |hsh|
55
- hsh[:rvm].is_a?(Array) && hsh[:rvm].include?("rbx-18mode")
56
- end
57
-
58
- validator_for :ruby, :rvm, "rbx-19mode RVM alias is no longer provide. Please use one of rbx, rbx-X, rbx-X.Y, or rbx-X.Y.Z depending on your desired version" do |hsh|
59
- hsh[:rvm].is_a?(Array) && hsh[:rvm].include?("rbx-19mode")
60
- end
61
-
62
- validator_for :ruby, :rvm, "rbx-2.0.0pre RVM alias is no longer provided. Please use one of rbx, rbx-X, rbx-X.Y, or rbx-X.Y.Z depending on your desired version" do |hsh|
63
- hsh[:rvm].is_a?(Array) && hsh[:rvm].include?("rbx-2.0.0pre")
64
- end
65
-
66
- validator_for :ruby, :rvm, "Ruby 1.9.1 is no longer maintained and is no longer provided on travis-ci.org. Please move to 1.9.3." do |hsh|
67
- hsh[:rvm].is_a?(Array) && hsh[:rvm].include?("1.9.1")
68
- end
69
-
70
- validator_for :ruby, :rvm, "Ruby 1.8.6 is no longer maintained and is no longer provided on travis-ci.org. Please move to 1.8.7." do |hsh|
71
- hsh[:rvm].is_a?(Array) && hsh[:rvm].include?("1.8.6")
72
- end
73
-
74
- DOCS_URL = "Travis CI documentation at http://bit.ly/travis-ci-environment"
75
-
76
- validator_for :ruby, :rvm, "Detected unsupported Ruby versions. For an up-to-date list of supported Rubies, see #{DOCS_URL}" do |hsh|
77
- ("ruby" == hsh[:language].to_s.downcase) && hsh[:rvm].is_a?(Array) && !known_ruby_versions?(hsh[:rvm])
78
- end
79
-
80
- validator_for :ruby, :language, "Language is set to Ruby but node_js key is present. Ruby builder will ignore node_js key." do |hsh|
81
- hsh[:language].to_s.downcase == "ruby" && ! blank?(hsh[:node_js])
82
- end
83
-
84
-
85
- 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 2.0.0 ruby-2.0.0 2.1.0 ruby-2.1.0 2.1.1 ruby-2.1.1 ruby-head jruby jruby-18mode jruby-19mode rbx rbx-18mode rbx-19mode jruby-head ree ree-1.8.7 2.1.0-preview2 ruby-2.1.0-preview2 2.1.0-preview1 ruby-2.1.0-preview1 ree-1.8.7-2011.12)
86
- KNOWN_NODE_VERSIONS = %w(0.6 0.8 0.9 0.10 0.11)
87
- KNOWN_PHP_VERSIONS = %w(5.2 5.3 5.3.3 5.4 5.5 5.6 hhvm)
88
-
89
- KNOWN_PYTHON_VERSIONS = %w(2.6 2.7 3.2 3.3 pypy)
90
- KNOWN_PERL_VERSIONS = %w(5.8 5.10 5.12 5.14 5.16 5.18 5.19)
91
-
92
-
93
- #
94
- # PHP
95
- #
96
-
97
- validator_for :php, :php, "Detected unsupported PHP versions. For an up-to-date list of supported PHP versions, see #{DOCS_URL}" do |hsh|
98
- ("php" == hsh[:language].to_s.downcase) && hsh[:php].is_a?(Array) && !known_php_versions?(hsh[:php])
99
- end
100
-
101
- #
102
- # Python
103
- #
104
-
105
- validator_for :python, :python, "Detected unsupported Python versions. For an up-to-date list of supported Python versions, see #{DOCS_URL}" do |hsh|
106
- ("python" == hsh[:language].to_s.downcase) && hsh[:python].is_a?(Array) && !known_python_versions?(hsh[:python])
107
- end
108
-
109
- #
110
- # Perl
111
- #
112
-
113
- validator_for :perl, :perl, "Detected unsupported Perl versions. For an up-to-date list of supported Perl versions, see #{DOCS_URL}" do |hsh|
114
- ("perl" == hsh[:language].to_s.downcase) && hsh[:perl].is_a?(Array) && !known_perl_versions?(hsh[:perl])
115
- end
116
-
117
-
118
- #
119
- # Node.js
120
- #
121
-
122
- 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|
123
- ("node_js" == hsh[:language].to_s.downcase) && hsh[:node_js].is_a?(Array) && !known_node_js_versions?(hsh[:node_js])
124
- end
125
-
126
- validator_for :all, :matrix, "Allowed matrix failures must contain a list of hashes." do |hash|
127
- if hash[:matrix] && hash[:matrix].is_a?(Hash) && hash[:matrix][:allow_failures]
128
- !hash[:matrix][:allow_failures].any?{|failure| failure.is_a?(Hash)}
129
- end
130
- end
131
-
132
- validator_for :all, :matrix, "Matrix includes must be a list of hashes." do |hash|
133
- if hash[:matrix] && hash[:matrix].is_a?(Hash) && hash[:matrix][:include]
134
- !hash[:matrix][:include].any?{|failure| failure.is_a?(Hash)}
135
- end
136
- end
137
-
138
- validator_for :all, :matrix, "Matrix must be a hash." do |hash|
139
- !(hash[:matrix].nil? || hash[:matrix].is_a?(Hash))
140
- end
141
-
142
- validator_for :all, :language, "Language must be valid" do |hash|
143
- hash.has_key?(:language) && validators_for_language(hash[:language]).empty?
144
- end
145
-
146
- protected
147
-
148
- def self.known_ruby_versions?(ary)
149
- ary = ary.map(&:to_s)
150
-
151
- unknown = ary - KNOWN_RUBY_VERSIONS
152
- unknown.empty?
153
- end
154
-
155
- def self.known_node_js_versions?(ary)
156
- ary = ary.map(&:to_s)
157
-
158
- unknown = ary - KNOWN_NODE_VERSIONS
159
- unknown.empty?
160
- end
161
-
162
- def self.known_php_versions?(ary)
163
- ary = ary.map(&:to_s)
164
-
165
- unknown = ary - KNOWN_PHP_VERSIONS
166
- unknown.empty?
167
- end
168
-
169
- def self.known_python_versions?(ary)
170
- ary = ary.map(&:to_s)
171
-
172
- unknown = ary - KNOWN_PYTHON_VERSIONS
173
- unknown.empty?
174
- end
175
-
176
- def self.known_perl_versions?(ary)
177
- ary = ary.map(&:to_s)
178
-
179
- unknown = ary - KNOWN_PERL_VERSIONS
180
- unknown.empty?
181
- end
182
-
183
- end
184
- end
185
- end
@@ -1,87 +0,0 @@
1
- require "pathname"
2
- require "safe_yaml"
3
-
4
- require "travis/lint/linter"
5
-
6
- module Travis
7
- module Lint
8
-
9
- class Runner
10
- def initialize(argv)
11
- if argv.empty?
12
- if File.exists?(".travis.yml")
13
- argv = [".travis.yml"]
14
- else
15
- show_help
16
- end
17
- end
18
-
19
- @quiet = !!ENV['QUIET']
20
-
21
- @travis_yml_file_paths = []
22
- argv.each do |arg|
23
- @travis_yml_file_paths << Pathname.new(arg).expand_path
24
- end
25
- end
26
-
27
-
28
- def run
29
- errors = false
30
- @travis_yml_file_paths.each do |travis_yml_file_path|
31
- check_that_travis_yml_file_exists!(travis_yml_file_path)
32
- check_that_travis_yml_file_is_valid_yaml!(travis_yml_file_path)
33
-
34
- if (issues = Linter.validate(self.parsed_travis_yml(travis_yml_file_path))).empty?
35
- unless @quiet
36
- puts "Hooray, #{travis_yml_file_path} seems to be solid!\n"
37
- end
38
- else
39
- errors = true
40
- $stderr.puts "#{travis_yml_file_path} has issues:"
41
- issues.each do |issue|
42
- $stderr.puts " Found an issue with the `#{issue[:key]}:` key:\n #{issue[:issue]}"
43
- end
44
- $stderr.puts
45
- end
46
- end
47
- exit(1) if errors
48
- exit(0)
49
- end
50
-
51
- protected
52
-
53
- def check_that_travis_yml_file_exists!(travis_yml_file_path)
54
- quit("Cannot read #{travis_yml_file_path}: file does not exist or is not readable") unless File.exists?(travis_yml_file_path) &&
55
- File.file?(travis_yml_file_path) &&
56
- File.readable?(travis_yml_file_path)
57
- end
58
-
59
- def check_that_travis_yml_file_is_valid_yaml!(travis_yml_file_path)
60
- begin
61
- YAML.load_file travis_yml_file_path, :safe => true
62
- rescue ArgumentError, Psych::SyntaxError => e
63
- quit "#{travis_yml_file_path} is not a valid YAML file and thus will be ignored by Travis CI.\nError message: #{e.message}"
64
- end
65
- end
66
-
67
- def parsed_travis_yml(travis_yml_file_path)
68
- YAML.load_file travis_yml_file_path, :safe => true
69
- end
70
-
71
- def show_help
72
- puts <<-EOS
73
- Usage:
74
-
75
- travis-lint [path to your .travis.yml]
76
- EOS
77
-
78
- exit(1)
79
- end
80
-
81
- def quit(message, status = 1)
82
- $stderr.puts message
83
- exit(status)
84
- end
85
- end
86
- end
87
- end
@@ -1,15 +0,0 @@
1
- module Travis
2
- module Lint
3
- module DSL
4
- class Validator < Struct.new(:language, :key, :message, :validator)
5
- def call(hash)
6
- if self.validator.call(hash)
7
- [false, { :key => self.key, :issue => self.message }]
8
- else
9
- [true, {}]
10
- end
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,6 +0,0 @@
1
- module Travis
2
- module Lint
3
- VERSION = "1.8.0"
4
- Version = VERSION
5
- end
6
- end
@@ -1,4 +0,0 @@
1
- --- !ruby/object
2
- table:
3
- :backdoor: !ruby/hash:ExploitableClassBuilder
4
- "foo; end; raise %(I'm in yr system!); def bar": "baz"
@@ -1,17 +0,0 @@
1
- language: foo
2
- rvm:
3
- - 1.9.3
4
- - jruby-19mode
5
- - rbx
6
- gemfile:
7
- - Gemfile
8
- - gemfiles/eventmachine-pre
9
- notifications:
10
- recipients:
11
- - recepient@example.com
12
- branches:
13
- only:
14
- - master
15
- - 0.9.x-stable
16
- - 0.8.x-stable
17
- - 0.7.x-stable
@@ -1,16 +0,0 @@
1
- rvm:
2
- - 1.9.3
3
- - jruby-19mode
4
- - rbx
5
- gemfile:
6
- - Gemfile
7
- - gemfiles/eventmachine-pre
8
- notifications:
9
- recipients:
10
- - recepient@example.com
11
- branches:
12
- only:
13
- - master
14
- - 0.9.x-stable
15
- - 0.8.x-stable
16
- - 0.7.x-stable
@@ -1 +0,0 @@
1
- language: ruby
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - jruby
4
- - rbx-2.0.0
@@ -1,5 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.8.7
4
- - rbx-2.0
5
- - rbx-2.0.0pre
@@ -1,5 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
- node_js:
5
- - 0.6
@@ -1,5 +0,0 @@
1
- language: node_js
2
- node_js:
3
- - 0.5
4
- - 110.00
5
- - node-webscale
@@ -1,7 +0,0 @@
1
- language: perl
2
- perl:
3
- - "5.6"
4
- - "5.8"
5
- - "5.10"
6
- - "5.12"
7
- - "5.14"
@@ -1,5 +0,0 @@
1
- language: php
2
- php:
3
- - 0.5
4
- - 6.0
5
- - jphp
@@ -1,7 +0,0 @@
1
- language: python
2
- python:
3
- - "2.3"
4
- - "2.4"
5
- - "2.5"
6
- - "2.6"
7
- - "2.7"
@@ -1,5 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - rubizilla
4
- - ruby-1.8.7-p248
5
- - goruby
@@ -1,11 +0,0 @@
1
- # encoding: binary
2
- require "pathname"
3
-
4
- require 'bundler'
5
- Bundler.setup(:default, :test)
6
-
7
- require 'rspec'
8
-
9
-
10
- $: << File.expand_path('../../lib', __FILE__)
11
- require "travis/lint"
@@ -1,100 +0,0 @@
1
- require "spec_helper"
2
- require "stringio"
3
-
4
- def capture
5
- status = nil
6
- $stdout = out = StringIO.new
7
- $stderr = err = StringIO.new
8
-
9
- begin
10
- yield
11
- rescue SystemExit => e
12
- status = e.status
13
- ensure
14
- $stdout = STDOUT
15
- $stderr = STDERR
16
- end
17
-
18
- err.rewind
19
- out.rewind
20
- return out.read || '', err.read || '', status
21
- end
22
-
23
- class ExploitableClassBuilder
24
- def []=(key, value)
25
- Class.new.class_eval <<-EOS
26
- def #{key}
27
- #{value}
28
- end
29
- EOS
30
- end
31
- end
32
-
33
- describe "A .travis.yml" do
34
- context "with issues" do
35
- it "run should exit with non-zero exit status" do
36
- _, _, status = capture do
37
- Travis::Lint::Runner.new(["spec/files/uses_unsupported_perl.yml"]).run
38
- end
39
-
40
- status.should_not == 0
41
- end
42
-
43
- it "run should report errors to $stderr" do
44
- _, err, _ = capture do
45
- Travis::Lint::Runner.new(["spec/files/uses_unsupported_perl.yml"]).run
46
- end
47
-
48
- err.chomp.should =~ /Found an issue with the `perl:` key:/
49
- end
50
-
51
- it "run should not report errors to $stdout" do
52
- out, _, _ = capture do
53
- Travis::Lint::Runner.new(["spec/files/uses_unsupported_perl.yml"]).run
54
- end
55
-
56
- out.chomp.should == ''
57
- end
58
- end
59
-
60
- context "without issues" do
61
- it "run should exit with zero exit status" do
62
- _, _, status = capture do
63
- Travis::Lint::Runner.new([".travis.yml"]).run
64
- end
65
-
66
- status.should == 0
67
- end
68
-
69
- it "run should report success to $stdout" do
70
- out, _, _ = capture do
71
- Travis::Lint::Runner.new([".travis.yml"]).run
72
- end
73
-
74
- out.chomp.should =~ /Hooray.*\.travis\.yml seems to be solid!/
75
- end
76
-
77
- context "with $QUIET set" do
78
- before { ENV['QUIET'] = '1' }
79
- after { ENV['QUIET'] = nil }
80
-
81
- it "run should be silent" do
82
- out, _, _ = capture do
83
- Travis::Lint::Runner.new([".travis.yml"]).run
84
- end
85
-
86
- out.chomp.should == ''
87
- end
88
- end
89
- end
90
-
91
- context "with an exploit" do
92
- it "loads safely" do
93
- expect {
94
- capture {
95
- Travis::Lint::Runner.new(["spec/files/contains_exploit.yml"]).run
96
- }
97
- }.to_not raise_error
98
- end
99
- end
100
- end
@@ -1,275 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe "A .travis.yml" do
4
- let(:language_key_is_mandatory) do
5
- { :key => :language, :issue => "The \"language\" key is mandatory" }
6
- end
7
-
8
- let(:rvm_key_is_recommended) do
9
- { :key => :rvm, :issue => "Specify Ruby versions/implementations you want to test against using the \"rvm\" key" }
10
- end
11
-
12
- let(:prefer_jruby18mode_over_jruby) do
13
- { :key => :rvm, :issue => "Prefer jruby-18mode RVM alias to jruby" }
14
- end
15
-
16
- let(:rbx18mode_is_no_longer_provided) do
17
- { :key => :rvm, :issue => "rbx-18mode RVM alias is no longer provide. Please use one of rbx, rbx-X, rbx-X.Y, or rbx-X.Y.Z depending on your desired version" }
18
- end
19
-
20
- let(:rbx19mode_is_no_longer_provided) do
21
- { :key => :rvm, :issue => "rbx-19mode RVM alias is no longer provide. Please use one of rbx, rbx-X, rbx-X.Y, or rbx-X.Y.Z depending on your desired version" }
22
- end
23
-
24
- let(:rbx200pre_is_no_longer_provided) do
25
- { :key => :rvm, :issue => "rbx-2.0.0pre RVM alias is no longer provided. Please use one of rbx, rbx-X, rbx-X.Y, or rbx-X.Y.Z depending on your desired version" }
26
- end
27
-
28
- let(:otp_release_key_is_required) do
29
- { :key => :otp_release, :issue => "Specify OTP releases you want to test against using the \"otp_release\" key" }
30
- end
31
-
32
- let(:docs) { "Travis CI documentation at http://bit.ly/travis-ci-environment" }
33
-
34
- def content_of_sample_file(name)
35
- path = Pathname.new(File.join("spec", "files", name)).expand_path
36
-
37
- YAML.load_file path.to_s, :safe => true
38
- end
39
-
40
- context "that is blank" do
41
- it "is valid" do
42
- Travis::Lint::Linter.validate({}).should_not include(language_key_is_mandatory)
43
-
44
- Travis::Lint::Linter.valid?(content_of_sample_file("no_language_key.yml")).should be_true
45
- end
46
- end
47
-
48
- context "with invalid language" do
49
- it "is invalid" do
50
- Travis::Lint::Linter.valid?(content_of_sample_file("invalid_language_key.yml")).should be_false
51
- end
52
- end
53
-
54
- context "using String keys" do
55
- it "is validates as with Symbol keys" do
56
- Travis::Lint::Linter.validate({ "language" => "ruby" }).should include(rvm_key_is_recommended)
57
- end
58
- end
59
-
60
- context "that has language set to Ruby" do
61
- context "but has no \"rvm\" key" do
62
- it "is invalid" do
63
- Travis::Lint::Linter.validate({ :language => "ruby" }).should include(rvm_key_is_recommended)
64
- Travis::Lint::Linter.valid?(content_of_sample_file("no_rvm_key.yml")).should be_false
65
- end
66
- end
67
-
68
- context "and uses jruby instead of jruby-18mode" do
69
- let(:travis_yml) do
70
- { :language => "ruby", :rvm => ["jruby"] }
71
- end
72
-
73
- it "is invalid" do
74
- Travis::Lint::Linter.validate(travis_yml).should include(prefer_jruby18mode_over_jruby)
75
- Travis::Lint::Linter.valid?(content_of_sample_file("uses_jruby_instead_of_jruby_in_specific_mode.yml")).should be_false
76
- end
77
- end
78
-
79
- context "and uses rbx-18mode" do
80
- let(:travis_yml) do
81
- { :language => "ruby", :rvm => ["rbx-18mode", "1.9.3"] }
82
- end
83
-
84
- it "is invalid" do
85
- Travis::Lint::Linter.validate(travis_yml).should include(rbx18mode_is_no_longer_provided)
86
- end
87
- end
88
-
89
- context "and uses rbx-19mode" do
90
- let(:travis_yml) do
91
- { :language => "ruby", :rvm => ["rbx-19mode", "1.9.3"] }
92
- end
93
-
94
- it "is invalid" do
95
- Travis::Lint::Linter.validate(travis_yml).should include(rbx19mode_is_no_longer_provided)
96
- end
97
- end
98
-
99
- context "and uses rbx-2.0.0pre" do
100
- let(:travis_yml) do
101
- { :language => "ruby", :rvm => ["rbx-2.0.0pre", "1.9.3"] }
102
- end
103
-
104
- it "is invalid" do
105
- Travis::Lint::Linter.validate(travis_yml).should include(rbx200pre_is_no_longer_provided)
106
- Travis::Lint::Linter.valid?(content_of_sample_file("uses_old_rbx_aliases.yml")).should be_false
107
- end
108
- end
109
-
110
- context "and uses an unsupported Ruby version" do
111
- let(:unsupported_rubies) do
112
- { :key => :rvm, :issue => "Detected unsupported Ruby versions. For an up-to-date list of supported Rubies, see #{docs}" }
113
- end
114
-
115
- let(:travis_yml) do
116
- { :language => "ruby", :rvm => ["neoruby", "goruby", "bonanzaruby"] }
117
- end
118
-
119
- it "is invalid" do
120
- Travis::Lint::Linter.validate(travis_yml).should include(unsupported_rubies)
121
- Travis::Lint::Linter.valid?(content_of_sample_file("uses_unsupported_rubies.yml")).should be_false
122
- end
123
- end
124
-
125
- context "that specifies Ruby as the language but tries to set node_js version" do
126
- let(:travis_yml) do
127
- { :language => "ruby", :rvm => ["1.9.3"], :node_js => ["0.6"] }
128
- end
129
-
130
- it "is invalid" do
131
- 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." })
132
- end
133
- end
134
- end
135
-
136
- context "that has language set to node_js" do
137
- context "and uses an unsupported Node.js version" do
138
- let(:unsupported_nodejs) do
139
- { :key => :node_js, :issue => "Detected unsupported Node.js versions. For an up-to-date list of supported Node.js versions, see #{docs}" }
140
- end
141
-
142
- let(:travis_yml) do
143
- { :language => "node_js", :node_js => ["100.0", "0.5"] }
144
- end
145
-
146
- it "is invalid" do
147
- Travis::Lint::Linter.validate(travis_yml).should include(unsupported_nodejs)
148
- Travis::Lint::Linter.valid?(content_of_sample_file("uses_unsupported_nodejs.yml")).should be_false
149
- end
150
- end
151
- end
152
-
153
- context "that has language set to PHP" do
154
- context "and uses an unsupported PHP version" do
155
- let(:unsupported_php) do
156
- { :key => :php, :issue => "Detected unsupported PHP versions. For an up-to-date list of supported PHP versions, see #{docs}" }
157
- end
158
-
159
- let(:travis_yml) do
160
- { :language => "php", :php => ["100.0", "0.5"] }
161
- end
162
-
163
- it "is invalid" do
164
- Travis::Lint::Linter.validate(travis_yml).should include(unsupported_php)
165
- Travis::Lint::Linter.valid?(content_of_sample_file("uses_unsupported_php.yml")).should be_false
166
- end
167
- end
168
- end
169
-
170
- context "that has language set to Python" do
171
- context "and uses an unsupported Python version" do
172
- let(:unsupported_python) do
173
- { :key => :python, :issue => "Detected unsupported Python versions. For an up-to-date list of supported Python versions, see #{docs}" }
174
- end
175
-
176
- let(:travis_yml) do
177
- { :language => "python", :python => ["stackless-py", "2.4", "2.3"] }
178
- end
179
-
180
- it "is invalid" do
181
- Travis::Lint::Linter.validate(travis_yml).should include(unsupported_python)
182
- Travis::Lint::Linter.valid?(content_of_sample_file("uses_unsupported_python.yml")).should be_false
183
- end
184
- end
185
- end
186
-
187
- context "that has language set to Perl" do
188
- context "and uses an unsupported Perl version" do
189
- let(:unsupported_perl) do
190
- { :key => :perl, :issue => "Detected unsupported Perl versions. For an up-to-date list of supported Perl versions, see #{docs}" }
191
- end
192
-
193
- let(:travis_yml) do
194
- { :language => "perl", :perl => ["5.6", "5.8"] }
195
- end
196
-
197
- it "is invalid" do
198
- Travis::Lint::Linter.validate(travis_yml).should include(unsupported_perl)
199
- Travis::Lint::Linter.valid?(content_of_sample_file("uses_unsupported_perl.yml")).should be_false
200
- end
201
- end
202
- end
203
-
204
- context "that has language set to erlang" do
205
- context "but has no \"otp_release\" key" do
206
- it "is invalid" do
207
- Travis::Lint::Linter.validate({ :language => "erlang" }).should include(otp_release_key_is_required)
208
- Travis::Lint::Linter.valid?({ :language => "erlang" }).should be_false
209
- end
210
- end
211
- end
212
-
213
- context "with a build matrix" do
214
- let(:invalid_array_matrix) {
215
- {:matrix => ['foo', 'bar', 'baz']}
216
- }
217
-
218
- let(:build_matrix_is_not_hash) {
219
- {:key => :matrix, :issue => "Matrix must be a hash."}
220
- }
221
-
222
- it "is invalid unless the build matrix is a hash" do
223
- Travis::Lint::Linter.valid?(invalid_array_matrix).should eq(false)
224
- Travis::Lint::Linter.validate(invalid_array_matrix).should include(build_matrix_is_not_hash)
225
- end
226
-
227
- let(:build_matrix_is_not_list_of_hashes) {
228
- {:key => :matrix, :issue => "Allowed matrix failures must contain a list of hashes."}
229
- }
230
- context "with allow_failures" do
231
- let(:invalid_matrix) {
232
- {:matrix => {:allow_failures => ["ruby-head"]}}
233
- }
234
-
235
- let(:valid_matrix) {
236
- {:matrix => {:allow_failures => [{"rvm" => "ruby-head"}]}}
237
- }
238
-
239
- it "is invalid when the allowed failures are not a list of hashes" do
240
- Travis::Lint::Linter.validate(invalid_matrix).should include(build_matrix_is_not_list_of_hashes)
241
- Travis::Lint::Linter.valid?(invalid_matrix).should == false
242
- end
243
-
244
- it "is valid when allowed failures are a list of hashes" do
245
- Travis::Lint::Linter.valid?(valid_matrix).should == true
246
- end
247
- end
248
- context "with include" do
249
- let(:include_is_a_hash) {
250
- {:matrix => {:include => {"jdk"=> 'openjdk6', 'script' => 'mvn dostuff'}}}
251
- }
252
-
253
- let(:include_is_an_array_of_arrays) {
254
- {:matrix => {:include => [[{"jdk"=> 'openjdk6', 'script' => 'mvn dostuff'}]]}}
255
- }
256
-
257
- let(:valid_matrix) {
258
- {:matrix => {:include => [{"jdk"=> 'openjdk6', 'script' => 'mvn dostuff'}]}}
259
- }
260
-
261
- let(:include_is_not_list_of_hashes) {
262
- {:key => :matrix, :issue => "Matrix includes must be a list of hashes."}
263
- }
264
- it "is invalid when the include is not a list of hashes" do
265
- Travis::Lint::Linter.validate(include_is_a_hash).should include(include_is_not_list_of_hashes)
266
- Travis::Lint::Linter.valid?(include_is_a_hash).should == false
267
- Travis::Lint::Linter.validate(include_is_an_array_of_arrays).should include(include_is_not_list_of_hashes)
268
- Travis::Lint::Linter.valid?(include_is_an_array_of_arrays).should == false
269
- end
270
- it "is valid when allowed include is a list of hashes" do
271
- Travis::Lint::Linter.valid?(valid_matrix).should == true
272
- end
273
- end
274
- end
275
- end
@@ -1,23 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "travis/lint/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "travis-lint"
7
- s.version = Travis::Lint::Version.to_s
8
- s.platform = Gem::Platform::RUBY
9
- s.authors = ["Michael S. Klishin", "Travis CI Development Team"]
10
- s.email = ["michaelklishin@me.com", "michael@novemberain.com"]
11
- s.homepage = "http://github.com/travis-ci"
12
- s.summary = %q{Checks your .travis.yml for possible issues, deprecations and so on}
13
- s.description = %q{travis-lint is a tool that check your .travis.yml for possible issues, deprecations and so on. Recommended for all travis-ci.org users.}
14
- s.files = `git ls-files`.split("\n")
15
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
- s.require_paths = ["lib"]
18
-
19
- s.add_dependency "hashr", "~> 0.0.22"
20
- s.add_dependency "safe_yaml", '~> 0.9.0'
21
-
22
- s.add_development_dependency "rspec", "~> 2.8"
23
- end