Skip to content

Commit 98dc58b

Browse files
committed
use GCC output parser
1 parent 13225dd commit 98dc58b

3 files changed

Lines changed: 30 additions & 6 deletions

File tree

package-lock.json

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,12 @@
66
"build": "tsc"
77
},
88
"dependencies": {
9-
"@octokit/action": "^7.0.2"
9+
"@octokit/action": "^7.0.2",
10+
"gcc-output-parser": "^0.0.5"
1011
},
1112
"devDependencies": {
1213
"@octokit/tsconfig": "^4.0.0",
13-
"typescript": "^5.8.3",
14-
"@types/node": "^22.15.2"
14+
"@types/node": "^22.15.2",
15+
"typescript": "^5.8.3"
1516
}
16-
}
17+
}

src/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Octokit } from "@octokit/action";
22
import { readFileSync } from "fs";
33

4+
const parser = require("gcc-output-parser");
5+
46
// if the action is triggered by not a pull request, exit
57
if (!process.env.GITHUB_REF?.startsWith("refs/pull/")) {
68
console.log("Not a pull request, exiting.");
@@ -13,9 +15,21 @@ const [owner, repo] = process.env.GITHUB_REPOSITORY?.split("/")!;
1315
const pull_request_number = parseInt(process.env.GITHUB_REF?.split("/")[2]!);
1416
const compilation_output = readFileSync("compilation.log");
1517

18+
type OutputEntry = {
19+
filename: string;
20+
line: number;
21+
column: number;
22+
type: string;
23+
text: string;
24+
code: string;
25+
adjustedColumn: number;
26+
};
27+
28+
const outputs: OutputEntry[] = parser.parseString(compilation_output);
29+
1630
octokit.rest.issues.createComment({
1731
owner,
1832
repo,
1933
issue_number: pull_request_number,
20-
body: `compilation output is:\n\n\`\`\`\n${compilation_output}\n\`\`\``,
34+
body: `compilation output is:\n\n\`\`\`\n${outputs}\n\`\`\``,
2135
});

0 commit comments

Comments
 (0)