diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index f140a23..0000000 --- a/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM golang:1.22 AS build - -ENV CGO_ENABLED=1 -ENV GOPROXY=https://proxy.golang.org\|https://artifactory.zgtools.net/artifactory/api/go/devex-go\|direct -ENV GONOSUMDB=*gitlab.zgtools.net* - -WORKDIR /go/src/zkafka -COPY . . - -RUN go mod download -RUN go build -o zkafka - -FROM debian -COPY --from=build /go/src/zkafka / -ENTRYPOINT ["/zkafka"] - diff --git a/Makefile b/Makefile index 20577ca..76e8511 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,7 @@ test-local: setup-test test-no-setup .PHONY: cover cover: - go test -v ./... -count=1 -coverprofile=cover.out -covermode atomic && \ - go tool cover -html=cover.out -o cover.html + ./coverage.sh .PHONY: example-producer example-producer: diff --git a/coverage.sh b/coverage.sh index 0934cac..bf35a51 100755 --- a/coverage.sh +++ b/coverage.sh @@ -22,11 +22,11 @@ function quit() { } # change to example directory for execution (because it uses hardcoded filepaths, and the testable # examples don't work when executed outside of that directory -go test -c -coverpkg=$pck1 -covermode=atomic -o "$root_res" -tags integration $pck1 +go test -c -coverpkg=$pck1 -covermode=atomic -o "$root_res" $pck1 # convert binary to go formatted go tool test2json -t "$root_res" -test.v -test.coverprofile "$root_out" -go test -c -coverpkg=$pck1 -covermode=atomic -o "$source_res" -tags integration $pck2 +go test -c -coverpkg=$pck1 -covermode=atomic -o "$source_res" $pck2 go tool test2json -t "$source_res" -test.v -test.coverprofile "$source_out" # delete aggregate file @@ -38,15 +38,4 @@ tail -n+2 "$source_out" >> "$omni_out" # print aggregated results go tool cover -func="$omni_out" - -# we need to create a cobertura.xml file (this is used for code coverage visualization) -# download the tool to convert gocover into covertura -go install github.com/boumenot/gocover-cobertura@latest -gocover-cobertura < $omni_out > coverage.tmp.xml -# the cobertura generated file has two issues. Its source array doesn't include the curdir and -# the class node filepaths aren't relative to the root. -# We'll run two commands -# 1. Remove the prefixed go.mod package name from filenames inside of the cobertura with a brute force replace with empty string -# 2. Add the workingdirectory to the sources array using a find replace (search for sources node, and replace with sources node but new workdir source nod) -pkg=gitlab.zgtools.net/devex/archetypes/gomods/zkafka -sed "s|$pkg/||" coverage.tmp.xml | sed "s||\n$(pwd)|"> coverage.xml \ No newline at end of file +go tool cover -html="$omni_out" -o cover.html