Skip to content

Commit

Permalink
fix partial matrix excludes
Browse files Browse the repository at this point in the history
the docs clearly state that excludes only have to match on the
keys provided: https://docs.travis-ci.com/user/build-matrix/#excluding-jobs
  • Loading branch information
ccutrer authored and grosser committed Aug 18, 2019
1 parent 3d202e9 commit 1247248
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/wwtd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ def matrix(config)

if matrix_config = config.delete("matrix")
if exclude = matrix_config["exclude"]
matrix -= exclude
exclude.each do |exclude_cell|
matrix.delete_if { |cell| matrix_match?(cell, exclude_cell) }
end
end
if include = matrix_config["include"]
if matrix == [{}]
Expand All @@ -130,6 +132,10 @@ def matrix(config)
matrix.map! { |c| config.merge(c) }
end

def matrix_match?(cell, exclude)
cell.slice(*exclude.keys) == exclude
end

def with_clean_env(&block)
if defined?(Bundler)
Bundler.with_clean_env(&block)
Expand Down
17 changes: 17 additions & 0 deletions spec/wwtd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,23 @@ def call(config)
{"rvm"=>"c", "gemfile"=>"Gemfile1"},
]
end

it "excludes partial matches" do
call(
"gemfile" => ["Gemfile1", "Gemfile2"],
"rvm" => ["a", "b"],
"env" => ["KEY=val"],
"matrix" => {
"exclude" => [
{"gemfile" => "Gemfile1", "rvm" => "b"}
],
}
).should == [
{"rvm" => "a", "gemfile"=>"Gemfile1", "env" => "KEY=val"},
{"rvm" => "a", "gemfile"=>"Gemfile2", "env" => "KEY=val"},
{"rvm" => "b", "gemfile"=>"Gemfile2", "env" => "KEY=val"},
]
end
end

describe ".config_info" do
Expand Down

0 comments on commit 1247248

Please sign in to comment.