Skip to content

Commit

Permalink
Fix merge group ib (#12398)
Browse files Browse the repository at this point in the history
* Test

* Add test and fix getting head sha for merge group event

* Remove tets workflow
  • Loading branch information
KacperMalachowski authored Nov 25, 2024
1 parent b55f103 commit 9a9735f
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/image-builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ func loadGithubActionsGitState() (GitStateConfig, error) {
JobType: "merge_group",
BaseCommitSHA: commitSHA,
BaseCommitRef: gitRef,
PullHeadCommitSHA: *payload.MergeGroup.HeadCommit.SHA,
PullHeadCommitSHA: *payload.MergeGroup.HeadSHA,
}, nil

default:
Expand Down
21 changes: 21 additions & 0 deletions cmd/image-builder/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,27 @@ func TestLoadGitStateConfig(t *testing.T) {
BaseCommitSHA: "art654",
},
},
{
name: "load data from event payload for github merge_group event",
options: options{
ciSystem: GithubActions,
},
env: map[string]string{
"GITHUB_EVENT_PATH": "./test_fixture/merge-group_event.json",
"GITHUB_EVENT_NAME": "merge_group",
"GITHUB_SHA": "659bf74f7b4ecab07d9398eec554217b51bad738",
"GITHUB_REF": "refs/heads/main",
},
gitState: GitStateConfig{
RepositoryName: "test-infra",
RepositoryOwner: "edplanes",
JobType: "merge_group",
BaseCommitSHA: "659bf74f7b4ecab07d9398eec554217b51bad738",
BaseCommitRef: "refs/heads/main",
isPullRequest: false,
PullHeadCommitSHA: "d42c05aa25fc3e8bfff0396086de3fccd4b34c29",
},
},
}

