From 371c189226c3bca53b611feaacac0ae0baf9ff7a Mon Sep 17 00:00:00 2001 From: root Date: Wed, 30 Sep 2026 15:20:42 +0000 Subject: [PATCH] chore: add Makefile and Drone pipeline Build, test, run, install and clean targets, with the version injected at link time. CI runs make check, build and test. --- .drone.yml | 26 ++++++++++++++++++++++++++ .gitignore | 1 + Makefile | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) create mode 100644 .drone.yml create mode 100644 Makefile diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..a47d6d4 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,26 @@ +--- +kind: pipeline +name: coopcloud.tech/cctuip +steps: + - name: make check + image: golang:1.20 + commands: + - make check + + - name: make build + image: golang:1.20 + commands: + - make build + depends_on: + - make check + + - name: make test + image: golang:1.20 + commands: + - make test + depends_on: + - make check + +volumes: + - name: deps + temp: {} \ No newline at end of file diff --git a/.gitignore b/.gitignore index e4ace77..f119a56 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ cctuip +cctuip-dev *.exe diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..063ef66 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev) +GOPATH := $(shell go env GOPATH) +LDFLAGS := "-X 'main.version=$(VERSION)'" +DIST_LDFLAGS := $(LDFLAGS)" -s -w" + +export GOPRIVATE=coopcloud.tech + +all: format check build test + +run: + @go run -ldflags=$(LDFLAGS) . + +install: + @go install -ldflags=$(LDFLAGS) . + +build-dev: + @go build -v -ldflags=$(LDFLAGS) -o cctuip-dev . + +build: + @go build -v -ldflags=$(DIST_LDFLAGS) -o cctuip . + +clean: + @rm -f cctuip cctuip-dev + @rm -f '$(GOPATH)/bin/cctuip' + +format: + @gofmt -s -w . + +check: + @test -z $$(gofmt -s -l .) || \ + (echo "gofmt: formatting issue - run 'make format' to resolve" && exit 1) + @go vet ./... + +test: + @go test ./... -cover -v + +loc: + @find . -name "*.go" | xargs wc -l \ No newline at end of file