Skip to content

Commit

Permalink
Add highlighting to error messages (#331)
Browse files Browse the repository at this point in the history
This is done by using the `::error::{message}` [workflow command
syntax][1].

Fixes #330

[1]: https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message
  • Loading branch information
johnboyes committed Feb 11, 2023
1 parent 318a78c commit 70dd583
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/github/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (a *Action) CheckLabels(stdout, stderr io.Writer) int {
func (a *Action) handleFailure() int {
a.outputResult("failure")
err := errors.New(a.trimTrailingNewLine(a.failMsg))
fmt.Fprintln(a.Stderr, "Error:", err)
fmt.Fprintln(a.Stderr, "::error::", err)
if a.allowFailure() {
return 0
}
Expand Down
2 changes: 1 addition & 1 deletion internal/github/action_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func TestLabelChecks(t *testing.T) {
t.Run(name, func(t *testing.T) {
tc.expectedStdout = "Checking GitHub labels ...\n" + tc.expectedStdout
if len(tc.expectedStderr) > 0 {
tc.expectedStderr = "Error: " + tc.expectedStderr
tc.expectedStderr = "::error:: " + tc.expectedStderr
}
setPullRequestNumber(tc.prNumber)
tc.specifyChecks()
Expand Down

0 comments on commit 70dd583

Please sign in to comment.