Repository navigation
Conversation
The annotation link that GitHub generates opens the commit view, which only shows files changed in that commit. Append a link to the spec file at the failing line in the tested revision to the annotation message. For pull_request events the pull request head commit is used instead of the temporary merge commit. Refs #92
There was a problem hiding this comment.
🟡 Changes recommended
Spec notification links break for paths containing # and can target the PR head instead of the tested merge commit, opening the wrong revision or line.
2 open issues
What changed in this PR
Adds direct spec-file links to annotation messages, addressing #92 by letting users navigate to files omitted from GitHub’s commit view.
Changes:
- Builds file-and-line URLs from GitHub Actions environment variables, preferring the PR head SHA when available.
- Adds URL assertions and isolates GitHub environment variables in formatter specs.
- Documents the new links and the limitation of annotation navigation.
| File | Description |
|---|---|
spec/rspec/github/formatter_spec.rb |
Tests annotation URLs and isolates GitHub environment variables. |
README.md |
Explains direct spec links and commit-view limitations. |
lib/rspec/github/notification_decorator.rb |
Builds revision-specific URLs and appends them to annotations. |
Review effort: Balanced
Percent-encode each path segment so characters like # or spaces don't break the link, and always use GITHUB_SHA so the link points at the commit that was actually tested (the merge commit on pull_request events), keeping line numbers in sync with the annotation.
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.

Refs #92
GitHub builds the annotation link itself from the
fileandlineparameters and opens the commit view. That view only shows files changed in that commit, so a failing spec in a file the commit didn't touch can't be seen there. Workflow commands have no parameter for setting the URL.This PR appends a link to the spec file at the failing line in the tested commit to the annotation message:
GITHUB_SERVER_URL,GITHUB_REPOSITORYandGITHUB_SHA, and is left out when those aren't set (e.g. local runs).GITHUB_SHAis the commit that was tested (the merge commit onpull_requestevents), so the linked line matches the annotation's line.#or spaces don't break the link.Still to verify: whether GitHub makes URLs inside annotation messages clickable. Check the annotations of this PR's own failing integration spec in the CI run.