for _, c := range tc {
Expand Down
160 changes: 160 additions & 0 deletions cmd/image-builder/test_fixture/merge-group_event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
{
"action": "checks_requested",
"merge_group": {
"base_ref": "refs/heads/main",
"base_sha": "659bf74f7b4ecab07d9398eec554217b51bad738",
"head_commit": {
"author": {
"email": "[email protected]",
"name": "Kacper Małachowski"
},
"committer": {
"email": "[email protected]",
"name": "GitHub"
},
"id": "d42c05aa25fc3e8bfff0396086de3fccd4b34c29",
"message": "Merge pull request #26 from edplanes/dependabot/github_actions/docker/metadata-action-5.5.1\n\nBump docker/metadata-action from 4.4.0 to 5.5.1",
"timestamp": "2024-11-25T07:51:32Z",
"tree_id": "4e6511450d1f377531c92719edf29974eb28b3f1"
},
"head_ref": "refs/heads/gh-readonly-queue/main/pr-26-659bf74f7b4ecab07d9398eec554217b51bad738",
"head_sha": "d42c05aa25fc3e8bfff0396086de3fccd4b34c29"
},
"organization": {
"avatar_url": "https://avatars.githubusercontent.com/u/115666164?v=4",
"description": "Open Source Virtual Airline Managment Tool started as university project",
"events_url": "https://api.github.com/orgs/edplanes/events",
"hooks_url": "https://api.github.com/orgs/edplanes/hooks",
"id": 115666164,
"issues_url": "https://api.github.com/orgs/edplanes/issues",
"login": "edplanes",
"members_url": "https://api.github.com/orgs/edplanes/members{/member}",
"node_id": "O_kgDOBuTs9A",
"public_members_url": "https://api.github.com/orgs/edplanes/public_members{/member}",
"repos_url": "https://api.github.com/orgs/edplanes/repos",
"url": "https://api.github.com/orgs/edplanes"
},
"repository": {
"allow_forking": true,
"archive_url": "https://api.github.com/repos/edplanes/test-infra/{archive_format}{/ref}",
"archived": false,
"assignees_url": "https://api.github.com/repos/edplanes/test-infra/assignees{/user}",
"blobs_url": "https://api.github.com/repos/edplanes/test-infra/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/edplanes/test-infra/branches{/branch}",
"clone_url": "https://github.com/edplanes/test-infra.git",
"collaborators_url": "https://api.github.com/repos/edplanes/test-infra/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/edplanes/test-infra/comments{/number}",
"commits_url": "https://api.github.com/repos/edplanes/test-infra/commits{/sha}",
"compare_url": "https://api.github.com/repos/edplanes/test-infra/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/edplanes/test-infra/contents/{+path}",
"contributors_url": "https://api.github.com/repos/edplanes/test-infra/contributors",
"created_at": "2023-05-25T19:10:09Z",
"custom_properties": {},
"default_branch": "main",
"deployments_url": "https://api.github.com/repos/edplanes/test-infra/deployments",
"description": null,
"disabled": false,
"downloads_url": "https://api.github.com/repos/edplanes/test-infra/downloads",
"events_url": "https://api.github.com/repos/edplanes/test-infra/events",
"fork": false,
"forks": 0,
"forks_count": 0,
"forks_url": "https://api.github.com/repos/edplanes/test-infra/forks",
"full_name": "edplanes/test-infra",
"git_commits_url": "https://api.github.com/repos/edplanes/test-infra/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/edplanes/test-infra/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/edplanes/test-infra/git/tags{/sha}",
"git_url": "git://github.com/edplanes/test-infra.git",
"has_discussions": false,
"has_downloads": true,
"has_issues": true,
"has_pages": false,
"has_projects": true,
"has_wiki": true,
"homepage": null,
"hooks_url": "https://api.github.com/repos/edplanes/test-infra/hooks",
"html_url": "https://github.com/edplanes/test-infra",
"id": 645488158,
"is_template": false,
"issue_comment_url": "https://api.github.com/repos/edplanes/test-infra/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/edplanes/test-infra/issues/events{/number}",
"issues_url": "https://api.github.com/repos/edplanes/test-infra/issues{/number}",
"keys_url": "https://api.github.com/repos/edplanes/test-infra/keys{/key_id}",
"labels_url": "https://api.github.com/repos/edplanes/test-infra/labels{/name}",
"language": "Go",
"languages_url": "https://api.github.com/repos/edplanes/test-infra/languages",
"license": null,
"merges_url": "https://api.github.com/repos/edplanes/test-infra/merges",
"milestones_url": "https://api.github.com/repos/edplanes/test-infra/milestones{/number}",
"mirror_url": null,
"name": "test-infra",
"node_id": "R_kgDOJnleHg",
"notifications_url": "https://api.github.com/repos/edplanes/test-infra/notifications{?since,all,participating}",
"open_issues": 6,
"open_issues_count": 6,
"owner": {
"avatar_url": "https://avatars.githubusercontent.com/u/115666164?v=4",
"events_url": "https://api.github.com/users/edplanes/events{/privacy}",
"followers_url": "https://api.github.com/users/edplanes/followers",
"following_url": "https://api.github.com/users/edplanes/following{/other_user}",
"gists_url": "https://api.github.com/users/edplanes/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/edplanes",
"id": 115666164,
"login": "edplanes",
"node_id": "O_kgDOBuTs9A",
"organizations_url": "https://api.github.com/users/edplanes/orgs",
"received_events_url": "https://api.github.com/users/edplanes/received_events",
"repos_url": "https://api.github.com/users/edplanes/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/edplanes/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/edplanes/subscriptions",
"type": "Organization",
"url": "https://api.github.com/users/edplanes",
"user_view_type": "public"
},
"private": false,
"pulls_url": "https://api.github.com/repos/edplanes/test-infra/pulls{/number}",
"pushed_at": "2024-11-25T07:51:47Z",
"releases_url": "https://api.github.com/repos/edplanes/test-infra/releases{/id}",
"size": 150,
"ssh_url": "[email protected]:edplanes/test-infra.git",
"stargazers_count": 0,
"stargazers_url": "https://api.github.com/repos/edplanes/test-infra/stargazers",
"statuses_url": "https://api.github.com/repos/edplanes/test-infra/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/edplanes/test-infra/subscribers",
"subscription_url": "https://api.github.com/repos/edplanes/test-infra/subscription",
"svn_url": "https://github.com/edplanes/test-infra",
"tags_url": "https://api.github.com/repos/edplanes/test-infra/tags",
"teams_url": "https://api.github.com/repos/edplanes/test-infra/teams",
"topics": [],
"trees_url": "https://api.github.com/repos/edplanes/test-infra/git/trees{/sha}",
"updated_at": "2024-11-25T07:50:31Z",
"url": "https://api.github.com/repos/edplanes/test-infra",
"visibility": "public",
"watchers": 0,
"watchers_count": 0,
"web_commit_signoff_required": false
},
"sender": {
"avatar_url": "https://avatars.githubusercontent.com/u/38684517?v=4",
"events_url": "https://api.github.com/users/KacperMalachowski/events{/privacy}",
"followers_url": "https://api.github.com/users/KacperMalachowski/followers",
"following_url": "https://api.github.com/users/KacperMalachowski/following{/other_user}",
"gists_url": "https://api.github.com/users/KacperMalachowski/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/KacperMalachowski",
"id": 38684517,
"login": "KacperMalachowski",
"node_id": "MDQ6VXNlcjM4Njg0NTE3",
"organizations_url": "https://api.github.com/users/KacperMalachowski/orgs",
"received_events_url": "https://api.github.com/users/KacperMalachowski/received_events",
"repos_url": "https://api.github.com/users/KacperMalachowski/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/KacperMalachowski/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/KacperMalachowski/subscriptions",
"type": "User",
"url": "https://api.github.com/users/KacperMalachowski",
"user_view_type": "public"
}
}

0 comments on commit 9a9735f

Please sign in to comment.