Skip to content

Commit c418c92

Browse files
committed
fix(cli): resolve package-relative paths and pipe exit codes
Selene and moonwave run per-package via lerna, producing paths like src/Shared/Foo.lua instead of src/acceltween/src/Shared/Foo.lua. Parsers now extract the package name from the lerna prefix to build repo-root-relative paths. Also fixes PIPESTATUS capture so linter jobs actually fail on errors.
1 parent a4fc07e commit c418c92

File tree

6 files changed

+45
-32
lines changed

6 files changed

+45
-32
lines changed

.github/workflows/linting.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
run: |
4848
set +e
4949
npm run lint:luau 2>&1 | tee lint-output.txt
50-
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
50+
echo "exit_code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
5151
exit 0
5252
continue-on-error: true
5353

@@ -77,7 +77,7 @@ jobs:
7777
run: |
7878
set +e
7979
npm run lint:stylua 2>&1 | tee lint-output.txt
80-
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
80+
echo "exit_code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
8181
exit 0
8282
continue-on-error: true
8383

@@ -111,7 +111,7 @@ jobs:
111111
run: |
112112
set +e
113113
npm run lint:selene 2>&1 | tee lint-output.txt
114-
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
114+
echo "exit_code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
115115
exit 0
116116
continue-on-error: true
117117

@@ -145,7 +145,7 @@ jobs:
145145
run: |
146146
set +e
147147
npm run lint:moonwave 2>&1 | tee lint-output.txt
148-
echo "exit_code=$?" >> "$GITHUB_OUTPUT"
148+
echo "exit_code=${PIPESTATUS[0]}" >> "$GITHUB_OUTPUT"
149149
exit 0
150150
continue-on-error: true
151151

docs/conventions/git-workflow.md

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,9 @@ PR descriptions are for reviewers and future readers browsing git history. They
5858
**Good** — says what changed from the user's perspective:
5959

6060
```
61-
Test and deploy results now appear on the GitHub Actions run summary
62-
page in addition to PR comments.
61+
Test and deploy results now appear on the GitHub Actions run summary page in addition to PR comments.
6362
64-
Also reorganizes the GitHub reporter code into `reporting/github/`
65-
with shared formatting and a separate API module.
66-
```
67-
68-
**Bad** — restates the diff:
69-
70-
```
71-
- Add `GithubJobSummaryReporter` that writes batch test/deploy results
72-
to `$GITHUB_STEP_SUMMARY`
73-
- Refactor GitHub reporter code into a `reporting/github/` subfolder
74-
with shared formatting extracted into `formatting.ts`
75-
- Wire up the new reporter in `batch test`, `batch deploy`, and
76-
`post-test-results` commands
63+
Also reorganizes the GitHub reporter code into `reporting/github/` with shared formatting and a separate API module.
7764
```
7865

7966
Keep descriptions to 1-3 sentences of plain prose. No markdown headers, checklists, or "generated by" badges. If a PR needs a long explanation, that's usually a sign it should be split up.

tools/nevermore-cli/src/utils/linting/parsers/moonwave-parser.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe('parseMoonwaveOutput', () => {
5353
const result = parseMoonwaveOutput(input);
5454

5555
expect(result).toHaveLength(1);
56-
expect(result[0].file).toBe('src/foo.lua');
56+
expect(result[0].file).toBe('src/acceltween/src/foo.lua');
5757
});
5858

