Update classifier inputs and query parameters (#274)

This commit is contained in:
Bhavya U 2024-07-22 08:27:21 -07:00 коммит произвёл GitHub
Родитель 8eedcd3589
Коммит 7815c4d9cf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
6 изменённых файлов: 48 добавлений и 20 удалений

Просмотреть файл

@ -1,9 +1,21 @@
name: "Classifier: Apply Labels" name: "Classifier: Apply Labels"
description: Applies labels generated from the python script back to their respective issues description: Applies labels generated from the python script back to their respective issues
inputs: inputs:
token: app_id:
description: GitHub token with issue, comment, and label read/write permissions description: GitHub App ID
default: ${{ github.token }} required: true
app_installation_id:
description: GitHub App Installation ID
required: true
app_private_key:
description: GitHub App Private Key
required: true
owner:
description: Repository owner
required: true
repo:
description: Repository name
required: true
configPath: configPath:
description: The PATH of a .github/PATH.json in the repo that describes what should be done per feature area description: The PATH of a .github/PATH.json in the repo that describes what should be done per feature area
required: true required: true

Просмотреть файл

@ -7,14 +7,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.Availability = void 0; exports.Availability = void 0;
const fs_1 = require("fs"); const fs_1 = require("fs");
const path_1 = require("path"); const path_1 = require("path");
const github_1 = require("@actions/github");
const octokit_1 = require("../../../api/octokit"); const octokit_1 = require("../../../api/octokit");
const utils_1 = require("../../../common/utils");
const Action_1 = require("../../../common/Action");
const vscodeTools_1 = require("../../../api/vscodeTools"); const vscodeTools_1 = require("../../../api/vscodeTools");
const token = (0, utils_1.getRequiredInput)('token'); const Action_1 = require("../../../common/Action");
const utils_1 = require("../../../common/utils");
const allowLabels = ((0, utils_1.getInput)('allowLabels') || '').split('|'); const allowLabels = ((0, utils_1.getInput)('allowLabels') || '').split('|');
const debug = !!(0, utils_1.getInput)('__debug'); const debug = !!(0, utils_1.getInput)('__debug');
const repo = (0, utils_1.getRequiredInput)('repo');
const owner = (0, utils_1.getRequiredInput)('owner');
// Do not modify. // Do not modify.
// Copied from https://github.com/microsoft/vscode-tools/blob/91715fe00caab042b4aab5ed41d0402b0ae2393b/src/common/endgame.ts#L11-L16 // Copied from https://github.com/microsoft/vscode-tools/blob/91715fe00caab042b4aab5ed41d0402b0ae2393b/src/common/endgame.ts#L11-L16
var Availability; var Availability;
@ -32,9 +32,10 @@ class ApplyLabels extends Action_1.Action {
async onTriggered(github) { async onTriggered(github) {
var _a; var _a;
const config = await github.readConfig((0, utils_1.getRequiredInput)('configPath')); const config = await github.readConfig((0, utils_1.getRequiredInput)('configPath'));
const token = await (0, Action_1.getAuthenticationToken)();
const labelings = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../issue_labels.json'), { encoding: 'utf8' })); const labelings = JSON.parse((0, fs_1.readFileSync)((0, path_1.join)(__dirname, '../issue_labels.json'), { encoding: 'utf8' }));
for (const labeling of labelings) { for (const labeling of labelings) {
const issue = new octokit_1.OctoKitIssue(token, github_1.context.repo, { number: labeling.number }); const issue = new octokit_1.OctoKitIssue(token, { owner, repo }, { number: labeling.number });
const potentialAssignees = []; const potentialAssignees = [];
const addAssignee = async (assignee) => { const addAssignee = async (assignee) => {
var _a; var _a;

Просмотреть файл

@ -5,16 +5,15 @@
import { readFileSync } from 'fs'; import { readFileSync } from 'fs';
import { join } from 'path'; import { join } from 'path';
import { context } from '@actions/github';
import { OctoKit, OctoKitIssue } from '../../../api/octokit'; import { OctoKit, OctoKitIssue } from '../../../api/octokit';
import { getRequiredInput, getInput, safeLog, daysAgoToHumanReadbleDate } from '../../../common/utils';
import { Action } from '../../../common/Action';
import { VSCodeToolsAPIManager } from '../../../api/vscodeTools'; import { VSCodeToolsAPIManager } from '../../../api/vscodeTools';
import { Action, getAuthenticationToken } from '../../../common/Action';
const token = getRequiredInput('token'); import { daysAgoToHumanReadbleDate, getInput, getRequiredInput, safeLog } from '../../../common/utils';
const allowLabels = (getInput('allowLabels') || '').split('|'); const allowLabels = (getInput('allowLabels') || '').split('|');
const debug = !!getInput('__debug'); const debug = !!getInput('__debug');
const repo = getRequiredInput('repo');
const owner = getRequiredInput('owner');
type ClassifierConfig = { type ClassifierConfig = {
vacation?: string[]; vacation?: string[];
@ -43,12 +42,13 @@ class ApplyLabels extends Action {
async onTriggered(github: OctoKit) { async onTriggered(github: OctoKit) {
const config: ClassifierConfig = await github.readConfig(getRequiredInput('configPath')); const config: ClassifierConfig = await github.readConfig(getRequiredInput('configPath'));
const token = await getAuthenticationToken();
const labelings: LabelingsFile = JSON.parse( const labelings: LabelingsFile = JSON.parse(
readFileSync(join(__dirname, '../issue_labels.json'), { encoding: 'utf8' }), readFileSync(join(__dirname, '../issue_labels.json'), { encoding: 'utf8' }),
); );
for (const labeling of labelings) { for (const labeling of labelings) {
const issue = new OctoKitIssue(token, context.repo, { number: labeling.number }); const issue = new OctoKitIssue(token, { owner, repo }, { number: labeling.number });
const potentialAssignees: string[] = []; const potentialAssignees: string[] = [];
const addAssignee = async (assignee: string) => { const addAssignee = async (assignee: string) => {

Просмотреть файл

@ -1,9 +1,21 @@
name: "Classifier: Fetch Sources" name: "Classifier: Fetch Sources"
description: Collect the issues/models/etc which are needed for later stages description: Collect the issues/models/etc which are needed for later stages
inputs: inputs:
token: app_id:
description: GitHub token with issue, comment, and label read/write permissions description: GitHub App ID
default: ${{ github.token }} required: true
app_installation_id:
description: GitHub App Installation ID
required: true
app_private_key:
description: GitHub App Private Key
required: true
owner:
description: Repository owner
required: true
repo:
description: Repository name
required: true
from: from:
description: Start point of collected issues (minutes ago) description: Start point of collected issues (minutes ago)
required: true required: true

Просмотреть файл

@ -21,6 +21,8 @@ const from = fromInput ? (0, utils_1.daysAgoToHumanReadbleDate)(+fromInput * min
const until = (0, utils_1.daysAgoToHumanReadbleDate)(+(0, utils_1.getRequiredInput)('until') * minToDay); const until = (0, utils_1.daysAgoToHumanReadbleDate)(+(0, utils_1.getRequiredInput)('until') * minToDay);
const createdQuery = `created:` + (from ? `${from}..${until}` : `<${until}`); const createdQuery = `created:` + (from ? `${from}..${until}` : `<${until}`);
const blobContainer = (0, utils_1.getRequiredInput)('blobContainerName'); const blobContainer = (0, utils_1.getRequiredInput)('blobContainerName');
const repo = (0, utils_1.getRequiredInput)('repo');
const owner = (0, utils_1.getRequiredInput)('owner');
class FetchIssues extends Action_1.Action { class FetchIssues extends Action_1.Action {
constructor() { constructor() {
super(...arguments); super(...arguments);
@ -28,7 +30,7 @@ class FetchIssues extends Action_1.Action {
} }
async onTriggered(github) { async onTriggered(github) {
var _a; var _a;
const query = `${createdQuery} is:open no:assignee ${excludeLabels}`; const query = `repo:${owner}/${repo} ${createdQuery} is:open no:assignee ${excludeLabels}`;
const data = []; const data = [];
for await (const page of github.query({ q: query })) { for await (const page of github.query({ q: query })) {
for (const issue of page) { for (const issue of page) {

Просмотреть файл

@ -24,12 +24,13 @@ const until = daysAgoToHumanReadbleDate(+getRequiredInput('until') * minToDay);
const createdQuery = `created:` + (from ? `${from}..${until}` : `<${until}`); const createdQuery = `created:` + (from ? `${from}..${until}` : `<${until}`);
const blobContainer = getRequiredInput('blobContainerName'); const blobContainer = getRequiredInput('blobContainerName');
const repo = getRequiredInput('repo');
const owner = getRequiredInput('owner');
class FetchIssues extends Action { class FetchIssues extends Action {
id = 'Clasifier-Deep/Apply/FetchIssues'; id = 'Clasifier-Deep/Apply/FetchIssues';
async onTriggered(github: OctoKit) { async onTriggered(github: OctoKit) {
const query = `${createdQuery} is:open no:assignee ${excludeLabels}`; const query = `repo:${owner}/${repo} ${createdQuery} is:open no:assignee ${excludeLabels}`;
const data: { number: number; contents: string }[] = []; const data: { number: number; contents: string }[] = [];
for await (const page of github.query({ q: query })) { for await (const page of github.query({ q: query })) {