Skip to content

Add milestone labels to PRs when related issues are milestoned #71

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
280 changes: 280 additions & 0 deletions fixtures/issues/milestoned.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,280 @@
{
"action": "milestoned",
"issue": {
"url": "https://api.github.com/repos/microsoft/TypeScript/issues/60648",
"repository_url": "https://api.github.com/repos/microsoft/TypeScript",
"labels_url": "https://api.github.com/repos/microsoft/TypeScript/issues/60648/labels{/name}",
"comments_url": "https://api.github.com/repos/microsoft/TypeScript/issues/60648/comments",
"events_url": "https://api.github.com/repos/microsoft/TypeScript/issues/60648/events",
"html_url": "https://github.com/microsoft/TypeScript/issues/60648",
"id": 2709502538,
"node_id": "I_kwDOAT9aAc6hf7pK",
"number": 60648,
"title": "Generic function with function as argument autocomplete broken, unless generic argument of the argument function is it's first argument",
"user": {
"login": "julijan",
"id": 1023863,
"node_id": "MDQ6VXNlcjEwMjM4NjM=",
"avatar_url": "https://avatars.githubusercontent.com/u/1023863?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/julijan",
"html_url": "https://github.com/julijan",
"followers_url": "https://api.github.com/users/julijan/followers",
"following_url": "https://api.github.com/users/julijan/following{/other_user}",
"gists_url": "https://api.github.com/users/julijan/gists{/gist_id}",
"starred_url": "https://api.github.com/users/julijan/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/julijan/subscriptions",
"organizations_url": "https://api.github.com/users/julijan/orgs",
"repos_url": "https://api.github.com/users/julijan/repos",
"events_url": "https://api.github.com/users/julijan/events{/privacy}",
"received_events_url": "https://api.github.com/users/julijan/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"labels": [],
"state": "open",
"locked": false,
"assignee": null,
"assignees": [],
"milestone": {
"url": "https://api.github.com/repos/microsoft/TypeScript/milestones/29",
"html_url": "https://github.com/microsoft/TypeScript/milestone/29",
"labels_url": "https://api.github.com/repos/microsoft/TypeScript/milestones/29/labels",
"id": 1973940,
"node_id": "MDk6TWlsZXN0b25lMTk3Mzk0MA==",
"number": 29,
"title": "Backlog",
"description": "Please send PRs for issues in the Backlog milestone!",
"creator": {
"login": "mhegazy",
"id": 8000722,
"node_id": "MDQ6VXNlcjgwMDA3MjI=",
"avatar_url": "https://avatars.githubusercontent.com/u/8000722?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/mhegazy",
"html_url": "https://github.com/mhegazy",
"followers_url": "https://api.github.com/users/mhegazy/followers",
"following_url": "https://api.github.com/users/mhegazy/following{/other_user}",
"gists_url": "https://api.github.com/users/mhegazy/gists{/gist_id}",
"starred_url": "https://api.github.com/users/mhegazy/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/mhegazy/subscriptions",
"organizations_url": "https://api.github.com/users/mhegazy/orgs",
"repos_url": "https://api.github.com/users/mhegazy/repos",
"events_url": "https://api.github.com/users/mhegazy/events{/privacy}",
"received_events_url": "https://api.github.com/users/mhegazy/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"open_issues": 2374,
"closed_issues": 1965,
"state": "open",
"created_at": "2016-08-31T00:21:08Z",
"updated_at": "2024-12-02T07:35:20Z",
"due_on": null,
"closed_at": null
},
"comments": 1,
"created_at": "2024-12-01T16:48:54Z",
"updated_at": "2024-12-02T07:01:06Z",
"closed_at": null,
"author_association": "NONE",
"sub_issues_summary": {
"total": 0,
"completed": 0,
"percent_completed": 0
},
"active_lock_reason": null,
"body": "### 🔎 Search Terms\n\ntypescript generic function no autocomplete function as argument\n\n### 🕗 Version & Regression Information\n\nRelevant versions are 5.4.5 and above, tested in all versions from 5.4.5 to 5.8.0 (Nightly) inclusive, I was able to reproduce the bug in all versions.\n\n### ⏯ Playground Link\n\nhttps://www.typescriptlang.org/play/?ts=5.7.2#code/IYZwngdgxgBAZgV2gFwJYHsIwE4FMDmqIyu2ACgDYKEQBCwAJgDwDyADsjLgB4kQMgYAJVxR02ZsWyoI+ADQxgEMAD4VACijAKFAEbAoAawBcMdcDZtTSsAvQcMEEKfbIAlDAC8KmADd0qAx2HM4wAHLoAJIQcKSsHCpupmTY6AC2RLhM-oE+AN4AvgBQRXiExKSU1DL0DOrmlsHIoXkwIOm4yAAWMvimUr0wBR7eMIUKeUUwMAD0MzC6uBToAO6KCMjoYmlsFJ24MEQLqYa4EAq4vmcw3ejUXTddB8hgbAdHbKlv2BRgftqBYAkBhTNodIrDADcJSKc0OEBIeGIvV+CmAGy26V2+xgK3EhkEqDgMAARPY0JgQCTFNh8Ag0mdONtcII4KhsMQFHBxFxuMAdntjEVQJBYIgUI4cAQiIiqjQAOLodDMVy8vgCYSicSSZDSWRo5RqTTaPQGExmcmOUKuNGWazKEY+HJBGDk0IRaKxbDxZCJZKpDIgLLO-LFUrSirkKgKpV1dRu0ytdoM7q9fq6wYFW1WRQOryhiaguGLZZrdGbbbYki4-EgUHJ3AQtyQoA\n\n### 💻 Code\n\n```ts\nasync function registerPluginBad<Opt extends Record<string, any>>(callback: (app: any, options: Opt) => void, opts: NoInfer<Opt>): Promise<void> {}\n\nregisterPluginBad((app, opts: { something: string }) => {}, {\n // below autocomplete is broken, even though the type is properly validated\n some\n});\n\n\n// interestingly, autocomplete works if \"options\" argument comes first, for example:\nasync function registerPluginGood<Opt extends Record<string, any>>(callback: (options: Opt, app: any) => void, opts: NoInfer<Opt>): Promise<void> {}\n\nregisterPluginGood((opts: { something: string }, app: any) => {}, {\n // below autocomplete works\n some\n});\n```\n\n\n### 🙁 Actual behavior\n\nThis one has to be tested in the playground:\nregisterPluginBad - second argument does not autocomplete, however type is properly validated\nregisterPluginGood - exact same function, except the first argument \"callback\" arguments have changed the order, which for some reason fixes the autocomplete\n\n### 🙂 Expected behavior\n\nFor both functions, autocomplete should work. Argument order should not matter.\nBoth do not infer from \"opts\", so any inference should be from \"options\" argument of the callback.\n\n### Additional information about the issue\n\n_No response_",
"closed_by": null,
"reactions": {
"url": "https://api.github.com/repos/microsoft/TypeScript/issues/60648/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"timeline_url": "https://api.github.com/repos/microsoft/TypeScript/issues/60648/timeline",
"performed_via_github_app": null,
"state_reason": null
},
"repository": {
"id": 20929025,
"node_id": "MDEwOlJlcG9zaXRvcnkyMDkyOTAyNQ==",
"name": "TypeScript",
"full_name": "microsoft/TypeScript",
"private": false,
"owner": {
"login": "microsoft",
"id": 6154722,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=",
"avatar_url": "https://avatars2.githubusercontent.com/u/6154722?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/microsoft",
"html_url": "https://github.com/microsoft",
"followers_url": "https://api.github.com/users/microsoft/followers",
"following_url": "https://api.github.com/users/microsoft/following{/other_user}",
"gists_url": "https://api.github.com/users/microsoft/gists{/gist_id}",
"starred_url": "https://api.github.com/users/microsoft/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/microsoft/subscriptions",
"organizations_url": "https://api.github.com/users/microsoft/orgs",
"repos_url": "https://api.github.com/users/microsoft/repos",
"events_url": "https://api.github.com/users/microsoft/events{/privacy}",
"received_events_url": "https://api.github.com/users/microsoft/received_events",
"type": "Organization",
"site_admin": false
},
"html_url": "https://github.com/microsoft/TypeScript",
"description": "TypeScript is a superset of JavaScript that compiles to clean JavaScript output.",
"fork": false,
"url": "https://api.github.com/repos/microsoft/TypeScript",
"forks_url": "https://api.github.com/repos/microsoft/TypeScript/forks",
"keys_url": "https://api.github.com/repos/microsoft/TypeScript/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/microsoft/TypeScript/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/microsoft/TypeScript/teams",
"hooks_url": "https://api.github.com/repos/microsoft/TypeScript/hooks",
"issue_events_url": "https://api.github.com/repos/microsoft/TypeScript/issues/events{/number}",
"events_url": "https://api.github.com/repos/microsoft/TypeScript/events",
"assignees_url": "https://api.github.com/repos/microsoft/TypeScript/assignees{/user}",
"branches_url": "https://api.github.com/repos/microsoft/TypeScript/branches{/branch}",
"tags_url": "https://api.github.com/repos/microsoft/TypeScript/tags",
"blobs_url": "https://api.github.com/repos/microsoft/TypeScript/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/microsoft/TypeScript/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/microsoft/TypeScript/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/microsoft/TypeScript/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/microsoft/TypeScript/statuses/{sha}",
"languages_url": "https://api.github.com/repos/microsoft/TypeScript/languages",
"stargazers_url": "https://api.github.com/repos/microsoft/TypeScript/stargazers",
"contributors_url": "https://api.github.com/repos/microsoft/TypeScript/contributors",
"subscribers_url": "https://api.github.com/repos/microsoft/TypeScript/subscribers",
"subscription_url": "https://api.github.com/repos/microsoft/TypeScript/subscription",
"commits_url": "https://api.github.com/repos/microsoft/TypeScript/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/microsoft/TypeScript/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/microsoft/TypeScript/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/microsoft/TypeScript/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/microsoft/TypeScript/contents/{+path}",
"compare_url": "https://api.github.com/repos/microsoft/TypeScript/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/microsoft/TypeScript/merges",
"archive_url": "https://api.github.com/repos/microsoft/TypeScript/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/microsoft/TypeScript/downloads",
"issues_url": "https://api.github.com/repos/microsoft/TypeScript/issues{/number}",
"pulls_url": "https://api.github.com/repos/microsoft/TypeScript/pulls{/number}",
"milestones_url": "https://api.github.com/repos/microsoft/TypeScript/milestones{/number}",
"notifications_url": "https://api.github.com/repos/microsoft/TypeScript/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/microsoft/TypeScript/labels{/name}",
"releases_url": "https://api.github.com/repos/microsoft/TypeScript/releases{/id}",
"deployments_url": "https://api.github.com/repos/microsoft/TypeScript/deployments",
"created_at": "2014-06-17T15:28:39Z",
"updated_at": "2019-12-02T20:35:43Z",
"pushed_at": "2019-12-02T20:46:21Z",
"git_url": "git://github.com/microsoft/TypeScript.git",
"ssh_url": "git@github.com:microsoft/TypeScript.git",
"clone_url": "https://github.com/microsoft/TypeScript.git",
"svn_url": "https://github.com/microsoft/TypeScript",
"homepage": "https://www.typescriptlang.org",
"size": 1194161,
"stargazers_count": 56143,
"watchers_count": 56143,
"language": "TypeScript",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 7644,
"mirror_url": null,
"archived": false,
"disabled": false,
"open_issues_count": 4099,
"license": {
"key": "apache-2.0",
"name": "Apache License 2.0",
"spdx_id": "Apache-2.0",
"url": "https://api.github.com/licenses/apache-2.0",
"node_id": "MDc6TGljZW5zZTI="
},
"forks": 7644,
"open_issues": 4099,
"watchers": 56143,
"default_branch": "master"
},
"organization": {
"login": "microsoft",
"id": 6154722,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=",
"url": "https://api.github.com/orgs/microsoft",
"repos_url": "https://api.github.com/orgs/microsoft/repos",
"events_url": "https://api.github.com/orgs/microsoft/events",
"hooks_url": "https://api.github.com/orgs/microsoft/hooks",
"issues_url": "https://api.github.com/orgs/microsoft/issues",
"members_url": "https://api.github.com/orgs/microsoft/members{/member}",
"public_members_url": "https://api.github.com/orgs/microsoft/public_members{/member}",
"avatar_url": "https://avatars2.githubusercontent.com/u/6154722?v=4",
"description": "Open source, from Microsoft with love"
},
"milestone": {
"url": "https://api.github.com/repos/microsoft/TypeScript/milestones/29",
"html_url": "https://github.com/microsoft/TypeScript/milestone/29",
"labels_url": "https://api.github.com/repos/microsoft/TypeScript/milestones/29/labels",
"id": 1973940,
"node_id": "MDk6TWlsZXN0b25lMTk3Mzk0MA==",
"number": 29,
"title": "Backlog",
"description": "Please send PRs for issues in the Backlog milestone!",
"creator": {
"login": "mhegazy",
"id": 8000722,
"node_id": "MDQ6VXNlcjgwMDA3MjI=",
"avatar_url": "https://avatars.githubusercontent.com/u/8000722?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/mhegazy",
"html_url": "https://github.com/mhegazy",
"followers_url": "https://api.github.com/users/mhegazy/followers",
"following_url": "https://api.github.com/users/mhegazy/following{/other_user}",
"gists_url": "https://api.github.com/users/mhegazy/gists{/gist_id}",
"starred_url": "https://api.github.com/users/mhegazy/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/mhegazy/subscriptions",
"organizations_url": "https://api.github.com/users/mhegazy/orgs",
"repos_url": "https://api.github.com/users/mhegazy/repos",
"events_url": "https://api.github.com/users/mhegazy/events{/privacy}",
"received_events_url": "https://api.github.com/users/mhegazy/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
},
"open_issues": 2374,
"closed_issues": 1965,
"state": "open",
"created_at": "2016-08-31T00:21:08Z",
"updated_at": "2024-12-02T07:35:20Z",
"due_on": null,
"closed_at": null
},
"sender": {
"login": "RyanCavanaugh",
"id": 6685088,
"node_id": "MDQ6VXNlcjY2ODUwODg=",
"avatar_url": "https://avatars.githubusercontent.com/u/6685088?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/RyanCavanaugh",
"html_url": "https://github.com/RyanCavanaugh",
"followers_url": "https://api.github.com/users/RyanCavanaugh/followers",
"following_url": "https://api.github.com/users/RyanCavanaugh/following{/other_user}",
"gists_url": "https://api.github.com/users/RyanCavanaugh/gists{/gist_id}",
"starred_url": "https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/RyanCavanaugh/subscriptions",
"organizations_url": "https://api.github.com/users/RyanCavanaugh/orgs",
"repos_url": "https://api.github.com/users/RyanCavanaugh/repos",
"events_url": "https://api.github.com/users/RyanCavanaugh/events{/privacy}",
"received_events_url": "https://api.github.com/users/RyanCavanaugh/received_events",
"type": "User",
"user_view_type": "public",
"site_admin": false
}
}
4 changes: 3 additions & 1 deletion src/anyRepoHandleIssue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { InvocationContext, HttpResponseInit } from "@azure/functions"
import { Octokit } from "@octokit/rest"
import { sha } from "./sha"
import { addReprosLabelOnIssue } from "./checks/addReprosLabel"
import { addMilestoneLabelsToRelatedPRs } from "./checks/addMilestoneLabelsToRelatedPRs";
import { createGitHubClient } from "./util/createGitHubClient"
import { Logger } from "./util/logger"

Expand All @@ -20,7 +21,8 @@ export const handleIssuePayload = async (payload: IssuesEvent, context: Invocati
}

if (payload.repository.name === "TypeScript") {
run("Adding repro tags from issue bodies", addReprosLabelOnIssue)
await run("Adding repro tags from issue bodies", addReprosLabelOnIssue)
await run("Adding milestone labels to related PRs", addMilestoneLabelsToRelatedPRs)
Comment on lines +24 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The promise was unawaited intentionally before; otherwise if the handler takes more than 10 seconds, the request will error out due to a timeout on GitHub's side of the webhook.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do u recommend then? those run actions are awaited in other webhooks so I followed suite here. Should this just kick off both "jobs"? Or maybe the old one should not be awaited but the new one should be awaited?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, they are? Weird.... Maybe we assume they're fast enough but I'd have to check the logs

}

return {
Expand Down
Loading