5959
it('skips the aborting summary line', () => {

tools/nevermore-cli/src/utils/linting/parsers/moonwave-parser.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,12 @@ function _stripAnsi(text: string): string {
3131
/**
3232
* Matches the severity header line.
3333
* Optional lerna prefix.
34-
* Group 1: severity (error, warning)
35-
* Group 2: message
34+
* Group 1: lerna package name (e.g. "acceltween") or undefined
35+
* Group 2: severity (error, warning)
36+
* Group 3: message
3637
*/
3738
const SEVERITY_PATTERN =
38-
/^(?:@[\w-]+\/[\w-]+:\s+)?\s*(error|warning):\s*(.+)$/;
39+
/^(?:@[\w-]+\/([\w-]+):\s+)?\s*(error|warning):\s*(.+)$/;
3940

4041
/**
4142
* Matches the location line with the `┌─` marker.
@@ -47,9 +48,19 @@ const SEVERITY_PATTERN =
4748
const LOCATION_PATTERN =
4849
/^(?:@[\w-]+\/[\w-]+:\s+)?\s+ (.+?):(\d+):(\d+)/;
4950

51+
/** Resolve a package-relative path to a repo-root-relative path. */
52+
function _resolvePackagePath(
53+
packageName: string | undefined,
54+
filePath: string
55+
): string {
56+
if (!packageName) return filePath;
57+
return `src/${packageName}/${filePath}`;
58+
}
59+
5060
interface PendingDiagnostic {
5161
severity: DiagnosticSeverity;
5262
message: string;
63+
packageName: string | undefined;
5364
}
5465

5566
export function parseMoonwaveOutput(raw: string): Diagnostic[] {
@@ -66,10 +77,11 @@ export function parseMoonwaveOutput(raw: string): Diagnostic[] {
6677
// Try to match a severity header
6778
const sevMatch = line.match(SEVERITY_PATTERN);
6879
if (sevMatch) {
69-
const [, severity, message] = sevMatch;
80+
const [, packageName, severity, message] = sevMatch;
7081
pending = {
7182
severity: severity as DiagnosticSeverity,
7283
message: message.trim(),
84+
packageName,
7385
};
7486
continue;
7587
}
@@ -78,7 +90,8 @@ export function parseMoonwaveOutput(raw: string): Diagnostic[] {
7890
if (pending) {
7991
const locMatch = line.match(LOCATION_PATTERN);
8092
if (locMatch) {
81-
const [, file, lineStr, colStr] = locMatch;
93+
const [, rawFile, lineStr, colStr] = locMatch;
94+
const file = _resolvePackagePath(pending.packageName, rawFile);
8295
diagnostics.push({
8396
file,
8497
line: parseInt(lineStr, 10),

tools/nevermore-cli/src/utils/linting/parsers/selene-parser.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('parseSeleneOutput', () => {
5252
const result = parseSeleneOutput(input);
5353

5454
expect(result).toHaveLength(1);
55-
expect(result[0].file).toBe('src/foo.lua');
55+
expect(result[0].file).toBe('src/acceltween/src/foo.lua');
5656
expect(result[0].severity).toBe('warning');
5757
});
5858

tools/nevermore-cli/src/utils/linting/parsers/selene-parser.ts

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ import { type Diagnostic, type DiagnosticSeverity } from '@quenty/cli-output-hel
2525
/**
2626
* Matches the severity header line.
2727
* Optional lerna prefix: `@scope/pkg: `
28-
* Group 1: severity (error, warning)
29-
* Group 2: rule name
30-
* Group 3: message
28+
* Group 1: lerna package name (e.g. "acceltween") or undefined
29+
* Group 2: severity (error, warning)
30+
* Group 3: rule name
31+
* Group 4: message
3132
*/
3233
const SEVERITY_PATTERN =
33-
/^(?:@[\w-]+\/[\w-]+:\s+)?(error|warning)\[(\w+)\]: (.+)$/;
34+
/^(?:@[\w-]+\/([\w-]+):\s+)?(error|warning)\[(\w+)\]: (.+)$/;
3435

3536
/**
3637
* Matches the location line with the `┌─` marker.
@@ -42,10 +43,20 @@ const SEVERITY_PATTERN =
4243
const LOCATION_PATTERN =
4344
/^(?:@[\w-]+\/[\w-]+:\s+)?\s+ (.+?):(\d+):(\d+)/;
4445

46+
/** Resolve a package-relative path to a repo-root-relative path. */
47+
function _resolvePackagePath(
48+
packageName: string | undefined,
49+
filePath: string
50+
): string {
51+
if (!packageName) return filePath;
52+
return `src/${packageName}/${filePath}`;
53+
}
54+
4555
interface PendingDiagnostic {
4656
severity: DiagnosticSeverity;
4757
rule: string;
4858
message: string;
59+
packageName: string | undefined;
4960
}
5061

5162
export function parseSeleneOutput(raw: string): Diagnostic[] {
@@ -57,11 +68,12 @@ export function parseSeleneOutput(raw: string): Diagnostic[] {
5768
// Try to match a severity header
5869
const sevMatch = line.match(SEVERITY_PATTERN);
5970
if (sevMatch) {
60-
const [, severity, rule, message] = sevMatch;
71+
const [, packageName, severity, rule, message] = sevMatch;
6172
pending = {
6273
severity: severity as DiagnosticSeverity,
6374
rule,
6475
message,
76+
packageName,
6577
};
6678
continue;
6779
}
@@ -70,7 +82,8 @@ export function parseSeleneOutput(raw: string): Diagnostic[] {
7082
if (pending) {
7183
const locMatch = line.match(LOCATION_PATTERN);
7284
if (locMatch) {
73-
const [, file, lineStr, colStr] = locMatch;
85+
const [, rawFile, lineStr, colStr] = locMatch;
86+
const file = _resolvePackagePath(pending.packageName, rawFile);
7487
diagnostics.push({
7588
file,
7689
line: parseInt(lineStr, 10),

0 commit comments

Comments
 (0)