From 35c555382f79b9e2f046e1cb78d82661e54b505c Mon Sep 17 00:00:00 2001 From: Jan Koehnlein Date: Fri, 22 Oct 2021 15:54:36 +0000 Subject: [PATCH] [projectmanager] fixed moving of issues --- column.txt | 162 ++++++++++++++++++++++++++++++++ config/projectmanager.yaml | 5 + plugins/common/github.go | 1 + plugins/projectmanager/build.sh | 2 +- plugins/projectmanager/main.go | 7 +- 5 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 column.txt diff --git a/column.txt b/column.txt new file mode 100644 index 0000000..9785e19 --- /dev/null +++ b/column.txt @@ -0,0 +1,162 @@ +[ + { + "url": "https://api.github.com/projects/columns/cards/71283249", + "project_url": "https://api.github.com/projects/12696765", + "id": 71283249, + "node_id": "PRC_lADOAjTo384Awby9zgQ_sjE", + "note": null, + "archived": false, + "creator": { + "login": "princerachit", + "id": 32481722, + "node_id": "MDQ6VXNlcjMyNDgxNzIy", + "avatar_url": "https://avatars.githubusercontent.com/u/32481722?u=638e24474e29bafde3ac9216349ad5ed2db80b03&v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/princerachit", + "html_url": "https://github.com/princerachit", + "followers_url": "https://api.github.com/users/princerachit/followers", + "following_url": "https://api.github.com/users/princerachit/following{/other_user}", + "gists_url": "https://api.github.com/users/princerachit/gists{/gist_id}", + "starred_url": "https://api.github.com/users/princerachit/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/princerachit/subscriptions", + "organizations_url": "https://api.github.com/users/princerachit/orgs", + "repos_url": "https://api.github.com/users/princerachit/repos", + "events_url": "https://api.github.com/users/princerachit/events{/privacy}", + "received_events_url": "https://api.github.com/users/princerachit/received_events", + "type": "User", + "site_admin": false + }, + "created_at": "2021-10-21T09:48:27Z", + "updated_at": "2021-10-21T09:48:53Z", + "column_url": "https://api.github.com/projects/columns/14782120", + "content_url": "https://api.github.com/repos/gitpod-io/gitpod/issues/6332" + }, + { + "url": "https://api.github.com/projects/columns/cards/71283442", + "project_url": "https://api.github.com/projects/12696765", + "id": 71283442, + "node_id": "PRC_lADOAjTo384Awby9zgQ_svI", + "note": null, + "archived": false, + "creator": { + "login": "princerachit", + "id": 32481722, + "node_id": "MDQ6VXNlcjMyNDgxNzIy", + "avatar_url": "https://avatars.githubusercontent.com/u/32481722?u=638e24474e29bafde3ac9216349ad5ed2db80b03&v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/princerachit", + "html_url": "https://github.com/princerachit", + "followers_url": "https://api.github.com/users/princerachit/followers", + "following_url": "https://api.github.com/users/princerachit/following{/other_user}", + "gists_url": "https://api.github.com/users/princerachit/gists{/gist_id}", + "starred_url": "https://api.github.com/users/princerachit/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/princerachit/subscriptions", + "organizations_url": "https://api.github.com/users/princerachit/orgs", + "repos_url": "https://api.github.com/users/princerachit/repos", + "events_url": "https://api.github.com/users/princerachit/events{/privacy}", + "received_events_url": "https://api.github.com/users/princerachit/received_events", + "type": "User", + "site_admin": false + }, + "created_at": "2021-10-21T09:51:18Z", + "updated_at": "2021-10-21T09:51:24Z", + "column_url": "https://api.github.com/projects/columns/14782120", + "content_url": "https://api.github.com/repos/gitpod-io/gitpod/issues/6333" + }, + { + "url": "https://api.github.com/projects/columns/cards/71295524", + "project_url": "https://api.github.com/projects/12696765", + "id": 71295524, + "node_id": "PRC_lADOAjTo384Awby9zgQ_4iQ", + "note": null, + "archived": false, + "creator": { + "login": "JanKoehnlein", + "id": 377752, + "node_id": "MDQ6VXNlcjM3Nzc1Mg==", + "avatar_url": "https://avatars.githubusercontent.com/u/377752?u=6e97b016434e7f4957702e03a4e63f116abc8576&v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/JanKoehnlein", + "html_url": "https://github.com/JanKoehnlein", + "followers_url": "https://api.github.com/users/JanKoehnlein/followers", + "following_url": "https://api.github.com/users/JanKoehnlein/following{/other_user}", + "gists_url": "https://api.github.com/users/JanKoehnlein/gists{/gist_id}", + "starred_url": "https://api.github.com/users/JanKoehnlein/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/JanKoehnlein/subscriptions", + "organizations_url": "https://api.github.com/users/JanKoehnlein/orgs", + "repos_url": "https://api.github.com/users/JanKoehnlein/repos", + "events_url": "https://api.github.com/users/JanKoehnlein/events{/privacy}", + "received_events_url": "https://api.github.com/users/JanKoehnlein/received_events", + "type": "User", + "site_admin": false + }, + "created_at": "2021-10-21T12:53:24Z", + "updated_at": "2021-10-21T12:54:18Z", + "column_url": "https://api.github.com/projects/columns/14782120", + "content_url": "https://api.github.com/repos/gitpod-io/gitpod/issues/6320" + }, + { + "url": "https://api.github.com/projects/columns/cards/71361247", + "project_url": "https://api.github.com/projects/12696765", + "id": 71361247, + "node_id": "PRC_lADOAjTo384Awby9zgRA4t8", + "note": null, + "archived": false, + "creator": { + "login": "csweichel", + "id": 3210701, + "node_id": "MDQ6VXNlcjMyMTA3MDE=", + "avatar_url": "https://avatars.githubusercontent.com/u/3210701?u=34b34ff0b896f1be0e5d1c8777210d1a995b762e&v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/csweichel", + "html_url": "https://github.com/csweichel", + "followers_url": "https://api.github.com/users/csweichel/followers", + "following_url": "https://api.github.com/users/csweichel/following{/other_user}", + "gists_url": "https://api.github.com/users/csweichel/gists{/gist_id}", + "starred_url": "https://api.github.com/users/csweichel/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/csweichel/subscriptions", + "organizations_url": "https://api.github.com/users/csweichel/orgs", + "repos_url": "https://api.github.com/users/csweichel/repos", + "events_url": "https://api.github.com/users/csweichel/events{/privacy}", + "received_events_url": "https://api.github.com/users/csweichel/received_events", + "type": "User", + "site_admin": false + }, + "created_at": "2021-10-22T08:43:46Z", + "updated_at": "2021-10-22T08:43:52Z", + "column_url": "https://api.github.com/projects/columns/14782120", + "content_url": "https://api.github.com/repos/gitpod-io/gitpod/issues/4848" + }, + { + "url": "https://api.github.com/projects/columns/cards/71361350", + "project_url": "https://api.github.com/projects/12696765", + "id": 71361350, + "node_id": "PRC_lADOAjTo384Awby9zgRA40Y", + "note": null, + "archived": false, + "creator": { + "login": "csweichel", + "id": 3210701, + "node_id": "MDQ6VXNlcjMyMTA3MDE=", + "avatar_url": "https://avatars.githubusercontent.com/u/3210701?u=34b34ff0b896f1be0e5d1c8777210d1a995b762e&v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/csweichel", + "html_url": "https://github.com/csweichel", + "followers_url": "https://api.github.com/users/csweichel/followers", + "following_url": "https://api.github.com/users/csweichel/following{/other_user}", + "gists_url": "https://api.github.com/users/csweichel/gists{/gist_id}", + "starred_url": "https://api.github.com/users/csweichel/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/csweichel/subscriptions", + "organizations_url": "https://api.github.com/users/csweichel/orgs", + "repos_url": "https://api.github.com/users/csweichel/repos", + "events_url": "https://api.github.com/users/csweichel/events{/privacy}", + "received_events_url": "https://api.github.com/users/csweichel/received_events", + "type": "User", + "site_admin": false + }, + "created_at": "2021-10-22T08:44:51Z", + "updated_at": "2021-10-22T08:44:58Z", + "column_url": "https://api.github.com/projects/columns/14782120", + "content_url": "https://api.github.com/repos/gitpod-io/gitpod/issues/6352" + } +] diff --git a/config/projectmanager.yaml b/config/projectmanager.yaml index 904e5a9..e8bf3bb 100644 --- a/config/projectmanager.yaml +++ b/config/projectmanager.yaml @@ -26,6 +26,11 @@ orgsRepos: labels: - "groundwork: awaiting deployment" state: "closed" + - id: 14782155 + org: "gitpod-io" + labels: + - "groundwork: deployed" + state: "closed" "gitpod-io/gitpod-test-repo": projects: "Groundwork Test": diff --git a/plugins/common/github.go b/plugins/common/github.go index bf0a4be..8474368 100644 --- a/plugins/common/github.go +++ b/plugins/common/github.go @@ -17,6 +17,7 @@ import ( func FindCardByIssueURL(gh github.Client, org, repo string, number int, col int) (cardID *int, err error) { issueURL := fmt.Sprintf("https://api.github.com/repos/%s/%s/issues/%v", org, repo, number) + // Funny fact: this also returns cards from other columns, even in other projects inboxCards, err := gh.GetColumnProjectCards(org, col) if err != nil { return diff --git a/plugins/projectmanager/build.sh b/plugins/projectmanager/build.sh index 9442ba4..472add4 100755 --- a/plugins/projectmanager/build.sh +++ b/plugins/projectmanager/build.sh @@ -2,7 +2,7 @@ set -ex -export TAG=cw-dev +export TAG=dev cp -rf ../common common docker build -t eu.gcr.io/gitpod-core-dev/prow/projectmanager:$TAG . diff --git a/plugins/projectmanager/main.go b/plugins/projectmanager/main.go index ffbe72b..f13571c 100644 --- a/plugins/projectmanager/main.go +++ b/plugins/projectmanager/main.go @@ -301,8 +301,10 @@ func (s *server) updateMatchingColumn(ie github.IssueEvent, log *logrus.Entry) e for projectName, managedProject := range managedOrgRepo.Projects { for _, managedColumn := range managedProject.Columns { + log.Infof("Project %s Column: %d (%s)", projectName, *managedColumn.ID, managedColumn.Labels) if managedColumn.ID == nil { log.Infof("Ignoring column: {%v}, has no columnID", managedColumn, e.number, e.org) + continue } // Org is not specified or does not match we just ignore processing this column if managedColumn.Org == "" || managedColumn.Org != e.org { @@ -323,15 +325,18 @@ func (s *server) updateMatchingColumn(ie github.IssueEvent, log *logrus.Entry) e continue } - cardID, err := common.FindCardByIssueURL(gc, orgRepoName, projectName, e.number, *managedColumn.ID) + log.Infof("Searching for card for issue #%d for in column: %d", e.number, *managedColumn.ID) + cardID, err := common.FindCardByIssueURL(gc, orgRepoName, e.repo, e.number, *managedColumn.ID) if err != nil { log.Infof("Cannot add the issue/PR: %d to the project: %s, column: %s, error: %s", e.number, projectName, managedColumn.ID, err) break } if cardID == nil { + log.Infof("No such card. Creating a new one") err = addIssueToColumn(gc, *managedColumn.ID, e) } else { + log.Infof("Found card %d, moving", cardID) err = common.MoveProjectCard(s.githubTokenGenerator, e.org, *cardID, *managedColumn.ID, "bottom") } if err != nil {