From 3482c952e9553c2faa24b8b02762a939966ece10 Mon Sep 17 00:00:00 2001
From: Markus Pesch <markus.pesch@cryptic.systems>
Date: Mon, 14 Apr 2025 19:22:50 +0200
Subject: [PATCH] chore(ci): add golang tests

---
 .gitea/workflows/golang-tests.yml | 24 ++++++++++++++++++++++++
 Makefile                          | 18 ++++++++++++------
 2 files changed, 36 insertions(+), 6 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..56f4a7b
--- /dev/null
+++ b/.gitea/workflows/golang-tests.yml
@@ -0,0 +1,24 @@
+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:
+        GONOSUMDB: ${{ vars.GONOSUMDB }}
+        GOPROXY: ${{ vars.GOPROXY }}
+      run: make test/unit
diff --git a/Makefile b/Makefile
index 2e7946f..fd6ddca 100644
--- a/Makefile
+++ b/Makefile
@@ -26,11 +26,8 @@ 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 +40,24 @@ 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) \
+	GONOSUMDB=$(shell go env GONOSUMDB) \
+		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) \
+	GONOSUMDB=$(shell go env GONOSUMDB) \
+		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) \
+	GONOSUMDB=$(shell go env GONOSUMDB) \
+		go tool cover -html=coverage.txt
 
 # GOLANGCI-LINT
 # ==============================================================================