From 3352ae4da5dc65a3aef1269f25649527ded5eaea Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Fri, 14 Apr 2023 08:07:49 +0000 Subject: [PATCH] test: generate e2e coverage profile Signed-off-by: Billy Zha try remove shell indication --- .github/workflows/build.yml | 7 ++++++- .gitignore | 3 +++ Makefile | 13 +++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d721c4392..fa46b3ef4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -35,6 +35,11 @@ jobs: - name: Run unit tests run: make test - name: Run e2e tests - run: make e2e + run: | + if [[ $GITHUB_REF_NAME == v* && $GITHUB_REF_TYPE == tag ]]; then + make e2e + else + make e2e-covdata + fi - name: Upload coverage to codecov.io uses: codecov/codecov-action@v3 diff --git a/.gitignore b/.gitignore index bf8cc05c4..1be3287e6 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,7 @@ bin/ vendor/ coverage.txt +test/e2e/coverage.txt +**/covcounters.* +**/covmeta.* dist/ diff --git a/Makefile b/Makefile index 8cb73b83d..709d2f8ae 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ all: build FORCE: bin/%: cmd/% FORCE - go build $(GO_BUILD_FLAGS) -o $@ ./$< + go build $(GO_INSTRUMENT_FLAGS) $(GO_BUILD_FLAGS) -o $@ ./$< .PHONY: download download: ## download dependencies via go mod @@ -48,7 +48,16 @@ test: vendor check-line-endings ## run unit tests e2e: build ## build notation cli and run e2e test NOTATION_BIN_PATH=`pwd`/bin/$(COMMANDS); \ cd ./test/e2e; \ - ./run.sh zot $$NOTATION_BIN_PATH + ./run.sh zot $$NOTATION_BIN_PATH; \ + +.PHONY: e2e-covdata +e2e-covdata: + export GOCOVERDIR=$(CURDIR)/test/e2e/.cover; \ + rm -rf $$GOCOVERDIR; \ + mkdir -p $$GOCOVERDIR; \ + export GO_INSTRUMENT_FLAGS='-coverpkg "github.com/notaryproject/notation/internal/...,github.com/notaryproject/notation/pkg/...,github.com/notaryproject/notation/cmd/..."'; \ + $(MAKE) e2e; \ + go tool covdata textfmt -i=$$GOCOVERDIR -o "$(CURDIR)/test/e2e/coverage.txt" .PHONY: clean clean: