From d440e5916e7a30019836cb0f6ea9960814abbcc2 Mon Sep 17 00:00:00 2001 From: CrazyMax Date: Sun, 28 May 2023 15:10:21 +0200 Subject: [PATCH] chore: use same target for sandboxed and native tests Signed-off-by: CrazyMax --- .github/workflows/build.yml | 5 ++--- Dockerfile | 4 ++-- Makefile | 7 +++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 836ac98..f05e968 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -95,14 +95,13 @@ jobs: echo -e "trust\n5\ny" | gpg --batch --no-tty --command-fd 0 --edit-key 7D851EB72D73BDA0 pass init 7D851EB72D73BDA0 fi - go test -short -v -coverprofile=./coverage.txt -covermode=atomic ./... - go tool cover -func=./coverage.txt + make test COVERAGEDIR=${{ env.DESTDIR }} shell: bash - name: Upload coverage uses: codecov/codecov-action@v3 with: - file: ./coverage.txt + file: ${{ env.DESTDIR }}/coverage.txt test-sandboxed: runs-on: ubuntu-22.04 diff --git a/Dockerfile b/Dockerfile index c2d8b2f..bb65323 100644 --- a/Dockerfile +++ b/Dockerfile @@ -86,8 +86,8 @@ RUN --mount=type=bind,target=. \ gpg -k mkdir /out - xx-go test -short -v -coverprofile=/out/coverage.txt -covermode=atomic ./... - xx-go tool cover -func=/out/coverage.txt + xx-go --wrap + make test COVERAGEDIR=/out EOT FROM scratch AS test-coverage diff --git a/Makefile b/Makefile index ceb860f..59ec6cf 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ GO_LDFLAGS = -s -w -X ${GO_PKG}/credentials.Version=${VERSION} -X ${GO_PKG}/cred BUILDX_CMD ?= docker buildx DESTDIR ?= ./bin/build +COVERAGEDIR ?= ./bin/coverage .PHONY: all all: cross @@ -35,8 +36,10 @@ release: # create release ./hack/release .PHONY: test -test: # tests all packages except vendor - go test -v `go list ./... | grep -v /vendor/` +test: + mkdir -p $(COVERAGEDIR) + go test -short -v -coverprofile=$(COVERAGEDIR)/coverage.txt -covermode=atomic ./... + go tool cover -func=$(COVERAGEDIR)/coverage.txt .PHONY: lint lint: