Skip to content

Commit

Permalink
Merge pull request #28 from WillAbides/pmatcher-fix
Browse files Browse the repository at this point in the history
Only match test logs when annotate-test-logs is set
  • Loading branch information
WillAbides authored Sep 22, 2023
2 parents 8471dee + 9103a95 commit 3309824
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 8 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ The performance improvements are achieved by:
with, but if you use one of those formats you can shave an additional half
second off the time.

### Annotations for test failures

Setup-go-faster adds annotations for test failures so they show up in your
pull request. As of [email protected], setup-go only adds annotations for
build failures, not test failures.

### Install tip

Setup-go-faster will install go tip from source if you set `go-version: tip`.
Expand Down Expand Up @@ -123,6 +117,13 @@ action will always check for a newer version available for download. Set this to
to enable.


### annotate-test-logs

If set to any non-empty value, logs output by tests will be annotated as test failures on your Pull Request.
This is useful if the only logging your tests do is on error. If you use `t.Log` outside of test failures,
you should not set this.


## Outputs

### GOCACHE
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ inputs:
of checking whether a newer version is available for download. With ignore-local, the
action will always check for a newer version available for download. Set this to any non-empty value
to enable.
annotate-test-logs:
required: false
description: |
If set to any non-empty value, logs output by tests will be annotated as test failures on your Pull Request.
This is useful if the only logging your tests do is on error. If you use `t.Log` outside of test failures,
you should not set this.
outputs:
GOCACHE:
description: output of `go env GOCACHE`
Expand All @@ -79,6 +85,7 @@ runs:
IGNORE_LOCAL_GO: ${{ inputs.ignore-local }}
GO_VERSION: ${{ inputs.go-version }}
GO_VERSION_FILE: ${{ inputs.go-version-file }}
ANNOTATE_TEST_LOGS: ${{ inputs.annotate-test-logs }}
shell: bash
run: src/run
branding:
Expand Down
2 changes: 1 addition & 1 deletion matchers.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"owner": "go",
"pattern": [
{
"regexp": "^\\s*(.+\\.go):(?:(\\d+):(?:(\\d+):)?)? (.*)",
"regexp": "^\\s*(.+\\.go):(?:(\\d+):(\\d+):)? (.*)",
"file": 1,
"line": 2,
"column": 3,
Expand Down
7 changes: 6 additions & 1 deletion src/run
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ if [ -z "$lv" ]; then
exit 1
fi

[ -n "$SKIP_MATCHER" ] || echo "::add-matcher::$GITHUB_ACTION_PATH/matchers.json"
matchers="$GITHUB_ACTION_PATH/matchers.json"
if [ -n "$ANNOTATE_TEST_LOGS" ]; then
matchers="$GITHUB_ACTION_PATH/test-matchers.json"
fi

[ -n "$SKIP_MATCHER" ] || echo "::add-matcher::$matchers"

src/install-go "$lv" "$target_dir" "$install_parent/tip/x64"
16 changes: 16 additions & 0 deletions test-matchers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"problemMatcher": [
{
"owner": "go",
"pattern": [
{
"regexp": "^\\s*(.+\\.go):(?:(\\d+):(?:(\\d+):)?)? (.*)",
"file": 1,
"line": 2,
"column": 3,
"message": 4
}
]
}
]
}

0 comments on commit 3309824

Please sign in to comment.