Skip to content

Commit 83df900

Browse files
authored
Merge pull request #6448 from microsoft/seanmcm/1_1_0_release
1_1_0 release
2 parents 80ea255 + b1d7d19 commit 83df900

File tree

130 files changed

+5395
-505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+5395
-505
lines changed

.github/actions/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# ignore dependency packages
2+
node_modules
3+
*.js.map

.github/actions/Locker/Locker.js

Lines changed: 43 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/Locker/Locker.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See LICENSE in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { GitHub, Issue } from '../api/api'
7+
import { daysAgoToHumanReadbleDate } from '../common/utils'
8+
import { ActionBase } from '../common/ActionBase'
9+
10+
export class Locker extends ActionBase {
11+
constructor(
12+
private github: GitHub,
13+
private daysSinceClose: number,
14+
private daysSinceUpdate: number,
15+
labels?: string,
16+
milestoneName?: string,
17+
milestoneId?: string,
18+
ignoreLabels?: string,
19+
ignoreMilestoneNames?: string,
20+
ignoreMilestoneIds?: string,
21+
minimumVotes?: number,
22+
maximumVotes?: number
23+
)
24+
{
25+
super(labels, milestoneName, milestoneId, ignoreLabels, ignoreMilestoneNames, ignoreMilestoneIds, minimumVotes, maximumVotes);
26+
}
27+
28+
async run() {
29+
const closedTimestamp = daysAgoToHumanReadbleDate(this.daysSinceClose)
30+
const updatedTimestamp = daysAgoToHumanReadbleDate(this.daysSinceUpdate)
31+
32+
const query = this.buildQuery((this.daysSinceClose ? `closed:<${closedTimestamp} ` : "") + (this.daysSinceUpdate ? `updated:<${updatedTimestamp} ` : "") + "is:closed is:unlocked");
33+
34+
for await (const page of this.github.query({ q: query })) {
35+
await Promise.all(
36+
page.map(async (issue) => {
37+
const hydrated = await issue.getIssue()
38+
39+
if (!hydrated.locked && hydrated.open === false && this.validateIssue(hydrated)
40+
// TODO: Verify closed and updated timestamps
41+
) {
42+
console.log(`Locking issue ${hydrated.number}`)
43+
await issue.lockIssue()
44+
} else {
45+
if (hydrated.locked) {
46+
console.log(`Issue ${hydrated.number} is already locked. Ignoring`)
47+
} else if (hydrated.open) {
48+
console.log(`Issue ${hydrated.number} is open. Ignoring`)
49+
}
50+
}
51+
}),
52+
)
53+
}
54+
}
55+
}

.github/actions/Locker/action.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Locker
2+
description: Lock closed issues and PRs after some time has passed
3+
inputs:
4+
token:
5+
description: GitHub token with issue, comment, and label read/write permissions
6+
default: ${{ github.token }}
7+
daysSinceClose:
8+
description: Days to wait since closing before locking the item
9+
required: true
10+
daysSinceUpdate:
11+
description: days to wait since the last interaction before locking the item
12+
required: true
13+
milestoneName:
14+
description: items with these milestones will be considered (name only, must match ID)
15+
milestoneId:
16+
description: items with these milestones will be considered (id only, must match name)
17+
labels:
18+
description: items with these labels will not be considered. May be "*".
19+
ignoreMilestoneNames:
20+
description: items with these milestones will not be considered (names only, must match IDs). May be "*".
21+
ignoreMilestoneIds:
22+
description: items with these milestones will not be considered (IDs only, must match names)
23+
ignoreLabels:
24+
description: items with these labels will not be considered
25+
minimumVotes:
26+
descriptions: Only issues with at least this many votes will be considered.
27+
maximumVotes:
28+
descriptions: Only issues fewer or equal to this many votes will be considered.
29+
readonly:
30+
description: If true, changes are not applied.
31+
runs:
32+
using: 'node12'
33+
main: 'index.js'

.github/actions/Locker/index.js

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/actions/Locker/index.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See LICENSE in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { OctoKit } from '../api/octokit'
7+
import { getInput, getRequiredInput } from '../common/utils'
8+
import { Locker } from './Locker'
9+
import { Action } from '../common/Action'
10+
11+
class LockerAction extends Action {
12+
id = 'Locker'
13+
14+
async onTriggered(github: OctoKit) {
15+
await new Locker(
16+
github,
17+
+getRequiredInput('daysSinceClose'),
18+
+getRequiredInput('daysSinceUpdate'),
19+
getInput('labels') || undefined,
20+
getInput('milestoneName') || undefined,
21+
getInput('milestoneId') || undefined,
22+
getInput('ignoreLabels') || undefined,
23+
getInput('ignoreMilestoneNames') || undefined,
24+
getInput('ignoreMilestoneIds') || undefined,
25+
+(getInput('minimumVotes') || 0),
26+
+(getInput('maximumVotes') || 9999999)
27+
).run()
28+
}
29+
}
30+
31+
new LockerAction().run() // eslint-disable-line

