Skip to content

Commit 3348e9d

Browse files
committed
Feedback from code review
1 parent fd048ca commit 3348e9d

4 files changed

Lines changed: 31 additions & 19 deletions

File tree

.github/actions/file/action.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ inputs:
1414
cached_filings:
1515
description: "Cached filings from previous runs, as stringified JSON. Without this, duplicate issues may be filed."
1616
required: false
17-
open_tracking_issues:
18-
description: "In the 'file' step, also open tracking issues which link to all issues with the same problem"
17+
open_grouped_issues:
18+
description: "In the 'file' step, also open tracking issues which link to all issues with the same root cause"
1919
required: false
20+
default: "false"
2021

2122
outputs:
2223
filings:

.github/actions/file/src/index.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import type { Finding, ResolvedFiling, RepeatedFiling } from "./types.d.js";
1+
import type {
2+
Finding,
3+
ResolvedFiling,
4+
RepeatedFiling,
5+
FindingGroupIssue,
6+
Filing,
7+
} from "./types.d.js";
28
import process from "node:process";
39
import core from "@actions/core";
410
import { Octokit } from "@octokit/core";
@@ -11,7 +17,7 @@ import { isResolvedFiling } from "./isResolvedFiling.js";
1117
import { openIssue } from "./openIssue.js";
1218
import { reopenIssue } from "./reopenIssue.js";
1319
import { updateFilingsWithNewFindings } from "./updateFilingsWithNewFindings.js";
14-
import { OctokitResponse } from "@octokit/types";
20+
import type { OctokitResponse } from "@octokit/types";
1521
const OctokitWithThrottling = Octokit.plugin(throttling);
1622

1723
export default async function () {
@@ -24,7 +30,7 @@ export default async function () {
2430
const cachedFilings: (ResolvedFiling | RepeatedFiling)[] = JSON.parse(
2531
core.getInput("cached_filings", { required: false }) || "[]",
2632
);
27-
const shouldOpenTrackingIssues = core.getBooleanInput("open_tracking_issues");
33+
const shouldOpenGroupedIssues = core.getBooleanInput("open_grouped_issues");
2834
core.debug(`Input: 'findings: ${JSON.stringify(findings)}'`);
2935
core.debug(`Input: 'repository: ${repoWithOwner}'`);
3036
core.debug(`Input: 'cached_filings: ${JSON.stringify(cachedFilings)}'`);
@@ -55,8 +61,7 @@ export default async function () {
5561
const filings = updateFilingsWithNewFindings(cachedFilings, findings);
5662

5763
// Track new issues for grouping
58-
const newIssuesByProblemShort: Record<string, { url: string; id: number }[]> =
59-
{};
64+
const newIssuesByProblemShort: Record<string, FindingGroupIssue[]> = {};
6065
const trackingIssueUrls: Record<string, string> = {};
6166

6267
for (const filing of filings) {
@@ -69,12 +74,13 @@ export default async function () {
6974
} else if (isNewFiling(filing)) {
7075
// Open a new issue for the filing
7176
response = await openIssue(octokit, repoWithOwner, filing.findings[0]);
72-
(filing as any).issue = { state: "open" } as Issue;
77+
(filing as Filing).issue = { state: "open" } as Issue;
7378
// Track for grouping
74-
if (shouldOpenTrackingIssues) {
79+
if (shouldOpenGroupedIssues) {
7580
const problemShort: string = filing.findings[0].problemShort;
76-
if (!newIssuesByProblemShort[problemShort])
81+
if (!newIssuesByProblemShort[problemShort]) {
7782
newIssuesByProblemShort[problemShort] = [];
83+
}
7884
newIssuesByProblemShort[problemShort].push({
7985
url: response.data.html_url,
8086
id: response.data.number,
@@ -102,12 +108,12 @@ export default async function () {
102108
}
103109

104110
// Open tracking issues for each root cause and link back from each newly-created issue
105-
if (shouldOpenTrackingIssues) {
111+
if (shouldOpenGroupedIssues) {
106112
for (const [problemShort, issues] of Object.entries(
107113
newIssuesByProblemShort,
108-
) as [string, { url: string; id: number }[]][]) {
114+
)) {
109115
if (issues.length > 1) {
110-
const title: string = `${problemShort} issues`;
116+
const title: string = `Accessibility tracking issue for all ${problemShort} issues`;
111117
const body: string =
112118
`# ${problemShort} issues\n\n` +
113119
issues.map((issue) => `- [ ] ${issue.url}`).join("\n");
@@ -133,9 +139,9 @@ export default async function () {
133139
}
134140
}
135141
}
136-
137-
core.setOutput("filings", JSON.stringify(filings));
138-
core.debug(`Output: 'filings: ${JSON.stringify(filings)}'`);
139-
core.info("Finished 'file' action");
140142
}
143+
144+
core.setOutput("filings", JSON.stringify(filings));
145+
core.debug(`Output: 'filings: ${JSON.stringify(filings)}'`);
146+
core.info("Finished 'file' action");
141147
}

.github/actions/file/src/types.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@ export type RepeatedFiling = {
3333
};
3434

3535
export type Filing = ResolvedFiling | NewFiling | RepeatedFiling;
36+
37+
export type FindingGroupIssue = {
38+
url: string;
39+
id: number;
40+
};

action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ inputs:
3131
description: "Whether to skip assigning filed issues to Copilot"
3232
required: false
3333
default: "false"
34-
open_tracking_issues:
34+
open_grouped_issues:
3535
description: "In the 'file' step, also open tracking issues which link to all issues with the same problem"
3636
required: false
3737
default: "false"
@@ -92,7 +92,7 @@ runs:
9292
repository: ${{ inputs.repository }}
9393
token: ${{ inputs.token }}
9494
cached_filings: ${{ steps.normalize_cache.outputs.value }}
95-
open_tracking_issues: ${{ inputs.open_tracking_issues }}
95+
open_grouped_issues: ${{ inputs.open_grouped_issues }}
9696
- if: ${{ steps.file.outputs.filings }}
9797
name: Get issues from filings
9898
id: get_issues_from_filings

0 commit comments

Comments
 (0)