From 6387e972e31c3212f845d2ea94f53fc4c0f1a907 Mon Sep 17 00:00:00 2001 From: Markus Pesch Date: Mon, 14 Apr 2025 19:22:50 +0200 Subject: [PATCH] chore(ci): add golang tests --- .gitea/workflows/golang-tests.yml | 23 +++++++++++++++++++++++ Makefile | 16 +++++++++------- 2 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 .gitea/workflows/golang-tests.yml diff --git a/.gitea/workflows/golang-tests.yml b/.gitea/workflows/golang-tests.yml new file mode 100644 index 0000000..f45cd9b --- /dev/null +++ b/.gitea/workflows/golang-tests.yml @@ -0,0 +1,23 @@ +name: Golang Tests + +on: + pull_request: + types: [ "opened", "reopened", "synchronize" ] + push: + branches: + - '**' + tags-ignore: + - '**' + +jobs: + unittest: + runs-on: + - ubuntu-latest + steps: + - uses: actions/checkout@v4.2.2 + - uses: actions/setup-go@v5.4.0 + with: + go-version: stable + - env: + GOPROXY: ${{ vars.GOPROXY }} + run: make test/unit diff --git a/Makefile b/Makefile index 2e7946f..66500e4 100644 --- a/Makefile +++ b/Makefile @@ -26,11 +26,7 @@ DCMERGE_IMAGE_UNQUALIFIED=${DCMERGE_IMAGE_NAMESPACE}/${DCMERGE_IMAGE_NAME}:${DCM # ============================================================================== dcmerge: CGO_ENABLED=0 \ - GOPRIVATE=$(shell go env GOPRIVATE) \ GOPROXY=$(shell go env GOPROXY) \ - GONOPROXY=$(shell go env GONOPROXY) \ - GONOSUMDB=$(shell go env GONOSUMDB) \ - GOSUMDB=$(shell go env GOSUMDB) \ go build -ldflags "-X 'main.version=${VERSION}'" -o ${@} main.go # CLEAN @@ -43,15 +39,21 @@ clean: # ============================================================================== PHONY+=test/unit test/unit: - go test -v -p 1 -coverprofile=coverage.txt -covermode=count -timeout 1200s ./pkg/... + CGO_ENABLED=0 \ + GOPROXY=$(shell go env GOPROXY) \ + go test -v -p 1 -coverprofile=coverage.txt -covermode=count -timeout 1200s ./pkg/... PHONY+=test/integration test/integration: - go test -v -p 1 -count=1 -timeout 1200s ./it/... + CGO_ENABLED=0 \ + GOPROXY=$(shell go env GOPROXY) \ + go test -v -p 1 -count=1 -timeout 1200s ./it/... PHONY+=test/coverage test/coverage: test/unit - go tool cover -html=coverage.txt + CGO_ENABLED=0 \ + GOPROXY=$(shell go env GOPROXY) \ + go tool cover -html=coverage.txt # GOLANGCI-LINT # ==============================================================================