diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46524b5a89..25d560f9b6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: - name: Docker Compose run: docker compose up -d --wait - name: Test - run: go test ./... + run: go-test-annotate sql: name: SQL runs-on: ubuntu-latest diff --git a/bin/.gotestsum-1.11.0.pkg b/bin/.gotestsum-1.11.0.pkg new file mode 120000 index 0000000000..383f4511d4 --- /dev/null +++ b/bin/.gotestsum-1.11.0.pkg @@ -0,0 +1 @@ +hermit \ No newline at end of file diff --git a/bin/gotestsum b/bin/gotestsum new file mode 120000 index 0000000000..1471d7ff99 --- /dev/null +++ b/bin/gotestsum @@ -0,0 +1 @@ +.gotestsum-1.11.0.pkg \ No newline at end of file diff --git a/buildengine/engine_test.go b/buildengine/engine_test.go index 0a0e13b45f..82276cb1b8 100644 --- a/buildengine/engine_test.go +++ b/buildengine/engine_test.go @@ -46,7 +46,7 @@ func TestEngine(t *testing.T) { expected := map[string][]string{ "alpha": {"another", "other", "builtin"}, "another": {"builtin"}, - "other": {}, + "other": {"alpha"}, "builtin": {}, } graph, err := engine.Graph() diff --git a/scripts/go-test-annotate b/scripts/go-test-annotate new file mode 100755 index 0000000000..42dc65c349 --- /dev/null +++ b/scripts/go-test-annotate @@ -0,0 +1,18 @@ +#!/bin/bash +set -exuo pipefail + +fail=0 +if ! gotestsum --format-hide-empty-pkg --junitfile junit-go.xml --junitfile-hide-empty-pkg -- -fullpath ./...; then + fail=1 +fi + +dir="$(pwd)" +yq -oj '.. | select(has("failure")) | .failure["+content"]' junit-go.xml | while read -r failure; do + line="$(echo "$failure" | jq -r | grep -E "$dir/.*\.go:[0-9]+" | sed -e "s,^[ ]*$dir/,,")" + file_path=$(echo "$line" | cut -d':' -f1) + line_number=$(echo "$line" | cut -d':' -f2) + # Output the warning message in the format expected by GitHub Actions + echo "::error file=$file_path,line=$line_number::$(echo "$failure" | jq -sRr @uri)" +done + +exit "$fail" \ No newline at end of file