From 980f2f7684220577a588490fd6dc4dbeaf3d4136 Mon Sep 17 00:00:00 2001 From: decentral1se Date: Thu, 15 Jul 2021 23:00:33 +0200 Subject: [PATCH] Add format and check targets + integrate into CI --- .drone.yml | 6 ++++++ Makefile | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 930334bb..6a1229f6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,6 +2,11 @@ kind: pipeline name: coopcloud.tech/abra steps: + - name: make check + image: golang:1.16 + commands: + - make check + - name: make build image: golang:1.16 commands: @@ -16,6 +21,7 @@ steps: accesstoken: from_secret: autono_bot_access_token depends_on: + - make check - make build when: status: diff --git a/Makefile b/Makefile index ef5280be..7cd367d2 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ GOPATH := $(shell go env GOPATH) LDFLAGS := "-X 'main.Commit=$(COMMIT)' -X 'main.Version=$(VERSION)'" VERSION := $(shell cat ./version) -all: run install build clean +all: run install build clean format check run: go run -ldflags=$(LDFLAGS) $(ABRA) @@ -17,3 +17,9 @@ build: clean: rm '$(GOPATH)/bin/abra' + +format: + gofmt -s -w . + +check: + test -z $$(gofmt -l .) || (echo "gofmt: formatting issue - run 'make format' to resolve" && exit 1)