From 6bd87900de6a723ee8586f68c329e579d329d17d Mon Sep 17 00:00:00 2001 From: Abin Simon Date: Wed, 1 Jun 2022 13:27:54 +0530 Subject: [PATCH] Add coverage reporting to go workflow --- .github/workflows/go.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 6d0818c..20b2a13 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -29,7 +29,22 @@ jobs: uses: helm/kind-action@v1.2.0 - name: Test all - run: go test -v ./... + run: go test -coverprofile=coverage.out -v ./... + + - name: Prepare coverage report + run: | + go install github.com/axw/gocov/gocov@latest + gocov convert coverage.out> coverage.json + echo "Coverage report (go)" > coverage.report + echo "" >> coverage.report + echo "|File|Percentage|Lines|" >> coverage.report + echo "|---|:---:|:---:|" >> coverage.report + gocov report coverage.json|grep -E '\-\-\-'|sed 's/---*//'|awk '{print "|"$1"|"$2"|"$3"|"}' >> coverage.report + + - name: Comment coverage report + uses: marocchino/sticky-pull-request-comment@v2 + with: + path: coverage.report # golangci: # strategy: