From 059e08c9600b54f5cc853779c22e4f29a074bd31 Mon Sep 17 00:00:00 2001 From: Alberto Ricart Date: Sat, 4 Jan 2025 10:20:52 -0600 Subject: [PATCH] fix misleading coverage Signed-off-by: Alberto Ricart --- .github/workflows/pushes.yaml | 59 ++++++++--------------------------- Makefile | 3 +- 2 files changed, 15 insertions(+), 47 deletions(-) diff --git a/.github/workflows/pushes.yaml b/.github/workflows/pushes.yaml index 1057a438..e45cd5b6 100644 --- a/.github/workflows/pushes.yaml +++ b/.github/workflows/pushes.yaml @@ -60,26 +60,10 @@ jobs: go-version: ${{ matrix.go }} # We're not doing releases, just checks, so we can live without check-latest here - - name: Export Go environment to Actions outputs - id: go-settings - run: | - echo "::set-output name=arch::$(go env GOARCH)" - echo "::set-output name=hostarch::$(go env GOHOSTARCH)" - echo "::set-output name=os::$(go env GOOS)" - echo "::set-output name=hostos::$(go env GOHOSTOS)" - echo "::set-output name=go-version::$(go env GOVERSION)" - # Use with: - # ${{ steps.go-settings.outputs.go-version }} - # which will look like `go1.17.1` if matrix `1.17.x` matches `1.17.1`. - # These are independent of how the matrix is setup, or if a matrix is even used. - # - # You can see the individual values in the "Set up Go" output, collapsed inside a "go env" group at the end. - name: Install additional check/lint tools id: tools-install run: | - go install github.com/mattn/goveralls@latest - go install github.com/wadey/gocovmerge@latest go install honnef.co/go/tools/cmd/staticcheck@2021.1.2 if: matrix.canonical @@ -92,38 +76,21 @@ jobs: - name: Run Tests (with coverage enabled) id: coverage run: | - mkdir cov - echo "::group::Coverage of ./cmd" - go test -v -failfast -covermode=atomic -coverprofile=./cov/cmd.out ./cmd - echo "::endgroup::" - echo "::group::Coverage of ./cmd/store" - go test -v -failfast -covermode=atomic -coverprofile=./cov/store.out ./cmd/store - echo "::endgroup::" - if: runner.os != 'Windows' + go test -v -failfast -coverpkg=./... -coverprofile=./coverage.out ./... +# if: runner.os != 'Windows' - - name: Run Tests (Windows) - id: wintest - # nb2: if we use the coverage approach on Windows, the -coverprofile flag appears to be looked for as a package, and I've no idea why (am not a Windows dev) - # cannot find package "github.com/nats-io/nsc/cov/cmd.out" in any of: - # C:\hostedtoolcache\windows\go\1.16.13\x64\src\github.com\nats-io\nsc\cov\cmd.out (from $GOROOT) - # D:\a\nsc\nsc\go\src\github.com\nats-io\nsc\cov\cmd.out (from $GOPATH) - run: | - echo "::group::Testing of ./cmd" - go test -v -failfast ./cmd - echo "::endgroup::" - echo "::group::Testing of ./cmd/store" - go test -v -failfast ./cmd/store - echo "::endgroup::" - if: runner.os == 'Windows' +# - name: Run Tests (windows) +# run: | +# go test -v -failfast ./... +# if: runner.os == 'Windows' - - name: Upload coverage results - id: coverage-upload - run: | - gocovmerge ./cov/*.out > coverage.out - goveralls -coverprofile=coverage.out -service=github - env: - COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: matrix.canonical + - name: Upload coverage + uses: coverallsapp/github-action@v2 + continue-on-error: true + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + flag-name: ${{ matrix.module }} + file: ./coverage.out - name: Bad versions creep defense id: go-module-versions diff --git a/Makefile b/Makefile index 9fbfe7f8..a3724e38 100644 --- a/Makefile +++ b/Makefile @@ -37,7 +37,8 @@ test: go vet ./... rm -rf ./coverage.out staticcheck -f text ./... - unset $$(env | sed -nEe 's/^(NSC_[^=]*_OPERATOR)=.*/\1/p'); go test -coverpkg=./... -coverprofile=./coverage.out ./... + #unset $$(env | sed -nEe 's/^(NSC_[^=]*_OPERATOR)=.*/\1/p'); go test -coverpkg=./... -coverprofile=./coverage.out ./... + unset $$(env | sed -nEe 's/^(NSC_[^=]*_OPERATOR)=.*/\1/p'); go test -coverpkg=$(go list ./...) -covermode=atomic -coverprofile=./coverage.out ./... staticcheck ./... release: fmt test compile