Skip to content

Commit d80ec89

Browse files
committed
feat: Add more/better logging
1 parent cb245ba commit d80ec89

File tree

3 files changed

+52
-20
lines changed

3 files changed

+52
-20
lines changed

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

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,46 +6,63 @@ import { closeIssueForFinding } from "./closeIssueForFinding.js";
66
import { openIssueForFinding } from "./openIssueForFinding.js";
77

88
export default async function () {
9+
core.info("Started 'file' action");
910
const findings: Finding[] = JSON.parse(core.getInput('findings', { required: true }));
1011
const repoWithOwner = core.getInput('repository', { required: true });
1112
const token = core.getInput('token', { required: true });
1213
const cachedFindings: Finding[] = JSON.parse(core.getInput('cached_findings', { required: false }) || "[]");
14+
core.debug(`Input: 'findings: ${JSON.stringify(findings)}'`);
15+
core.debug(`Input: 'repository: ${repoWithOwner}'`);
16+
core.debug(`Input: 'cached_findings: ${JSON.stringify(cachedFindings)}'`);
1317

1418
const findingsMap = toFindingsMap(findings);
1519
const cachedFindingsMap = toFindingsMap(cachedFindings);
1620

1721
const octokit = new Octokit({ auth: token });
18-
1922
const closedIssueUrls = [];
23+
const openedIssueUrls = [];
24+
const repeatIssueUrls = [];
25+
2026
for (const cachedFinding of cachedFindings) {
2127
if (!findingsMap.has(`${cachedFinding.url};${cachedFinding.problemShort};${cachedFinding.html}`)) {
22-
// Finding was not found in the latest run, so close its issue (if necessary)
23-
const response = await closeIssueForFinding(octokit, repoWithOwner, cachedFinding);
24-
closedIssueUrls.push(response.data.html_url);
25-
console.log(`Closed issue: ${response.data.title} (${repoWithOwner}#${response.data.number})`);
28+
try {
29+
// Finding was not found in the latest run, so close its issue (if necessary)
30+
const response = await closeIssueForFinding(octokit, repoWithOwner, cachedFinding);
31+
closedIssueUrls.push(response.data.html_url);
32+
core.info(`Closed issue: ${response.data.title} (${repoWithOwner}#${response.data.number})`);
33+
} catch (error) {
34+
core.error(`Failed to close issue for finding: ${error}`);
35+
}
2636
}
2737
}
2838

29-
const openedIssueUrls = [];
30-
const repeatIssueUrls = [];
3139
for (const finding of findings) {
3240
const cachedIssueUrl = cachedFindingsMap.get(`${finding.url};${finding.problemShort};${finding.html}`)?.issueUrl
3341
finding.issueUrl = cachedIssueUrl;
34-
const response = await openIssueForFinding(octokit, repoWithOwner, finding);
35-
finding.issueUrl = response.data.html_url;
36-
if (response.data.html_url === cachedIssueUrl) {
37-
// Finding was found in previous and latest runs, so reopen its issue (if necessary)
38-
repeatIssueUrls.push(response.data.html_url);
39-
console.log(`Repeated issue: ${response.data.title} (${repoWithOwner}#${response.data.number})`);
40-
} else {
41-
// New finding was found in the latest run, so create its issue
42-
openedIssueUrls.push(response.data.html_url);
43-
console.log(`Created issue: ${response.data.title} (${repoWithOwner}#${response.data.number})`);
42+
try {
43+
const response = await openIssueForFinding(octokit, repoWithOwner, finding);
44+
finding.issueUrl = response.data.html_url;
45+
if (response.data.html_url === cachedIssueUrl) {
46+
// Finding was found in previous and latest runs, so reopen its issue (if necessary)
47+
repeatIssueUrls.push(response.data.html_url);
48+
core.info(`Repeated issue: ${response.data.title} (${repoWithOwner}#${response.data.number})`);
49+
} else {
50+
// New finding was found in the latest run, so create its issue
51+
openedIssueUrls.push(response.data.html_url);
52+
core.info(`Created issue: ${response.data.title} (${repoWithOwner}#${response.data.number})`);
53+
}
54+
} catch (error) {
55+
core.error(`Failed to open/reopen issue for finding: ${error}`);
4456
}
4557
}
4658

4759
core.setOutput("closed_issue_urls", JSON.stringify(closedIssueUrls));
4860
core.setOutput("opened_issue_urls", JSON.stringify(openedIssueUrls));
4961
core.setOutput("repeated_issue_urls", JSON.stringify(repeatIssueUrls));
5062
core.setOutput("findings", JSON.stringify(findings));
63+
core.debug(`Output: 'closed_issue_urls: ${JSON.stringify(closedIssueUrls)}'`);
64+
core.debug(`Output: 'opened_issue_urls: ${JSON.stringify(openedIssueUrls)}'`);
65+
core.debug(`Output: 'repeated_issue_urls: ${JSON.stringify(repeatIssueUrls)}'`);
66+
core.debug(`Output: 'findings: ${JSON.stringify(findings)}'`);
67+
core.info("Finished 'file' action");
5168
}

.github/actions/find/src/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@ import core from "@actions/core";
22
import { findForUrl } from "./findForUrl.js";
33

44
export default async function () {
5+
core.info("Starting 'find' action");
56
const urls = core.getMultilineInput('urls', { required: true });
7+
core.debug(`Input: 'urls: ${JSON.stringify(urls)}'`);
68

79
let findings = [];
810
for (const url of urls) {
11+
core.info(`Scanning ${url}`)
912
const findingsForUrl = await findForUrl(url);
1013
if (findingsForUrl.length === 0) {
11-
console.log(`No accessibility gaps were found on ${url}`);
14+
core.info(`No accessibility gaps were found on ${url}`);
1215
continue;
1316
}
1417
findings.push(...findingsForUrl);
18+
core.info(`Found ${findingsForUrl.length} findings for ${url}`);
1519
}
1620

1721
core.setOutput("findings", JSON.stringify(findings));
22+
core.debug(`Output: 'findings: ${JSON.stringify(findings)}'`);
23+
core.info(`Found ${findings.length} findings in total`);
24+
core.info("Finished 'find' action");
1825
}

.github/actions/fix/src/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@ import { Octokit } from '@octokit/core';
33
import { fixIssue } from "./fixIssue.js";
44

55
export default async function () {
6+
core.info("Started 'fix' action");
67
const issueUrls = JSON.parse(core.getInput('issue_urls', { required: true }));
78
const repoWithOwner = core.getInput('repository', { required: true });
89
const token = core.getInput('token', { required: true });
10+
core.debug(`Input: 'issue_urls: ${JSON.stringify(issueUrls)}'`);
11+
core.debug(`Input: 'repository: ${repoWithOwner}'`);
912

1013
const octokit = new Octokit({ auth: token });
1114
for (const issueUrl of issueUrls) {
12-
await fixIssue(octokit, repoWithOwner, issueUrl);
13-
console.log(`Assigned ${repoWithOwner}#${issueUrl.split('/').pop()} to Copilot!`);
15+
try {
16+
await fixIssue(octokit, repoWithOwner, issueUrl);
17+
core.info(`Assigned ${repoWithOwner}#${issueUrl.split('/').pop()} to Copilot!`);
18+
} catch (error) {
19+
core.error(`Failed to assign ${repoWithOwner}#${issueUrl.split('/').pop()} to Copilot: ${error}`);
20+
}
1421
}
22+
core.info("Finished 'fix' action");
1523
}

0 commit comments

Comments
 (0)