fix: anchor GitHub annotation path to GITHUB_WORKSPACE#60
Open
exo-mv wants to merge 2 commits into
Open
Conversation
The reporter emits `::error file=,line=,col=::` workflow commands so test failures show as inline annotations on the PR diff. GitHub resolves the `file=` path from the repo root (GITHUB_WORKSPACE), but the reporter computed it with `relative(cwd, ...)`. Under lerna/nx the cwd is the package dir, so the path came out package-relative (e.g. `file=bar.test.js`) and never mapped onto the diff — no annotation appeared. Anchor the path to GITHUB_WORKSPACE in CI so it is repo-root-relative (`packages/foo/bar.test.js`); local runs stay cwd-relative. The logic lives in a new node:path-only `bin/github.js`, so the unit test can import it without dragging in the node:test reporter internals (which don't bundle for the barebone engines). Adds unit coverage for the CI and non-CI cases. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Co-Authored-By: Claude <noreply@anthropic.com>
aa698a4 to
d8cef00
Compare
resolveAnnotationFile ran the path through node:path relative()/resolve(), which produce backslash separators on Windows runners. GitHub matches `::error file=` annotation paths with forward slashes, so on Windows the annotation never landed on the repo file (and reporter.js's stack-line matcher, which assumes `/`, also missed). Normalize the result to POSIX separators so the annotation maps onto the PR diff on every platform. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
::error file=,line=,col=::path was computed withrelative(cwd, …); since lerna/nx run each package with cwd = the package dir, the path came out package-relative (bar.test.js) and GitHub — which resolves annotation paths from the repo root — never mapped it onto the diff.GITHUB_WORKSPACEso it's repo-root-relative (packages/foo/bar.test.js). Non-CI runs stay cwd-relative. Logic extracted intoresolveAnnotationFile.Test plan
tests/reporter.test.jscovers CI and non-CI cases.node --testpass.deno failure is pre-existing on master