Skip to content
Merged
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
31 changes: 29 additions & 2 deletions .github/local-actions/branch-manager/main.js

Large diffs are not rendered by default.

31 changes: 29 additions & 2 deletions .github/local-actions/labels-sync/main.js

Large diffs are not rendered by default.

31 changes: 29 additions & 2 deletions github-actions/branch-manager/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions github-actions/issue-labeling/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ts_project(
":node_modules/@octokit/rest",
":node_modules/@types/node",
"//github-actions:utils",
"//ng-dev/pr/common/labels",
],
)

Expand Down
13 changes: 12 additions & 1 deletion github-actions/issue-labeling/lib/issue-labeling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {GoogleGenAI} from '@google/genai';
import {Octokit} from '@octokit/rest';
import {ANGULAR_ROBOT, getAuthTokenFor, revokeActiveInstallationToken} from '../../utils.js';
import {components} from '@octokit/openapi-types';
import {miscLabels} from '../../../ng-dev/pr/common/labels/index.js';

export class IssueLabeling {
static run = async () => {
Expand Down Expand Up @@ -38,8 +39,17 @@ export class IssueLabeling {
// Initialize labels and issue data
await this.initialize();

const ai = this.getGenerativeAI();
// Determine if the issue already has an area label, if it does we can exit early.
if (
this.issueData?.labels.some((label) =>
(typeof label === 'string' ? label : label.name)?.startsWith('area: '),
)
) {
this.coreService.info('Issue already has an area label. Skipping.');
return;
}

const ai = this.getGenerativeAI();
const prompt = `
You are a helper for an open source repository.
Your task is to allow the user to categorize the issue with an "area: " label.
Expand Down Expand Up @@ -71,6 +81,7 @@ If no area label applies, respond with "none".

if (this.repoAreaLabels.has(text)) {
await this.addLabel(text);
await this.addLabel(miscLabels.GEMINI_TRIAGED.name);
} else {
this.coreService.info(
`Generated label "${text}" is not in the list of valid area labels or is "ambiguous"/"none".`,
Expand Down
16 changes: 16 additions & 0 deletions github-actions/issue-labeling/lib/main.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ describe('IssueLabeling', () => {
data: {
title: 'Tough Issue',
body: 'Complex Body',
labels: [],
},
}),
);
Expand Down Expand Up @@ -117,4 +118,19 @@ describe('IssueLabeling', () => {
expect(issueLabeling).toBeDefined();
expect(mockCore.getInput).not.toHaveBeenCalled(); // until run is called
});

it('should skip labeling when issue already has an area label', async () => {
mockGit.issues.get.and.resolveTo({
data: {
title: 'Tough Issue',
body: 'Complex Body',
labels: [{name: 'area: core'}],
},
});

await issueLabeling.run();

expect(mockGit.issues.addLabels).not.toHaveBeenCalled();
expect(mockCore.info).toHaveBeenCalledWith('Issue already has an area label. Skipping.');
});
});
301 changes: 300 additions & 1 deletion github-actions/issue-labeling/main.js

Large diffs are not rendered by default.

31 changes: 29 additions & 2 deletions github-actions/pull-request-labeling/main.js

Large diffs are not rendered by default.

31 changes: 29 additions & 2 deletions github-actions/unified-status-check/main.js

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion ng-dev/pr/common/labels/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {priorityLabels} from './priority.js';
import {featureLabels} from './feature.js';
import {requiresLabels} from './requires.js';
import {Label, LabelParams} from './base.js';
import {miscLabels} from './misc.js';

export const allLabels = {
...managedLabels,
Expand All @@ -15,10 +16,19 @@ export const allLabels = {
...priorityLabels,
...featureLabels,
...requiresLabels,
...miscLabels,
};

// Ensures that all labels in `allLabels` properly implement `Label`.
const _typeCheckEnforceAllLabels: Record<PropertyKey, Label<LabelParams>> = allLabels;

export {managedLabels, actionLabels, mergeLabels, targetLabels, priorityLabels, requiresLabels};
export {
managedLabels,
actionLabels,
mergeLabels,
targetLabels,
priorityLabels,
requiresLabels,
miscLabels,
};
export {Label};
4 changes: 4 additions & 0 deletions ng-dev/pr/common/labels/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ export const miscLabels = createTypedObject(MiscLabel)({
description:
'Label noting that a pull request will automatically be managed and rebased by renovate',
},
GEMINI_TRIAGED: {
name: 'gemini-triaged',
description: 'Label noting that an issue has been triaged by gemini',
},
});