Skip to content

Commit 7179738

Browse files
refactor(github-actions): update labeling prompt with descriptions
This allows for providing more info via github label descriptions so the prompt can possibly do a better job of automatically labeling issues.
1 parent d69b99a commit 7179738

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

github-actions/labeling/issue/lib/issue-labeling.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ describe('IssueLabeling', () => {
2121
// Mock paginate to return the result of the promise if it's a list, or just execute the callback
2222
(mockGit.paginate as jasmine.Spy).and.callFake((fn: any, args: any) => {
2323
if (fn === mockGit.issues.listLabelsOnIssue) {
24-
return Promise.resolve([{name: 'area: core'}, {name: 'area: router'}, {name: 'bug'}]);
24+
return Promise.resolve([
25+
{name: 'area: core', description: 'Core Angular framework'},
26+
{name: 'area: router', description: 'Angular Router'},
27+
{name: 'bug', description: 'Bug report'},
28+
]);
2529
}
2630
return Promise.resolve([]);
2731
});

github-actions/labeling/issue/lib/issue-labeling.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {Labeling} from '../../shared/labeling.js';
88
export class IssueLabeling extends Labeling {
99
readonly type = 'Issue';
1010
/** Set of area labels available in the current repository. */
11-
repoAreaLabels = new Set<string>();
11+
repoAreaLabels = new Map<string, string>();
1212
/** The issue data fetched from Github. */
1313
issueData?: components['schemas']['issue'];
1414

@@ -17,7 +17,7 @@ export class IssueLabeling extends Labeling {
1717

1818
// Determine if the issue already has an area label, if it does we can exit early.
1919
if (
20-
this.issueData?.labels.some((label) =>
20+
this.issueData?.labels.some((label: string | {name?: string}) =>
2121
(typeof label === 'string' ? label : label.name)?.startsWith('area: '),
2222
)
2323
) {
@@ -35,12 +35,12 @@ Title: ${this.issueData!.title}
3535
Body:
3636
${this.issueData!.body}
3737
38-
The available area labels are:
38+
The available area labels and descriptions are:
3939
${Array.from(this.repoAreaLabels)
40-
.map((label) => ` - ${label}`)
40+
.map(([label, description]) => ` - Label: "${label}", Description: "${description}"`)
4141
.join('\n')}
4242
43-
Based on the content, which area label is the best fit?
43+
Based on the content of the issue and the labels and descriptions above, which area label is the best fit?
4444
Respond ONLY with the exact label name (e.g. "area: core").
4545
If you are strictly unsure or if multiple labels match equally well, respond with "ambiguous".
4646
If no area label applies, respond with "none".
@@ -82,7 +82,7 @@ If no area label applies, respond with "none".
8282
.then((labels) =>
8383
labels
8484
.filter((l) => l.name.startsWith('area: '))
85-
.forEach((l) => this.repoAreaLabels.add(l.name)),
85+
.forEach((l) => this.repoAreaLabels.set(l.name, l.description ?? '')),
8686
),
8787
this.git.issues.get({owner, repo, issue_number: context.issue.number}).then((resp) => {
8888
this.issueData = resp.data;

github-actions/labeling/issue/main.js

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)