-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the add milestone github action #32691
Conversation
@@ -41,26 +38,19 @@ const isDuplicateValidationError = ( error ) => | |||
* @param {string} repo Repository name. | |||
* @param {string} title Milestone title. | |||
* | |||
* @return {Promise<OktokitIssuesListMilestonesForRepoResponseItem|void>} Promise resolving to milestone, if exists. | |||
* @return {Promise<any|void>} Promise resolving to milestone, if exists. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how these types are defined now, but import('@octokit/rest').IssuesListMilestonesForRepoResponseItem
no longer works.
// The included version of RequestError provides no way to access the | ||
// full 'errors' array that the github REST API returns. Hopefully they | ||
// resolve this soon! | ||
return requestError.message.includes( 'already_exists' ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately @actions/github
uses quite an old version of their RequestError
library.
Size Change: 0 B Total Size: 1.04 MB ℹ️ View Unchanged
|
Looks like there's existing unit tests, so for folks 👀 we can run this with:
|
references for the API endpoint: |
Example response: curl \
> -H "Accept: application/vnd.github.v3+json" \
> https://api.github.com/repos/WordPress/gutenberg/milestones
[
{
"url": "https://api.github.com/repos/WordPress/gutenberg/milestones/70",
"html_url": "https://github.com/WordPress/gutenberg/milestone/70",
"labels_url": "https://api.github.com/repos/WordPress/gutenberg/milestones/70/labels",
"id": 3734039,
"node_id": "MDk6TWlsZXN0b25lMzczNDAzOQ==",
"number": 70,
"title": "WordPress 5.x",
"description": "Tasks to be done for a major WordPress release in the near to medium term.",
"creator": {
"login": "mtias",
"id": 548849,
"node_id": "MDQ6VXNlcjU0ODg0OQ==",
"avatar_url": "https://avatars.githubusercontent.com/u/548849?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/mtias",
"html_url": "https://github.com/mtias",
"followers_url": "https://api.github.com/users/mtias/followers",
"following_url": "https://api.github.com/users/mtias/following{/other_user}",
"gists_url": "https://api.github.com/users/mtias/gists{/gist_id}",
"starred_url": "https://api.github.com/users/mtias/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/mtias/subscriptions",
"organizations_url": "https://api.github.com/users/mtias/orgs",
"repos_url": "https://api.github.com/users/mtias/repos",
"events_url": "https://api.github.com/users/mtias/events{/privacy}",
"received_events_url": "https://api.github.com/users/mtias/received_events",
"type": "User",
"site_admin": false
},
"open_issues": 99,
"closed_issues": 236,
"state": "open",
"created_at": "2018-10-12T14:46:17Z",
"updated_at": "2021-06-07T10:03:10Z",
"due_on": null,
"closed_at": null
},
{
"url": "https://api.github.com/repos/WordPress/gutenberg/milestones/150",
"html_url": "https://github.com/WordPress/gutenberg/milestone/150",
"labels_url": "https://api.github.com/repos/WordPress/gutenberg/milestones/150/labels",
"id": 6778712,
"node_id": "MDk6TWlsZXN0b25lNjc3ODcxMg==",
"number": 150,
"title": "Gutenberg 10.8",
"description": null,
"creator": {
"login": "github-actions[bot]",
"id": 41898282,
"node_id": "MDM6Qm90NDE4OTgyODI=",
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/github-actions%5Bbot%5D",
"html_url": "https://github.com/apps/github-actions",
"followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
"following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
"gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
"starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
"organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
"repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
"events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
"received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
"type": "Bot",
"site_admin": false
},
"open_issues": 0,
"closed_issues": 172,
"state": "open",
"created_at": "2021-05-20T20:12:51Z",
"updated_at": "2021-06-15T14:52:33Z",
"due_on": "2021-06-02T07:00:00Z",
"closed_at": null
},
{
"url": "https://api.github.com/repos/WordPress/gutenberg/milestones/151",
"html_url": "https://github.com/WordPress/gutenberg/milestone/151",
"labels_url": "https://api.github.com/repos/WordPress/gutenberg/milestones/151/labels",
"id": 6817780,
"node_id": "MDk6TWlsZXN0b25lNjgxNzc4MA==",
"number": 151,
"title": "Gutenberg 10.9",
"description": null,
"creator": {
"login": "github-actions[bot]",
"id": 41898282,
"node_id": "MDM6Qm90NDE4OTgyODI=",
"avatar_url": "https://avatars.githubusercontent.com/in/15368?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/github-actions%5Bbot%5D",
"html_url": "https://github.com/apps/github-actions",
"followers_url": "https://api.github.com/users/github-actions%5Bbot%5D/followers",
"following_url": "https://api.github.com/users/github-actions%5Bbot%5D/following{/other_user}",
"gists_url": "https://api.github.com/users/github-actions%5Bbot%5D/gists{/gist_id}",
"starred_url": "https://api.github.com/users/github-actions%5Bbot%5D/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/github-actions%5Bbot%5D/subscriptions",
"organizations_url": "https://api.github.com/users/github-actions%5Bbot%5D/orgs",
"repos_url": "https://api.github.com/users/github-actions%5Bbot%5D/repos",
"events_url": "https://api.github.com/users/github-actions%5Bbot%5D/events{/privacy}",
"received_events_url": "https://api.github.com/users/github-actions%5Bbot%5D/received_events",
"type": "Bot",
"site_admin": false
},
"open_issues": 2,
"closed_issues": 96,
"state": "open",
"created_at": "2021-06-03T01:59:35Z",
"updated_at": "2021-06-15T14:52:34Z",
"due_on": "2021-06-16T07:00:00Z",
"closed_at": null
}
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to give tentative approval. Let's try to rebase the PR since the performance test and E2E were not green.
I tested this by making sure units still worked, and checked to see if a real response shape was about right.
🤔 So in theory types should be generated in https://github.com/octokit/openapi-types.ts https://octokit.github.io/types.ts/interfaces/generated_endpoints.endpoints.html#get__repos__owner___repo__milestones
But this doesn't look particularly useful. One thing we could do is define an inline type with what we expect (plus other unknown additional properties). Since this is already broken in trunk, I think it's also fine to use any
for now and follow up with a better type.
I also wonder if we need to setup a periodic integration test, since units won't catch if GH APIs change.
97e9a00
to
92a4fc0
Compare
Thanks for the review, will merge and hopefully it'll work 🤞. |
Awesome, looks like the fix worked. Now to go back and add the milestone to all the PRs that were missed 😄 |
Not sure it helps, but on the note of Octokit type defs, there's been a few related conversations over at #29043. |
@ockham Thanks, I didn't realise we had other usages of octokit/rest in the codebase. I also noticed the |
Description
For some reason the Add Milestone github action stopped working recently. (slack convo - https://wordpress.slack.com/archives/C02QB2JS7/p1623640633051900).
The cause seems to be a change in the error format from the API.
The libraries we're using are quite outdated, so I decided to try updating them. It didn't go completely smoothly.
In particular I found the TypeScript definitions hard to work with, so I'd appreciate some help with that.
How has this been tested?
Actions should pass
Types of changes
Bug fix (non-breaking change which fixes an issue)