From f4af396285db189d5edc1d9b1b8e7d54a4e34dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Ma=C5=82achowski?= Date: Mon, 25 Nov 2024 08:41:13 +0100 Subject: [PATCH 1/7] Test --- .github/workflows/test.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000000..aa2951422ec1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,12 @@ +name: test + +on: + merge_group: + + +jobs: + test: + runs-on: ubuntu-latest + steps: + - run: echo $GITHUB_EVENT_NAME + - run: cat $GITHUB_EVENT_PATH \ No newline at end of file From 9aa8f02c05178e81396ff6181a72f40c5c7624bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Ma=C5=82achowski?= Date: Mon, 25 Nov 2024 09:09:14 +0100 Subject: [PATCH 2/7] Add test and fix getting head sha for merge group event --- cmd/image-builder/config.go | 2 +- cmd/image-builder/config_test.go | 21 +++ .../test_fixture/merge-group_event.json | 160 ++++++++++++++++++ 3 files changed, 182 insertions(+), 1 deletion(-) create mode 100644 cmd/image-builder/test_fixture/merge-group_event.json diff --git a/cmd/image-builder/config.go b/cmd/image-builder/config.go index 65233804f3b9..0354051a4c13 100644 --- a/cmd/image-builder/config.go +++ b/cmd/image-builder/config.go @@ -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: diff --git a/cmd/image-builder/config_test.go b/cmd/image-builder/config_test.go index 8fdbf4384ec7..6957108d60af 100644 --- a/cmd/image-builder/config_test.go +++ b/cmd/image-builder/config_test.go @@ -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 { diff --git a/cmd/image-builder/test_fixture/merge-group_event.json b/cmd/image-builder/test_fixture/merge-group_event.json new file mode 100644 index 000000000000..6fc5ff47d753 --- /dev/null +++ b/cmd/image-builder/test_fixture/merge-group_event.json @@ -0,0 +1,160 @@ +{ + "action": "checks_requested", + "merge_group": { + "base_ref": "refs/heads/main", + "base_sha": "659bf74f7b4ecab07d9398eec554217b51bad738", + "head_commit": { + "author": { + "email": "38684517+KacperMalachowski@users.noreply.github.com", + "name": "Kacper MaƂachowski" + }, + "committer": { + "email": "noreply@github.com", + "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": "git@github.com: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" + } +} \ No newline at end of file From 0a8fa2ce1ce5d7923d53f4f61c79047144d493c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Ma=C5=82achowski?= Date: Mon, 25 Nov 2024 09:51:22 +0100 Subject: [PATCH 3/7] Remove tets workflow --- .github/workflows/test.yml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index aa2951422ec1..000000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: test - -on: - merge_group: - - -jobs: - test: - runs-on: ubuntu-latest - steps: - - run: echo $GITHUB_EVENT_NAME - - run: cat $GITHUB_EVENT_PATH \ No newline at end of file From 849603e2531f5a6f457eafc974a02f54c2346711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Ma=C5=82achowski?= Date: Mon, 25 Nov 2024 10:29:41 +0100 Subject: [PATCH 4/7] Fix client not passing pull head sha on merge_group event --- cmd/image-builder/config.go | 1 + cmd/image-builder/config_test.go | 6 +- .../test_fixture/merge-group_event.json | 210 ++++++++++-------- 3 files changed, 118 insertions(+), 99 deletions(-) diff --git a/cmd/image-builder/config.go b/cmd/image-builder/config.go index 0354051a4c13..0b9e71c489be 100644 --- a/cmd/image-builder/config.go +++ b/cmd/image-builder/config.go @@ -318,6 +318,7 @@ func loadGithubActionsGitState() (GitStateConfig, error) { BaseCommitSHA: commitSHA, BaseCommitRef: gitRef, PullHeadCommitSHA: *payload.MergeGroup.HeadSHA, + isPullRequest: true, }, nil default: diff --git a/cmd/image-builder/config_test.go b/cmd/image-builder/config_test.go index 6957108d60af..97ae9d27aa2f 100644 --- a/cmd/image-builder/config_test.go +++ b/cmd/image-builder/config_test.go @@ -371,12 +371,12 @@ func TestLoadGitStateConfig(t *testing.T) { }, gitState: GitStateConfig{ RepositoryName: "test-infra", - RepositoryOwner: "edplanes", + RepositoryOwner: "kyma-project", JobType: "merge_group", BaseCommitSHA: "659bf74f7b4ecab07d9398eec554217b51bad738", BaseCommitRef: "refs/heads/main", - isPullRequest: false, - PullHeadCommitSHA: "d42c05aa25fc3e8bfff0396086de3fccd4b34c29", + isPullRequest: true, + PullHeadCommitSHA: "e47034172c36d3e5fb407b5ba57adf0f7868599d", }, }, } diff --git a/cmd/image-builder/test_fixture/merge-group_event.json b/cmd/image-builder/test_fixture/merge-group_event.json index 6fc5ff47d753..a94215a060ce 100644 --- a/cmd/image-builder/test_fixture/merge-group_event.json +++ b/cmd/image-builder/test_fixture/merge-group_event.json @@ -1,8 +1,20 @@ { "action": "checks_requested", + "enterprise": { + "avatar_url": "https://avatars.githubusercontent.com/b/4978?v=4", + "created_at": "2020-12-16T23:19:05Z", + "description": "SAP Enterprise Account", + "html_url": "https://github.com/enterprises/sap", + "id": 4978, + "name": "SAP", + "node_id": "MDEwOkVudGVycHJpc2U0OTc4", + "slug": "sap", + "updated_at": "2024-06-27T14:56:18Z", + "website_url": "https://sap.com" + }, "merge_group": { - "base_ref": "refs/heads/main", - "base_sha": "659bf74f7b4ecab07d9398eec554217b51bad738", + "base_ref": "refs/heads/test-merge-group", + "base_sha": "4e2379dce4dcce7648c1ae3d7e9f44cf93a2b93d", "head_commit": { "author": { "email": "38684517+KacperMalachowski@users.noreply.github.com", @@ -12,128 +24,134 @@ "email": "noreply@github.com", "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" + "id": "e47034172c36d3e5fb407b5ba57adf0f7868599d", + "message": "Merge pull request #12387 from KacperMalachowski/test-merge-queue\n\nTest merge queue", + "timestamp": "2024-11-25T09:24:38Z", + "tree_id": "3efa879dafdbeee187d2a3cedb8b7b8dae25e904" }, - "head_ref": "refs/heads/gh-readonly-queue/main/pr-26-659bf74f7b4ecab07d9398eec554217b51bad738", - "head_sha": "d42c05aa25fc3e8bfff0396086de3fccd4b34c29" + "head_ref": "refs/heads/gh-readonly-queue/test-merge-group/pr-12387-4e2379dce4dcce7648c1ae3d7e9f44cf93a2b93d", + "head_sha": "e47034172c36d3e5fb407b5ba57adf0f7868599d" }, "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" + "avatar_url": "https://avatars.githubusercontent.com/u/39153523?v=4", + "description": "A flexible and easy way to connect and extend enterprise applications in a cloud-native world.", + "events_url": "https://api.github.com/orgs/kyma-project/events", + "hooks_url": "https://api.github.com/orgs/kyma-project/hooks", + "id": 39153523, + "issues_url": "https://api.github.com/orgs/kyma-project/issues", + "login": "kyma-project", + "members_url": "https://api.github.com/orgs/kyma-project/members{/member}", + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM5MTUzNTIz", + "public_members_url": "https://api.github.com/orgs/kyma-project/public_members{/member}", + "repos_url": "https://api.github.com/orgs/kyma-project/repos", + "url": "https://api.github.com/orgs/kyma-project" }, "repository": { "allow_forking": true, - "archive_url": "https://api.github.com/repos/edplanes/test-infra/{archive_format}{/ref}", + "archive_url": "https://api.github.com/repos/kyma-project/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", + "assignees_url": "https://api.github.com/repos/kyma-project/test-infra/assignees{/user}", + "blobs_url": "https://api.github.com/repos/kyma-project/test-infra/git/blobs{/sha}", + "branches_url": "https://api.github.com/repos/kyma-project/test-infra/branches{/branch}", + "clone_url": "https://github.com/kyma-project/test-infra.git", + "collaborators_url": "https://api.github.com/repos/kyma-project/test-infra/collaborators{/collaborator}", + "comments_url": "https://api.github.com/repos/kyma-project/test-infra/comments{/number}", + "commits_url": "https://api.github.com/repos/kyma-project/test-infra/commits{/sha}", + "compare_url": "https://api.github.com/repos/kyma-project/test-infra/compare/{base}...{head}", + "contents_url": "https://api.github.com/repos/kyma-project/test-infra/contents/{+path}", + "contributors_url": "https://api.github.com/repos/kyma-project/test-infra/contributors", + "created_at": "2018-09-05T09:44:20Z", "custom_properties": {}, "default_branch": "main", - "deployments_url": "https://api.github.com/repos/edplanes/test-infra/deployments", - "description": null, + "deployments_url": "https://api.github.com/repos/kyma-project/test-infra/deployments", + "description": "Test infrastructure for the Kyma project.", "disabled": false, - "downloads_url": "https://api.github.com/repos/edplanes/test-infra/downloads", - "events_url": "https://api.github.com/repos/edplanes/test-infra/events", + "downloads_url": "https://api.github.com/repos/kyma-project/test-infra/downloads", + "events_url": "https://api.github.com/repos/kyma-project/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", + "forks": 180, + "forks_count": 180, + "forks_url": "https://api.github.com/repos/kyma-project/test-infra/forks", + "full_name": "kyma-project/test-infra", + "git_commits_url": "https://api.github.com/repos/kyma-project/test-infra/git/commits{/sha}", + "git_refs_url": "https://api.github.com/repos/kyma-project/test-infra/git/refs{/sha}", + "git_tags_url": "https://api.github.com/repos/kyma-project/test-infra/git/tags{/sha}", + "git_url": "git://github.com/kyma-project/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, + "has_projects": false, + "has_wiki": false, + "homepage": "https://status.build.kyma-project.io/", + "hooks_url": "https://api.github.com/repos/kyma-project/test-infra/hooks", + "html_url": "https://github.com/kyma-project/test-infra", + "id": 147495537, "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}", + "issue_comment_url": "https://api.github.com/repos/kyma-project/test-infra/issues/comments{/number}", + "issue_events_url": "https://api.github.com/repos/kyma-project/test-infra/issues/events{/number}", + "issues_url": "https://api.github.com/repos/kyma-project/test-infra/issues{/number}", + "keys_url": "https://api.github.com/repos/kyma-project/test-infra/keys{/key_id}", + "labels_url": "https://api.github.com/repos/kyma-project/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}", + "languages_url": "https://api.github.com/repos/kyma-project/test-infra/languages", + "license": { + "key": "apache-2.0", + "name": "Apache License 2.0", + "node_id": "MDc6TGljZW5zZTI=", + "spdx_id": "Apache-2.0", + "url": "https://api.github.com/licenses/apache-2.0" + }, + "merges_url": "https://api.github.com/repos/kyma-project/test-infra/merges", + "milestones_url": "https://api.github.com/repos/kyma-project/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, + "node_id": "MDEwOlJlcG9zaXRvcnkxNDc0OTU1Mzc=", + "notifications_url": "https://api.github.com/repos/kyma-project/test-infra/notifications{?since,all,participating}", + "open_issues": 68, + "open_issues_count": 68, "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}", + "avatar_url": "https://avatars.githubusercontent.com/u/39153523?v=4", + "events_url": "https://api.github.com/users/kyma-project/events{/privacy}", + "followers_url": "https://api.github.com/users/kyma-project/followers", + "following_url": "https://api.github.com/users/kyma-project/following{/other_user}", + "gists_url": "https://api.github.com/users/kyma-project/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", + "html_url": "https://github.com/kyma-project", + "id": 39153523, + "login": "kyma-project", + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM5MTUzNTIz", + "organizations_url": "https://api.github.com/users/kyma-project/orgs", + "received_events_url": "https://api.github.com/users/kyma-project/received_events", + "repos_url": "https://api.github.com/users/kyma-project/repos", "site_admin": false, - "starred_url": "https://api.github.com/users/edplanes/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/edplanes/subscriptions", + "starred_url": "https://api.github.com/users/kyma-project/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kyma-project/subscriptions", "type": "Organization", - "url": "https://api.github.com/users/edplanes", + "url": "https://api.github.com/users/kyma-project", "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": "git@github.com: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", + "pulls_url": "https://api.github.com/repos/kyma-project/test-infra/pulls{/number}", + "pushed_at": "2024-11-25T09:18:28Z", + "releases_url": "https://api.github.com/repos/kyma-project/test-infra/releases{/id}", + "size": 46482, + "ssh_url": "git@github.com:kyma-project/test-infra.git", + "stargazers_count": 37, + "stargazers_url": "https://api.github.com/repos/kyma-project/test-infra/stargazers", + "statuses_url": "https://api.github.com/repos/kyma-project/test-infra/statuses/{sha}", + "subscribers_url": "https://api.github.com/repos/kyma-project/test-infra/subscribers", + "subscription_url": "https://api.github.com/repos/kyma-project/test-infra/subscription", + "svn_url": "https://github.com/kyma-project/test-infra", + "tags_url": "https://api.github.com/repos/kyma-project/test-infra/tags", + "teams_url": "https://api.github.com/repos/kyma-project/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", + "trees_url": "https://api.github.com/repos/kyma-project/test-infra/git/trees{/sha}", + "updated_at": "2024-11-25T09:13:39Z", + "url": "https://api.github.com/repos/kyma-project/test-infra", "visibility": "public", - "watchers": 0, - "watchers_count": 0, + "watchers": 37, + "watchers_count": 37, "web_commit_signoff_required": false }, "sender": { From dba3860749ddab2ed18e8621c2567a6f2afdb560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Ma=C5=82achowski?= Date: Mon, 25 Nov 2024 08:41:13 +0100 Subject: [PATCH 5/7] Test --- .github/workflows/test.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000000..aa2951422ec1 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,12 @@ +name: test + +on: + merge_group: + + +jobs: + test: + runs-on: ubuntu-latest + steps: + - run: echo $GITHUB_EVENT_NAME + - run: cat $GITHUB_EVENT_PATH \ No newline at end of file From bbea90517fdcbaeaab8d93f85931d14ef1a029e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Ma=C5=82achowski?= Date: Mon, 25 Nov 2024 10:55:27 +0100 Subject: [PATCH 6/7] Fix --- cmd/image-builder/config.go | 1 + cmd/image-builder/config_test.go | 6 +- .../test_fixture/merge-group_event.json | 210 ++++++++++-------- 3 files changed, 118 insertions(+), 99 deletions(-) diff --git a/cmd/image-builder/config.go b/cmd/image-builder/config.go index 0354051a4c13..0b9e71c489be 100644 --- a/cmd/image-builder/config.go +++ b/cmd/image-builder/config.go @@ -318,6 +318,7 @@ func loadGithubActionsGitState() (GitStateConfig, error) { BaseCommitSHA: commitSHA, BaseCommitRef: gitRef, PullHeadCommitSHA: *payload.MergeGroup.HeadSHA, + isPullRequest: true, }, nil default: diff --git a/cmd/image-builder/config_test.go b/cmd/image-builder/config_test.go index 6957108d60af..97ae9d27aa2f 100644 --- a/cmd/image-builder/config_test.go +++ b/cmd/image-builder/config_test.go @@ -371,12 +371,12 @@ func TestLoadGitStateConfig(t *testing.T) { }, gitState: GitStateConfig{ RepositoryName: "test-infra", - RepositoryOwner: "edplanes", + RepositoryOwner: "kyma-project", JobType: "merge_group", BaseCommitSHA: "659bf74f7b4ecab07d9398eec554217b51bad738", BaseCommitRef: "refs/heads/main", - isPullRequest: false, - PullHeadCommitSHA: "d42c05aa25fc3e8bfff0396086de3fccd4b34c29", + isPullRequest: true, + PullHeadCommitSHA: "e47034172c36d3e5fb407b5ba57adf0f7868599d", }, }, } diff --git a/cmd/image-builder/test_fixture/merge-group_event.json b/cmd/image-builder/test_fixture/merge-group_event.json index 6fc5ff47d753..a94215a060ce 100644 --- a/cmd/image-builder/test_fixture/merge-group_event.json +++ b/cmd/image-builder/test_fixture/merge-group_event.json @@ -1,8 +1,20 @@ { "action": "checks_requested", + "enterprise": { + "avatar_url": "https://avatars.githubusercontent.com/b/4978?v=4", + "created_at": "2020-12-16T23:19:05Z", + "description": "SAP Enterprise Account", + "html_url": "https://github.com/enterprises/sap", + "id": 4978, + "name": "SAP", + "node_id": "MDEwOkVudGVycHJpc2U0OTc4", + "slug": "sap", + "updated_at": "2024-06-27T14:56:18Z", + "website_url": "https://sap.com" + }, "merge_group": { - "base_ref": "refs/heads/main", - "base_sha": "659bf74f7b4ecab07d9398eec554217b51bad738", + "base_ref": "refs/heads/test-merge-group", + "base_sha": "4e2379dce4dcce7648c1ae3d7e9f44cf93a2b93d", "head_commit": { "author": { "email": "38684517+KacperMalachowski@users.noreply.github.com", @@ -12,128 +24,134 @@ "email": "noreply@github.com", "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" + "id": "e47034172c36d3e5fb407b5ba57adf0f7868599d", + "message": "Merge pull request #12387 from KacperMalachowski/test-merge-queue\n\nTest merge queue", + "timestamp": "2024-11-25T09:24:38Z", + "tree_id": "3efa879dafdbeee187d2a3cedb8b7b8dae25e904" }, - "head_ref": "refs/heads/gh-readonly-queue/main/pr-26-659bf74f7b4ecab07d9398eec554217b51bad738", - "head_sha": "d42c05aa25fc3e8bfff0396086de3fccd4b34c29" + "head_ref": "refs/heads/gh-readonly-queue/test-merge-group/pr-12387-4e2379dce4dcce7648c1ae3d7e9f44cf93a2b93d", + "head_sha": "e47034172c36d3e5fb407b5ba57adf0f7868599d" }, "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" + "avatar_url": "https://avatars.githubusercontent.com/u/39153523?v=4", + "description": "A flexible and easy way to connect and extend enterprise applications in a cloud-native world.", + "events_url": "https://api.github.com/orgs/kyma-project/events", + "hooks_url": "https://api.github.com/orgs/kyma-project/hooks", + "id": 39153523, + "issues_url": "https://api.github.com/orgs/kyma-project/issues", + "login": "kyma-project", + "members_url": "https://api.github.com/orgs/kyma-project/members{/member}", + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM5MTUzNTIz", + "public_members_url": "https://api.github.com/orgs/kyma-project/public_members{/member}", + "repos_url": "https://api.github.com/orgs/kyma-project/repos", + "url": "https://api.github.com/orgs/kyma-project" }, "repository": { "allow_forking": true, - "archive_url": "https://api.github.com/repos/edplanes/test-infra/{archive_format}{/ref}", + "archive_url": "https://api.github.com/repos/kyma-project/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", + "assignees_url": "https://api.github.com/repos/kyma-project/test-infra/assignees{/user}", + "blobs_url": "https://api.github.com/repos/kyma-project/test-infra/git/blobs{/sha}", + "branches_url": "https://api.github.com/repos/kyma-project/test-infra/branches{/branch}", + "clone_url": "https://github.com/kyma-project/test-infra.git", + "collaborators_url": "https://api.github.com/repos/kyma-project/test-infra/collaborators{/collaborator}", + "comments_url": "https://api.github.com/repos/kyma-project/test-infra/comments{/number}", + "commits_url": "https://api.github.com/repos/kyma-project/test-infra/commits{/sha}", + "compare_url": "https://api.github.com/repos/kyma-project/test-infra/compare/{base}...{head}", + "contents_url": "https://api.github.com/repos/kyma-project/test-infra/contents/{+path}", + "contributors_url": "https://api.github.com/repos/kyma-project/test-infra/contributors", + "created_at": "2018-09-05T09:44:20Z", "custom_properties": {}, "default_branch": "main", - "deployments_url": "https://api.github.com/repos/edplanes/test-infra/deployments", - "description": null, + "deployments_url": "https://api.github.com/repos/kyma-project/test-infra/deployments", + "description": "Test infrastructure for the Kyma project.", "disabled": false, - "downloads_url": "https://api.github.com/repos/edplanes/test-infra/downloads", - "events_url": "https://api.github.com/repos/edplanes/test-infra/events", + "downloads_url": "https://api.github.com/repos/kyma-project/test-infra/downloads", + "events_url": "https://api.github.com/repos/kyma-project/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", + "forks": 180, + "forks_count": 180, + "forks_url": "https://api.github.com/repos/kyma-project/test-infra/forks", + "full_name": "kyma-project/test-infra", + "git_commits_url": "https://api.github.com/repos/kyma-project/test-infra/git/commits{/sha}", + "git_refs_url": "https://api.github.com/repos/kyma-project/test-infra/git/refs{/sha}", + "git_tags_url": "https://api.github.com/repos/kyma-project/test-infra/git/tags{/sha}", + "git_url": "git://github.com/kyma-project/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, + "has_projects": false, + "has_wiki": false, + "homepage": "https://status.build.kyma-project.io/", + "hooks_url": "https://api.github.com/repos/kyma-project/test-infra/hooks", + "html_url": "https://github.com/kyma-project/test-infra", + "id": 147495537, "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}", + "issue_comment_url": "https://api.github.com/repos/kyma-project/test-infra/issues/comments{/number}", + "issue_events_url": "https://api.github.com/repos/kyma-project/test-infra/issues/events{/number}", + "issues_url": "https://api.github.com/repos/kyma-project/test-infra/issues{/number}", + "keys_url": "https://api.github.com/repos/kyma-project/test-infra/keys{/key_id}", + "labels_url": "https://api.github.com/repos/kyma-project/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}", + "languages_url": "https://api.github.com/repos/kyma-project/test-infra/languages", + "license": { + "key": "apache-2.0", + "name": "Apache License 2.0", + "node_id": "MDc6TGljZW5zZTI=", + "spdx_id": "Apache-2.0", + "url": "https://api.github.com/licenses/apache-2.0" + }, + "merges_url": "https://api.github.com/repos/kyma-project/test-infra/merges", + "milestones_url": "https://api.github.com/repos/kyma-project/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, + "node_id": "MDEwOlJlcG9zaXRvcnkxNDc0OTU1Mzc=", + "notifications_url": "https://api.github.com/repos/kyma-project/test-infra/notifications{?since,all,participating}", + "open_issues": 68, + "open_issues_count": 68, "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}", + "avatar_url": "https://avatars.githubusercontent.com/u/39153523?v=4", + "events_url": "https://api.github.com/users/kyma-project/events{/privacy}", + "followers_url": "https://api.github.com/users/kyma-project/followers", + "following_url": "https://api.github.com/users/kyma-project/following{/other_user}", + "gists_url": "https://api.github.com/users/kyma-project/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", + "html_url": "https://github.com/kyma-project", + "id": 39153523, + "login": "kyma-project", + "node_id": "MDEyOk9yZ2FuaXphdGlvbjM5MTUzNTIz", + "organizations_url": "https://api.github.com/users/kyma-project/orgs", + "received_events_url": "https://api.github.com/users/kyma-project/received_events", + "repos_url": "https://api.github.com/users/kyma-project/repos", "site_admin": false, - "starred_url": "https://api.github.com/users/edplanes/starred{/owner}{/repo}", - "subscriptions_url": "https://api.github.com/users/edplanes/subscriptions", + "starred_url": "https://api.github.com/users/kyma-project/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kyma-project/subscriptions", "type": "Organization", - "url": "https://api.github.com/users/edplanes", + "url": "https://api.github.com/users/kyma-project", "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": "git@github.com: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", + "pulls_url": "https://api.github.com/repos/kyma-project/test-infra/pulls{/number}", + "pushed_at": "2024-11-25T09:18:28Z", + "releases_url": "https://api.github.com/repos/kyma-project/test-infra/releases{/id}", + "size": 46482, + "ssh_url": "git@github.com:kyma-project/test-infra.git", + "stargazers_count": 37, + "stargazers_url": "https://api.github.com/repos/kyma-project/test-infra/stargazers", + "statuses_url": "https://api.github.com/repos/kyma-project/test-infra/statuses/{sha}", + "subscribers_url": "https://api.github.com/repos/kyma-project/test-infra/subscribers", + "subscription_url": "https://api.github.com/repos/kyma-project/test-infra/subscription", + "svn_url": "https://github.com/kyma-project/test-infra", + "tags_url": "https://api.github.com/repos/kyma-project/test-infra/tags", + "teams_url": "https://api.github.com/repos/kyma-project/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", + "trees_url": "https://api.github.com/repos/kyma-project/test-infra/git/trees{/sha}", + "updated_at": "2024-11-25T09:13:39Z", + "url": "https://api.github.com/repos/kyma-project/test-infra", "visibility": "public", - "watchers": 0, - "watchers_count": 0, + "watchers": 37, + "watchers_count": 37, "web_commit_signoff_required": false }, "sender": { From 74ea4385885f686430d2d32ecb1082683ba671cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Ma=C5=82achowski?= Date: Mon, 25 Nov 2024 10:56:15 +0100 Subject: [PATCH 7/7] Remove test workflow --- .github/workflows/test.yml | 12 ------------ 1 file changed, 12 deletions(-) delete mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index aa2951422ec1..000000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: test - -on: - merge_group: - - -jobs: - test: - runs-on: ubuntu-latest - steps: - - run: echo $GITHUB_EVENT_NAME - - run: cat $GITHUB_EVENT_PATH \ No newline at end of file