diff --git a/README.md b/README.md index 4f97e00..1e599aa 100644 --- a/README.md +++ b/README.md @@ -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`. @@ -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 diff --git a/action.yml b/action.yml index c62ab4f..53c9447 100644 --- a/action.yml +++ b/action.yml @@ -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` @@ -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: diff --git a/matchers.json b/matchers.json index ed07009..24be341 100644 --- a/matchers.json +++ b/matchers.json @@ -4,7 +4,7 @@ "owner": "go", "pattern": [ { - "regexp": "^\\s*(.+\\.go):(?:(\\d+):(?:(\\d+):)?)? (.*)", + "regexp": "^\\s*(.+\\.go):(?:(\\d+):(\\d+):)? (.*)", "file": 1, "line": 2, "column": 3, diff --git a/src/run b/src/run index 391a60e..d0b4b34 100755 --- a/src/run +++ b/src/run @@ -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" diff --git a/test-matchers.json b/test-matchers.json new file mode 100644 index 0000000..ed07009 --- /dev/null +++ b/test-matchers.json @@ -0,0 +1,16 @@ +{ + "problemMatcher": [ + { + "owner": "go", + "pattern": [ + { + "regexp": "^\\s*(.+\\.go):(?:(\\d+):(?:(\\d+):)?)? (.*)", + "file": 1, + "line": 2, + "column": 3, + "message": 4 + } + ] + } + ] +}