Skip to content

Commit

Permalink
Use a matrix for test-repos not jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Feb 9, 2022
1 parent 282f257 commit 598ff45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
8 changes: 4 additions & 4 deletions lib/github_service/commands/cross_repo_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,15 @@ def update_github_workflow_yaml_content
raw_yaml = rugged_repo.blob_at(branch_ref.target.oid, ".github/workflows/ci.yaml").content
content = YAML.safe_load(raw_yaml)

content["jobs"] = test_repos.each_with_object({}) do |test_repo, result|
result[test_repo] = {
content["jobs"] = {
"cross-repo" => {
"uses" => "ManageIQ/manageiq-cross_repo/.github/workflows/manageiq_cross_repo.yaml@master",
"with" => {
"test-repo" => test_repo,
"test-repo" => test_repos.inspect,
"repos" => repos.join(",")
}
}
end
}

entry = {}
entry[:path] = ".github/workflows/ci.yaml"
Expand Down
16 changes: 4 additions & 12 deletions spec/lib/github_service/commands/cross_repo_test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -386,14 +386,8 @@ def assert_execute(valid: true)
github_workflow_yml_content = repo.blob_at(branch.target.oid, ".github/workflows/ci.yaml").content
content = YAML.safe_load(github_workflow_yml_content)

expect(content["jobs"].count).to eq(2)
expect(content["jobs"].keys).to match_array(["foo", "bar"])

expect(content["jobs"]["foo"]["with"]["test-repo"]).to eq("foo")
expect(content["jobs"]["bar"]["with"]["test-repo"]).to eq("bar")

expect(content["jobs"]["foo"]["with"]["repos"]).to eq("repo1,repo2")
expect(content["jobs"]["bar"]["with"]["repos"]).to eq("repo1,repo2")
expect(content["jobs"]["cross-repo"]["with"]["test-repo"]).to eq('["foo", "bar"]')
expect(content["jobs"]["cross-repo"]["with"]["repos"]).to eq("repo1,repo2")
end

it "commits the changes" do
Expand All @@ -414,8 +408,7 @@ def assert_execute(valid: true)
MSG

expect(commit_content).to include "repos: repo1,repo2"
expect(commit_content).to include "test-repo: foo"
expect(commit_content).to include "test-repo: bar"
expect(commit_content).to include "test-repo: '[\"foo\", \"bar\"]'"
end

it "pushes the changes" do
Expand All @@ -436,8 +429,7 @@ def assert_execute(valid: true)
MSG

expect(commit_content).to include "repos: repo1,repo2"
expect(commit_content).to include "test-repo: foo"
expect(commit_content).to include "test-repo: bar"
expect(commit_content).to include "test-repo: '[\"foo\", \"bar\"]'"
end
end

Expand Down

0 comments on commit 598ff45

Please sign in to comment.