Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only match test logs when annotate-test-logs is set #28

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 setup-go@v4.1.0, 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
}
]
}
]
}