Skip to content

Commit 8f26629

Browse files
committed
Fix step links to point to first warning/error line instead of line 1
The generated GitHub Actions step links always used #step:N:1, pointing to the first line of the step. Now the link points to the line where the first warning (or error) actually occurred in the compilation output. https://claude.ai/code/session_01Eph17CQCfdnKaJhA2nSr9W
1 parent 2aca677 commit 8f26629

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/index.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,16 @@ for (const file of readdirRecursively(".")) {
6969
const compilationOutput = readFileSync(file).toString();
7070

7171
let compileResult = "✅success";
72+
let firstIssueLine = 1;
73+
const lines = compilationOutput.split("\n");
7274
if (compilationOutput.match(/warning( .\d+)?:/)) {
7375
compileResult = "⚠️warning";
76+
const idx = lines.findIndex((line) => line.match(/warning( .\d+)?:/));
77+
if (idx !== -1) firstIssueLine = idx + 1;
7478
} else if (compilationOutput.match(/error( .\d+)?:/)) {
7579
compileResult = "❌error";
80+
const idx = lines.findIndex((line) => line.match(/error( .\d+)?:/));
81+
if (idx !== -1) firstIssueLine = idx + 1;
7682
}
7783

7884
const { data: job } = await octokit.rest.actions.getJobForWorkflowRun({
@@ -102,7 +108,7 @@ for (const file of readdirRecursively(".")) {
102108
}
103109

104110
rows.push({
105-
url: `https://github.com/${owner}/${repo}/actions/runs/${runId}/job/${jobId}#step:${stepId}:1`,
111+
url: `https://github.com/${owner}/${repo}/actions/runs/${runId}/job/${jobId}#step:${stepId}:${firstIssueLine}`,
106112
status: compileResult,
107113
...jobMatch.groups,
108114
});

0 commit comments

Comments
 (0)