Skip to content

Commit

Permalink
Merge pull request #579 from agrare/update_github_actions_matrix
Browse files Browse the repository at this point in the history
Use a matrix for test-repos not jobs
  • Loading branch information
Fryguy committed Feb 9, 2022
2 parents 282f257 + 341e80d commit 5f60fd4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
10 changes: 5 additions & 5 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,
"repos" => repos.join(",")
"test-repos" => test_repos.inspect,
"repos" => repos.join(",")
}
}
end
}

entry = {}
entry[:path] = ".github/workflows/ci.yaml"
Expand Down
18 changes: 5 additions & 13 deletions spec/lib/github_service/commands/cross_repo_test_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
manageiq:
uses: agrare/manageiq-cross_repo/.github/workflows/manageiq_cross_repo.yaml@github_actions
with:
test-repo: ManageIQ/manageiq@master
test-repos: '["ManageIQ/manageiq@master"]'
repos: ManageIQ/manageiq@master
YAML

Expand Down 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-repos"]).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-repos: '[\"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-repos: '[\"foo\", \"bar\"]'"
end
end

Expand Down

0 comments on commit 5f60fd4

Please sign in to comment.