.github/actions/Reopener/Reopener.js

Lines changed: 72 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See LICENSE in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import { GitHub, Issue } from '../api/api'
7+
import { ActionBase } from '../common/ActionBase'
8+
9+
export class Reopener extends ActionBase {
10+
constructor(
11+
private github: GitHub,
12+
private alsoApplyToOpenIssues: boolean,
13+
private addLabels?: string,
14+
private removeLabels?: string,
15+
private reopenComment?: string,
16+
private setMilestoneId?: string,
17+
labels?: string,
18+
milestoneName?: string,
19+
milestoneId?: string,
20+
ignoreLabels?: string,
21+
ignoreMilestoneNames?: string,
22+
ignoreMilestoneIds?: string,
23+
minimumVotes?: number,
24+
maximumVotes?: number
25+
)
26+
{
27+
super(labels, milestoneName, milestoneId, ignoreLabels, ignoreMilestoneNames, ignoreMilestoneIds, minimumVotes, maximumVotes);
28+
}
29+
30+
async run() {
31+
const addLabelsSet = this.addLabels ? this.addLabels.split(',') : [];
32+
const removeLabelsSet = this.removeLabels ? this.removeLabels.split(',') : [];
33+
34+
console.log(`alsoApplyToOpenIssues: ${this.alsoApplyToOpenIssues}`);
35+
36+
const query = this.buildQuery((this.alsoApplyToOpenIssues ? "": "is:closed ") + "is:unlocked");
37+
38+
for await (const page of this.github.query({ q: query })) {
39+
await Promise.all(
40+
page.map(async (issue) => {
41+
const hydrated = await issue.getIssue()
42+
if (!hydrated.locked && (this.alsoApplyToOpenIssues || hydrated.open === false) && this.validateIssue(hydrated)
43+
// TODO: Verify closed and updated timestamps
44+
) {
45+
if (hydrated.open === false) {
46+
console.log(`Reopening issue ${hydrated.number}`)
47+
await issue.reopenIssue()
48+
}
49+
if (this.setMilestoneId != undefined) {
50+
console.log(`Setting milestone of issue ${hydrated.number} to id ${+this.setMilestoneId}`)
51+
await issue.setMilestone(+this.setMilestoneId)
52+
}
53+
if (removeLabelsSet.length > 0) {
54+
for (const removeLabel of removeLabelsSet) {
55+
if (removeLabel && removeLabel.length > 0) {
56+
console.log(`Removing label on issue ${hydrated.number}: ${removeLabel}`)
57+
await issue.removeLabel(removeLabel)
58+
}
59+
}
60+
}
61+
if (addLabelsSet.length > 0) {
62+
for (const addLabel of addLabelsSet) {
63+
if (addLabel && addLabel.length > 0) {
64+
console.log(`Adding label on issue ${hydrated.number}: ${addLabel}`)
65+
await issue.addLabel(addLabel)
66+
}
67+
}
68+
}
69+
if (this.reopenComment) {
70+
console.log(`Posting comment to issue ${hydrated.number}.`)
71+
await issue.postComment(this.reopenComment)
72+
}
73+
} else {
74+
if (hydrated.locked) {
75+
console.log(`Issue ${hydrated.number} is locked. Ignoring`)
76+
} else if (!this.alsoApplyToOpenIssues && hydrated.open) {
77+
console.log(`Issue ${hydrated.number} is open. Ignoring`)
78+
}
79+
}
80+
}),
81+
)
82+
}
83+
}
84+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Locker
2+
description: Lock closed issues and PRs after some time has passed
3+
inputs:
4+
token:
5+
description: GitHub token with issue, comment, and label read/write permissions
6+
default: ${{ github.token }}
7+
alsoApplyToOpenIssues:
8+
description: If true, applies to issues that are already opened (to add/remove labels, etc., but not reopen).
9+
addLabels:
10+
description: Labels to add to issue as it is reopend.
11+
reopenComment:
12+
description: Comment to add upon reopening the issue.
13+
setMilestoneId:
14+
description: Milestone to set reopened issue to.
15+
removeLabels:
16+
description: Labels to remove from issue as it is reopened.
17+
milestoneName:
18+
description: items with these milestones will be considered (name only, must match ID)
19+
milestoneId:
20+
description: items with these milestones will be considered (id only, must match name)
21+
labels:
22+
description: items with these labels will not be considered. May be "*".
23+
ignoreMilestoneNames:
24+
description: items with these milestones will not be considered (names only, must match IDs). May be "*".
25+
ignoreMilestoneIds:
26+
description: items with these milestones will not be considered (IDs only, must match names)
27+
ignoreLabels:
28+
description: items with these labels will not be considered
29+
minimumVotes:
30+
descriptions: Only issues with at least this many votes will be considered.
31+
maximumVotes:
32+
descriptions: Only issues fewer or equal to this many votes will be considered.
33+
readonly:
34+
description: If true, changes are not applied.
35+
runs:
36+
using: 'node12'
37+
main: 'index.js'

0 commit comments

Comments
 (0)