Skip to content

Commit 62936d7

Browse files
authored
Add milestone labels to PRs when related issues are milestoned (#71)
1 parent 1d49baa commit 62936d7

File tree

6 files changed

+568
-2
lines changed

6 files changed

+568
-2
lines changed

fixtures/issues/milestoned.json

Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
{
2+
"action": "milestoned",
3+
"issue": {
4+
"url": "https://api.github.com/repos/microsoft/TypeScript/issues/60648",
5+
"repository_url": "https://api.github.com/repos/microsoft/TypeScript",
6+
"labels_url": "https://api.github.com/repos/microsoft/TypeScript/issues/60648/labels{/name}",
7+
"comments_url": "https://api.github.com/repos/microsoft/TypeScript/issues/60648/comments",
8+
"events_url": "https://api.github.com/repos/microsoft/TypeScript/issues/60648/events",
9+
"html_url": "https://github.com/microsoft/TypeScript/issues/60648",
10+
"id": 2709502538,
11+
"node_id": "I_kwDOAT9aAc6hf7pK",
12+
"number": 60648,
13+
"title": "Generic function with function as argument autocomplete broken, unless generic argument of the argument function is it's first argument",
14+
"user": {
15+
"login": "julijan",
16+
"id": 1023863,
17+
"node_id": "MDQ6VXNlcjEwMjM4NjM=",
18+
"avatar_url": "https://avatars.githubusercontent.com/u/1023863?v=4",
19+
"gravatar_id": "",
20+
"url": "https://api.github.com/users/julijan",
21+
"html_url": "https://github.com/julijan",
22+
"followers_url": "https://api.github.com/users/julijan/followers",
23+
"following_url": "https://api.github.com/users/julijan/following{/other_user}",
24+
"gists_url": "https://api.github.com/users/julijan/gists{/gist_id}",
25+
"starred_url": "https://api.github.com/users/julijan/starred{/owner}{/repo}",
26+
"subscriptions_url": "https://api.github.com/users/julijan/subscriptions",
27+
"organizations_url": "https://api.github.com/users/julijan/orgs",
28+
"repos_url": "https://api.github.com/users/julijan/repos",
29+
"events_url": "https://api.github.com/users/julijan/events{/privacy}",
30+
"received_events_url": "https://api.github.com/users/julijan/received_events",
31+
"type": "User",
32+
"user_view_type": "public",
33+
"site_admin": false
34+
},
35+
"labels": [],
36+
"state": "open",
37+
"locked": false,
38+
"assignee": null,
39+
"assignees": [],
40+
"milestone": {
41+
"url": "https://api.github.com/repos/microsoft/TypeScript/milestones/29",
42+
"html_url": "https://github.com/microsoft/TypeScript/milestone/29",
43+
"labels_url": "https://api.github.com/repos/microsoft/TypeScript/milestones/29/labels",
44+
"id": 1973940,
45+
"node_id": "MDk6TWlsZXN0b25lMTk3Mzk0MA==",
46+
"number": 29,
47+
"title": "Backlog",
48+
"description": "Please send PRs for issues in the Backlog milestone!",
49+
"creator": {
50+
"login": "mhegazy",
51+
"id": 8000722,
52+
"node_id": "MDQ6VXNlcjgwMDA3MjI=",
53+
"avatar_url": "https://avatars.githubusercontent.com/u/8000722?v=4",
54+
"gravatar_id": "",
55+
"url": "https://api.github.com/users/mhegazy",
56+
"html_url": "https://github.com/mhegazy",
57+
"followers_url": "https://api.github.com/users/mhegazy/followers",
58+
"following_url": "https://api.github.com/users/mhegazy/following{/other_user}",
59+
"gists_url": "https://api.github.com/users/mhegazy/gists{/gist_id}",
60+
"starred_url": "https://api.github.com/users/mhegazy/starred{/owner}{/repo}",
61+
"subscriptions_url": "https://api.github.com/users/mhegazy/subscriptions",
62+
"organizations_url": "https://api.github.com/users/mhegazy/orgs",
63+
"repos_url": "https://api.github.com/users/mhegazy/repos",
64+
"events_url": "https://api.github.com/users/mhegazy/events{/privacy}",
65+
"received_events_url": "https://api.github.com/users/mhegazy/received_events",
66+
"type": "User",
67+
"user_view_type": "public",
68+
"site_admin": false
69+
},
70+
"open_issues": 2374,
71+
"closed_issues": 1965,
72+
"state": "open",
73+
"created_at": "2016-08-31T00:21:08Z",
74+
"updated_at": "2024-12-02T07:35:20Z",
75+
"due_on": null,
76+
"closed_at": null
77+
},
78+
"comments": 1,
79+
"created_at": "2024-12-01T16:48:54Z",
80+
"updated_at": "2024-12-02T07:01:06Z",
81+
"closed_at": null,
82+
"author_association": "NONE",
83+
"sub_issues_summary": {
84+
"total": 0,
85+
"completed": 0,
86+
"percent_completed": 0
87+
},
88+
"active_lock_reason": null,
89+
"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_",
90+
"closed_by": null,
91+
"reactions": {
92+
"url": "https://api.github.com/repos/microsoft/TypeScript/issues/60648/reactions",
93+
"total_count": 0,
94+
"+1": 0,
95+
"-1": 0,
96+
"laugh": 0,
97+
"hooray": 0,
98+
"confused": 0,
99+
"heart": 0,
100+
"rocket": 0,
101+
"eyes": 0
102+
},
103+
"timeline_url": "https://api.github.com/repos/microsoft/TypeScript/issues/60648/timeline",
104+
"performed_via_github_app": null,
105+
"state_reason": null
106+
},
107+
"repository": {
108+
"id": 20929025,
109+
"node_id": "MDEwOlJlcG9zaXRvcnkyMDkyOTAyNQ==",
110+
"name": "TypeScript",
111+
"full_name": "microsoft/TypeScript",
112+
"private": false,
113+
"owner": {
114+
"login": "microsoft",
115+
"id": 6154722,
116+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=",
117+
"avatar_url": "https://avatars2.githubusercontent.com/u/6154722?v=4",
118+
"gravatar_id": "",
119+
"url": "https://api.github.com/users/microsoft",
120+
"html_url": "https://github.com/microsoft",
121+
"followers_url": "https://api.github.com/users/microsoft/followers",
122+
"following_url": "https://api.github.com/users/microsoft/following{/other_user}",
123+
"gists_url": "https://api.github.com/users/microsoft/gists{/gist_id}",
124+
"starred_url": "https://api.github.com/users/microsoft/starred{/owner}{/repo}",
125+
"subscriptions_url": "https://api.github.com/users/microsoft/subscriptions",
126+
"organizations_url": "https://api.github.com/users/microsoft/orgs",
127+
"repos_url": "https://api.github.com/users/microsoft/repos",
128+
"events_url": "https://api.github.com/users/microsoft/events{/privacy}",
129+
"received_events_url": "https://api.github.com/users/microsoft/received_events",
130+
"type": "Organization",
131+
"site_admin": false
132+
},
133+
"html_url": "https://github.com/microsoft/TypeScript",
134+
"description": "TypeScript is a superset of JavaScript that compiles to clean JavaScript output.",
135+
"fork": false,
136+
"url": "https://api.github.com/repos/microsoft/TypeScript",
137+
"forks_url": "https://api.github.com/repos/microsoft/TypeScript/forks",
138+
"keys_url": "https://api.github.com/repos/microsoft/TypeScript/keys{/key_id}",
139+
"collaborators_url": "https://api.github.com/repos/microsoft/TypeScript/collaborators{/collaborator}",
140+
"teams_url": "https://api.github.com/repos/microsoft/TypeScript/teams",
141+
"hooks_url": "https://api.github.com/repos/microsoft/TypeScript/hooks",
142+
"issue_events_url": "https://api.github.com/repos/microsoft/TypeScript/issues/events{/number}",
143+
"events_url": "https://api.github.com/repos/microsoft/TypeScript/events",
144+
"assignees_url": "https://api.github.com/repos/microsoft/TypeScript/assignees{/user}",
145+
"branches_url": "https://api.github.com/repos/microsoft/TypeScript/branches{/branch}",
146+
"tags_url": "https://api.github.com/repos/microsoft/TypeScript/tags",
147+
"blobs_url": "https://api.github.com/repos/microsoft/TypeScript/git/blobs{/sha}",
148+
"git_tags_url": "https://api.github.com/repos/microsoft/TypeScript/git/tags{/sha}",
149+
"git_refs_url": "https://api.github.com/repos/microsoft/TypeScript/git/refs{/sha}",
150+
"trees_url": "https://api.github.com/repos/microsoft/TypeScript/git/trees{/sha}",
151+
"statuses_url": "https://api.github.com/repos/microsoft/TypeScript/statuses/{sha}",
152+
"languages_url": "https://api.github.com/repos/microsoft/TypeScript/languages",
153+
"stargazers_url": "https://api.github.com/repos/microsoft/TypeScript/stargazers",
154+
"contributors_url": "https://api.github.com/repos/microsoft/TypeScript/contributors",
155+
"subscribers_url": "https://api.github.com/repos/microsoft/TypeScript/subscribers",
156+
"subscription_url": "https://api.github.com/repos/microsoft/TypeScript/subscription",
157+
"commits_url": "https://api.github.com/repos/microsoft/TypeScript/commits{/sha}",
158+
"git_commits_url": "https://api.github.com/repos/microsoft/TypeScript/git/commits{/sha}",
159+
"comments_url": "https://api.github.com/repos/microsoft/TypeScript/comments{/number}",
160+
"issue_comment_url": "https://api.github.com/repos/microsoft/TypeScript/issues/comments{/number}",
161+
"contents_url": "https://api.github.com/repos/microsoft/TypeScript/contents/{+path}",
162+
"compare_url": "https://api.github.com/repos/microsoft/TypeScript/compare/{base}...{head}",
163+
"merges_url": "https://api.github.com/repos/microsoft/TypeScript/merges",
164+
"archive_url": "https://api.github.com/repos/microsoft/TypeScript/{archive_format}{/ref}",
165+
"downloads_url": "https://api.github.com/repos/microsoft/TypeScript/downloads",
166+
"issues_url": "https://api.github.com/repos/microsoft/TypeScript/issues{/number}",
167+
"pulls_url": "https://api.github.com/repos/microsoft/TypeScript/pulls{/number}",
168+
"milestones_url": "https://api.github.com/repos/microsoft/TypeScript/milestones{/number}",
169+
"notifications_url": "https://api.github.com/repos/microsoft/TypeScript/notifications{?since,all,participating}",
170+
"labels_url": "https://api.github.com/repos/microsoft/TypeScript/labels{/name}",
171+
"releases_url": "https://api.github.com/repos/microsoft/TypeScript/releases{/id}",
172+
"deployments_url": "https://api.github.com/repos/microsoft/TypeScript/deployments",
173+
"created_at": "2014-06-17T15:28:39Z",
174+
"updated_at": "2019-12-02T20:35:43Z",
175+
"pushed_at": "2019-12-02T20:46:21Z",
176+
"git_url": "git://github.com/microsoft/TypeScript.git",
177+
"ssh_url": "[email protected]:microsoft/TypeScript.git",
178+
"clone_url": "https://github.com/microsoft/TypeScript.git",
179+
"svn_url": "https://github.com/microsoft/TypeScript",
180+
"homepage": "https://www.typescriptlang.org",
181+
"size": 1194161,
182+
"stargazers_count": 56143,
183+
"watchers_count": 56143,
184+
"language": "TypeScript",
185+
"has_issues": true,
186+
"has_projects": true,
187+
"has_downloads": true,
188+
"has_wiki": true,
189+
"has_pages": false,
190+
"forks_count": 7644,
191+
"mirror_url": null,
192+
"archived": false,
193+
"disabled": false,
194+
"open_issues_count": 4099,
195+
"license": {
196+
"key": "apache-2.0",
197+
"name": "Apache License 2.0",
198+
"spdx_id": "Apache-2.0",
199+
"url": "https://api.github.com/licenses/apache-2.0",
200+
"node_id": "MDc6TGljZW5zZTI="
201+
},
202+
"forks": 7644,
203+
"open_issues": 4099,
204+
"watchers": 56143,
205+
"default_branch": "master"
206+
},
207+
"organization": {
208+
"login": "microsoft",
209+
"id": 6154722,
210+
"node_id": "MDEyOk9yZ2FuaXphdGlvbjYxNTQ3MjI=",
211+
"url": "https://api.github.com/orgs/microsoft",
212+
"repos_url": "https://api.github.com/orgs/microsoft/repos",
213+
"events_url": "https://api.github.com/orgs/microsoft/events",
214+
"hooks_url": "https://api.github.com/orgs/microsoft/hooks",
215+
"issues_url": "https://api.github.com/orgs/microsoft/issues",
216+
"members_url": "https://api.github.com/orgs/microsoft/members{/member}",
217+
"public_members_url": "https://api.github.com/orgs/microsoft/public_members{/member}",
218+
"avatar_url": "https://avatars2.githubusercontent.com/u/6154722?v=4",
219+
"description": "Open source, from Microsoft with love"
220+
},
221+
"milestone": {
222+
"url": "https://api.github.com/repos/microsoft/TypeScript/milestones/29",
223+
"html_url": "https://github.com/microsoft/TypeScript/milestone/29",
224+
"labels_url": "https://api.github.com/repos/microsoft/TypeScript/milestones/29/labels",
225+
"id": 1973940,
226+
"node_id": "MDk6TWlsZXN0b25lMTk3Mzk0MA==",
227+
"number": 29,
228+
"title": "Backlog",
229+
"description": "Please send PRs for issues in the Backlog milestone!",
230+
"creator": {
231+
"login": "mhegazy",
232+
"id": 8000722,
233+
"node_id": "MDQ6VXNlcjgwMDA3MjI=",
234+
"avatar_url": "https://avatars.githubusercontent.com/u/8000722?v=4",
235+
"gravatar_id": "",
236+
"url": "https://api.github.com/users/mhegazy",
237+
"html_url": "https://github.com/mhegazy",
238+
"followers_url": "https://api.github.com/users/mhegazy/followers",
239+
"following_url": "https://api.github.com/users/mhegazy/following{/other_user}",
240+
"gists_url": "https://api.github.com/users/mhegazy/gists{/gist_id}",
241+
"starred_url": "https://api.github.com/users/mhegazy/starred{/owner}{/repo}",
242+
"subscriptions_url": "https://api.github.com/users/mhegazy/subscriptions",
243+
"organizations_url": "https://api.github.com/users/mhegazy/orgs",
244+
"repos_url": "https://api.github.com/users/mhegazy/repos",
245+
"events_url": "https://api.github.com/users/mhegazy/events{/privacy}",
246+
"received_events_url": "https://api.github.com/users/mhegazy/received_events",
247+
"type": "User",
248+
"user_view_type": "public",
249+
"site_admin": false
250+
},
251+
"open_issues": 2374,
252+
"closed_issues": 1965,
253+
"state": "open",
254+
"created_at": "2016-08-31T00:21:08Z",
255+
"updated_at": "2024-12-02T07:35:20Z",
256+
"due_on": null,
257+
"closed_at": null
258+
},
259+
"sender": {
260+
"login": "RyanCavanaugh",
261+
"id": 6685088,
262+
"node_id": "MDQ6VXNlcjY2ODUwODg=",
263+
"avatar_url": "https://avatars.githubusercontent.com/u/6685088?v=4",
264+
"gravatar_id": "",
265+
"url": "https://api.github.com/users/RyanCavanaugh",
266+
"html_url": "https://github.com/RyanCavanaugh",
267+
"followers_url": "https://api.github.com/users/RyanCavanaugh/followers",
268+
"following_url": "https://api.github.com/users/RyanCavanaugh/following{/other_user}",
269+
"gists_url": "https://api.github.com/users/RyanCavanaugh/gists{/gist_id}",
270+
"starred_url": "https://api.github.com/users/RyanCavanaugh/starred{/owner}{/repo}",
271+
"subscriptions_url": "https://api.github.com/users/RyanCavanaugh/subscriptions",
272+
"organizations_url": "https://api.github.com/users/RyanCavanaugh/orgs",
273+
"repos_url": "https://api.github.com/users/RyanCavanaugh/repos",
274+
"events_url": "https://api.github.com/users/RyanCavanaugh/events{/privacy}",
275+
"received_events_url": "https://api.github.com/users/RyanCavanaugh/received_events",
276+
"type": "User",
277+
"user_view_type": "public",
278+
"site_admin": false
279+
}
280+
}

src/anyRepoHandleIssue.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { InvocationContext, HttpResponseInit } from "@azure/functions"
33
import { Octokit } from "@octokit/rest"
44
import { sha } from "./sha"
55
import { addReprosLabelOnIssue } from "./checks/addReprosLabel"
6+
import { addMilestoneLabelsToRelatedPRs } from "./checks/addMilestoneLabelsToRelatedPRs";
67
import { createGitHubClient } from "./util/createGitHubClient"
78
import { Logger } from "./util/logger"
89

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

2223
if (payload.repository.name === "TypeScript") {
23-
run("Adding repro tags from issue bodies", addReprosLabelOnIssue)
24+
await run("Adding repro tags from issue bodies", addReprosLabelOnIssue)
25+
await run("Adding milestone labels to related PRs", addMilestoneLabelsToRelatedPRs)
2426
}
2527

2628
return {

0 commit comments

Comments
 (0)