wwtd 1.2.0 → 1.3.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: 5ea58cf2ea3a962dbc5ed44866ba2ff5411de57e
4
- data.tar.gz: 4803501289ed6fcbdf9e606855be37cf6e3b9454
3
+ metadata.gz: 61da2cf51ba1d01d93f74f8979a6114f74863592
4
+ data.tar.gz: ead0ba73395bb7f8180aece8665dbbbcbc5536a8
5
5
  SHA512:
6
- metadata.gz: cf228f3b8f0136905943f05cae7802d925843bf7affcc51f6c07d93bec2c4a2de9781af9bf120ef6c2b9162a3024e5063a0e5921e7da9af2a16a50ce58e3e8a5
7
- data.tar.gz: 13922b88b673cac8ca958e7c7ac4750072f53c78f21d4b267b0380806ea06cde560430dc41abdf374e3108ff7b367bb6fe49c9bcb97c107a7c2da7d8946529d4
6
+ metadata.gz: 07e972cabce7d8256374fd796f148c10cc827a7def79fc20079377ee6b844db1ebdaae4d504038253e7f7b15cee446b223e01cfdc8d84636a1f9fa99566246d5
7
+ data.tar.gz: d07e181e39e27b68816b2b3e8bcac1580b50abc3c64f2877fd7f01ff3f0f848400a0bf4e91ff314571b782ebfbea7f0165e3ffaec03cc5be3936477e7b130252
@@ -18,7 +18,7 @@ module WWTD
18
18
  def read_travis_yml(options={})
19
19
  config = (File.exist?(CONFIG) ? YAML.load_file(CONFIG) : {})
20
20
  config.delete("source_key") # we don't need that we already have the source
21
- ignored = (config.keys - UNDERSTOOD) + Array(options[:ignore])
21
+ ignored = (config.keys - UNDERSTOOD - Array(options[:use])) + Array(options[:ignore])
22
22
 
23
23
  calculate_local_ruby_matrix = (
24
24
  ignored.include?("rvm") &&
@@ -97,7 +97,16 @@ module WWTD
97
97
 
98
98
  def matrix(config)
99
99
  if config["env"] && config["env"].is_a?(Hash)
100
- config["env"] = config["env"].values.map { |v| v.join(" ")}
100
+ global = if config["env"]["global"]
101
+ " " + config["env"]["global"].join(" ")
102
+ else
103
+ ""
104
+ end
105
+ if config["env"]["matrix"]
106
+ config["env"] = config["env"]["matrix"].map { |v| v + global }
107
+ else
108
+ config["env"] = global.strip
109
+ end
101
110
  end
102
111
 
103
112
  matrix = [{}]
@@ -33,7 +33,7 @@ module WWTD
33
33
  puts "\nFailed:"
34
34
  failed.each do |state, config|
35
35
  runner = WWTD::Run.new(config.merge(:rerun => true), {}, nil)
36
- env, cmd = runner.env_and_command
36
+ env, cmd = runner.env_and_command_for_section("script")
37
37
  env = WWTD.escaped_env(env, :rerun => true)
38
38
  puts colorize(:red, env + cmd)
39
39
  end
@@ -60,7 +60,8 @@ module WWTD
60
60
 
61
61
  def parse_options(argv)
62
62
  options = {
63
- :ignore => []
63
+ :ignore => [],
64
+ :use => [],
64
65
  }
65
66
  OptionParser.new do |opts|
66
67
  opts.banner = <<-BANNER.gsub(/^ {10}/, "")
@@ -73,6 +74,7 @@ module WWTD
73
74
  BANNER
74
75
  opts.on("-l", "--local", "Ignore rvm options / only run on current ruby") { options[:ignore] << "rvm" }
75
76
  opts.on("-i", "--ignore FIELDS", String, "Ignore selected travis fields like rvm/gemfile/matrix/...") { |fields| options[:ignore] += fields.split(",") }
77
+ opts.on("-u", "--use FIELDS", String, "Use dangerous travis fields like before_install/install/before_script/...") { |fields| options[:use] += fields.split(",") }
76
78
  opts.on("-p", "--parallel [COUNT]", Integer, "Run in parallel") { |c| options[:parallel] = c || 4 }
77
79
  opts.on("-o", "--only-bundle", "Only bundle, do not run anything") { options[:only_bundle] = true }
78
80
  opts.on("-h", "--help", "Show this.") { puts opts; exit }
@@ -13,7 +13,7 @@ module WWTD
13
13
  return unless version
14
14
  version = normalize_ruby_version(version)
15
15
  if rvm_executable
16
- command = "rvm #{version} do "
16
+ command = "rvm-exec #{version} "
17
17
  command if cache_command("#{command} ruby -v")
18
18
  elsif chruby_executable
19
19
  command = "chruby-exec #{version} -- "
@@ -1,12 +1,15 @@
1
1
  module WWTD
2
2
  class Run
3
+
4
+ SCRIPT_SECTIONS = ["before_install", "install", "before_script", "script", "after_script"]
5
+
3
6
  def initialize(config, env, lock)
4
7
  @config, @env, @lock = config, env, lock
5
8
  add_env_from_config
6
9
  @switch = build_switch_statement
7
10
  end
8
11
 
9
- def execute(&block)
12
+ def execute
10
13
  state = if Ruby.available?(config["rvm"])
11
14
  yield(:start, config)
12
15
  success? ? :success : :failure
@@ -20,20 +23,22 @@ module WWTD
20
23
  end
21
24
 
22
25
  # internal api
23
- def env_and_command
24
- default_command = (wants_bundle? ? "bundle exec rake" : "rake")
25
- command = config["script"] || default_command
26
- command = [command] unless Array === command
27
- command = command.map { |cmd| "#{switch}#{cmd}" }.join(" && ")
28
-
29
- [env, command]
26
+ def env_and_command_for_section(key)
27
+ if command = config[key]
28
+ command = [command] unless Array === command
29
+ command = command.map { |cmd| "#{switch}#{cmd}" }.join(" && ")
30
+
31
+ [env, command]
32
+ elsif key == "script"
33
+ command = (wants_bundle? ? "#{switch}bundle exec rake" : "#{switch}rake")
34
+ [env, command]
35
+ end
30
36
  end
31
37
 
32
38
  private
33
39
 
34
40
  attr_reader :config, :env, :lock, :switch
35
41
 
36
-
37
42
  def success?
38
43
  if wants_bundle?
39
44
  flock File.join(lock, (config["rvm"] || "rvm").to_s) do
@@ -43,7 +48,13 @@ module WWTD
43
48
  end
44
49
  end
45
50
 
46
- sh(*env_and_command)
51
+ SCRIPT_SECTIONS.each do |section|
52
+ if env_and_command = env_and_command_for_section(section)
53
+ return unless sh(*env_and_command)
54
+ end
55
+ end
56
+
57
+ true
47
58
  end
48
59
 
49
60
  def wants_bundle?
@@ -1,3 +1,3 @@
1
1
  module WWTD
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wwtd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-09 00:00:00.000000000 Z
11
+ date: 2015-12-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: michael@grosser.it