Skip to content

Commit

Permalink
Merge pull request #12827 from microsoft/seanmcm/1_22_9_release
Browse files Browse the repository at this point in the history
Merge for 1.22.9
  • Loading branch information
sean-mcmanus authored Oct 10, 2024
2 parents 3cc2650 + 8a2324d commit 827db55
Show file tree
Hide file tree
Showing 177 changed files with 7,429 additions and 7,735 deletions.
2 changes: 2 additions & 0 deletions .github/actions/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
registry=https://pkgs.dev.azure.com/azure-public/VisualCpp/_packaging/cpp_PublicPackages/npm/registry/
always-auth=true
86 changes: 86 additions & 0 deletions .github/actions/AddComment/AddComment.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

98 changes: 98 additions & 0 deletions .github/actions/AddComment/AddComment.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { GitHub } from '../api/api';
import { ActionBase } from '../common/ActionBase';
import { daysAgoToHumanReadbleDate, daysAgoToTimestamp, safeLog } from '../common/utils';

export class AddComment extends ActionBase {
constructor(
private github: GitHub,
private createdAfter: string | undefined,
private afterDays: number,
labels: string,
private addComment: string,
private addLabels?: string,
private removeLabels?: string,
private setMilestoneId?: string,
milestoneName?: string,
milestoneId?: string,
ignoreLabels?: string,
ignoreMilestoneNames?: string,
ignoreMilestoneIds?: string,
minimumVotes?: number,
maximumVotes?: number,
involves?: string
) {
super(labels, milestoneName, milestoneId, ignoreLabels, ignoreMilestoneNames, ignoreMilestoneIds, minimumVotes, maximumVotes, involves);
}

async run() {
const updatedTimestamp = this.afterDays ? daysAgoToHumanReadbleDate(this.afterDays) : undefined;
const query = this.buildQuery(
(updatedTimestamp ? `updated:<${updatedTimestamp} ` : "") +
(this.createdAfter ? `created:>${this.createdAfter} ` : "") +
"is:open is:unlocked");

const addLabelsSet = this.addLabels ? this.addLabels.split(',') : [];
const removeLabelsSet = this.removeLabels ? this.removeLabels.split(',') : [];

for await (const page of this.github.query({ q: query })) {
for (const issue of page) {
const hydrated = await issue.getIssue();
if (hydrated.open && this.validateIssue(hydrated)
// TODO: Verify updated timestamp
) {
// Don't add a comment if already commented on by an action.
let foundActionComment = false;
for await (const commentBatch of issue.getComments()) {
for (const comment of commentBatch) {
if (comment.author.isGitHubApp) {
foundActionComment = true;
break;
}
}
if (foundActionComment)
break;
}
if (foundActionComment) {
safeLog(`Issue ${hydrated.number} already commented on by an action. Ignoring.`);
continue;
}

if (this.addComment) {
safeLog(`Posting comment on issue ${hydrated.number}`);
await issue.postComment(this.addComment);
}
if (removeLabelsSet.length > 0) {
for (const removeLabel of removeLabelsSet) {
if (removeLabel && removeLabel.length > 0) {
safeLog(`Removing label on issue ${hydrated.number}: ${removeLabel}`);
await issue.removeLabel(removeLabel);
}
}
}
if (addLabelsSet.length > 0) {
for (const addLabel of addLabelsSet) {
if (addLabel && addLabel.length > 0) {
safeLog(`Adding label on issue ${hydrated.number}: ${addLabel}`);
await issue.addLabel(addLabel);
}
}
}
if (this.setMilestoneId != undefined) {
safeLog(`Setting milestone of issue ${hydrated.number} to id ${+this.setMilestoneId}`);
await issue.setMilestone(+this.setMilestoneId);
}
safeLog(`Processing issue ${hydrated.number}.`);
} else {
if (!hydrated.open) {
safeLog(`Issue ${hydrated.number} is not open. Ignoring`);
}
}
}
}
}
}
42 changes: 42 additions & 0 deletions .github/actions/AddComment/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Add Comment and Label
description: Add comment (etc) to issues that are marked with a specified label (etc)
inputs:
token:
description: GitHub token with issue, comment, and label read/write permissions
default: ${{ github.token }}
createdAfter:
description: Creation date after which to be considered.
required: false
afterDays:
description: Days to wait before performing this action (may be 0).
required: false
addComment:
description: Comment to add
labels:
description: items with these labels will be considered. May be "*".
required: true
milestoneName:
description: items with these milestones will be considered (name only, must match ID)
milestoneId:
description: items with these milestones will be considered (id only, must match name)
ignoreLabels:
description: items with these labels will not be considered
ignoreMilestoneNames:
description: items with these milestones will not be considered (names only, must match IDs). May be "*".
ignoreMilestoneIds:
description: items with these milestones will not be considered (IDs only, must match names)
addLabels:
description: Labels to add to issue.
removeLabels:
description: Labels to remove from issue.
minimumVotes:
descriptions: Only issues with at least this many votes will be considered.
maximumVotes:
descriptions: Only issues fewer or equal to this many votes will be considered.
involves:
descriptions: Qualifier to find issues that in some way involve a certain user either as an author, assignee, or mentions.
readonly:
description: If true, changes are not applied.
runs:
using: 'node12'
main: 'index.js'
20 changes: 20 additions & 0 deletions .github/actions/AddComment/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions .github/actions/AddComment/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { OctoKit } from '../api/octokit'
import { getInput, getRequiredInput } from '../common/utils'
import { AddComment } from './AddComment'
import { Action } from '../common/Action'

class AddCommentAction extends Action {
id = 'AddComment';

async onTriggered(github: OctoKit) {
await new AddComment(
github,
getInput('createdAfter') || undefined,
+(getInput('afterDays') || 0),
getRequiredInput('labels'),
getInput('addComment') || '',
getInput('addLabels') || undefined,
getInput('removeLabels') || undefined,
getInput('setMilestoneId') || undefined,
getInput('milestoneName') || undefined,
getInput('milestoneId') || undefined,
getInput('ignoreLabels') || undefined,
getInput('ignoreMilestoneNames') || undefined,
getInput('ignoreMilestoneIds') || undefined,
+(getInput('minimumVotes') || 0),
+(getInput('maximumVotes') || 9999999),
getInput('involves') || undefined
).run();
}
}

new AddCommentAction().run(); // eslint-disable-line
2 changes: 1 addition & 1 deletion .github/actions/Locker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ inputs:
milestoneId:
description: items with these milestones will be considered (id only, must match name)
labels:
description: items with these labels will not be considered. May be "*".
description: items with these labels will be considered. May be "*".
ignoreMilestoneNames:
description: items with these milestones will not be considered (names only, must match IDs). May be "*".
ignoreMilestoneIds:
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/Reopener/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ inputs:
milestoneId:
description: items with these milestones will be considered (id only, must match name)
labels:
description: items with these labels will not be considered. May be "*".
description: items with these labels will be considered. May be "*".
ignoreMilestoneNames:
description: items with these milestones will not be considered (names only, must match IDs). May be "*".
ignoreMilestoneIds:
Expand Down
Loading

0 comments on commit 827db55

Please sign in to comment.