From 2dcdbcd32b2bdd105443c84022a75105da059e5f Mon Sep 17 00:00:00 2001 From: naveen <172697+naveensrinivasan@users.noreply.github.com> Date: Wed, 19 Jan 2022 21:52:45 +0000 Subject: [PATCH] :seedling: Track code coverage Track code coverage https://github.com/ossf/scorecard/issues/986 Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com> --- .github/workflows/main.yml | 5 +++++ .gitignore | 2 ++ Makefile | 7 ++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index db785deb..2206082c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -39,6 +39,11 @@ jobs: run: | go env -w GOFLAGS=-mod=mod make -j 5 all + - name: Upload codecoverage + uses: codecov/codecov-action@f32b3a3741e1053eb607407145bc9619351dc93b # 2.1.0 + with: + files: ./unit-coverage.out + verbose: true license-check: name: license boilerplate check runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 4a4abae7..384d0cfa 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,8 @@ results.json # Output of the go coverage tool, specifically when used with LiteIDE. *.coverprofile* +unit-coverage.out +e2e-coverage.out # IDE directories. diff --git a/Makefile b/Makefile index 8554eedf..e22c0974 100644 --- a/Makefile +++ b/Makefile @@ -267,12 +267,13 @@ test: $(test-targets) unit-test: ## Runs unit test without e2e # Run unit tests, ignoring e2e tests - go test -race -covermode atomic `go list ./... | grep -v e2e` + # run the go tests and gen the file coverage-all used to do the integration with codecov + go test -race -covermode=atomic -coverprofile=unit-coverage.out `go list ./... | grep -v e2e` e2e: ## Runs e2e tests. Requires GITHUB_AUTH_TOKEN env var to be set to GitHub personal access token e2e: build-scorecard check-env | $(GINKGO) # Run e2e tests. GITHUB_AUTH_TOKEN with personal access token must be exported to run this - $(GINKGO) --race --skip="E2E TEST:executable" -p -v -cover ./... + $(GINKGO) --race --skip="E2E TEST:executable" -p -v -cover -coverprofile=filename ./... $(GINKGO): install @@ -281,7 +282,7 @@ ci-e2e: build-scorecard check-env | $(GINKGO) # Run CI e2e tests. GITHUB_AUTH_TOKEN with personal access token must be exported to run this $(call ndef, GITHUB_AUTH_TOKEN) @echo Ignoring these test for ci-e2e $(IGNORED_CI_TEST) - $(GINKGO) -p -v -cover --skip=$(IGNORED_CI_TEST) ./e2e/... + $(GINKGO) -p -v -cover --skip=$(IGNORED_CI_TEST) -coverprofile=e2e-coverage.out ./e2e/... check-env: