diff --git a/.drone.yml b/.drone.yml index 71bf2bb..23159bc 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,7 +2,40 @@ kind: pipeline name: coopcloud.tech/abra steps: + - name: make check + image: golang:1.16 + commands: + - make check + + - name: make static + image: golang:1.16 + ignore: true # until we decide we all want this check + environment: + STATIC_CHECK_URL: honnef.co/go/tools/cmd/staticcheck + STATIC_CHECK_VERSION: v0.2.0 + commands: + - go install $STATIC_CHECK_URL@$STATIC_CHECK_VERSION + - make static + - name: make build image: golang:1.16 commands: - make build + + - name: notify on failure + image: plugins/matrix + settings: + homeserver: https://matrix.autonomic.zone + roomid: "IFazIpLtxiScqbHqoa:autonomic.zone" + userid: "@autono-bot:autonomic.zone" + accesstoken: + from_secret: autono_bot_access_token + depends_on: + - make check + - make build + when: + status: + - failure +trigger: + branch: + - main diff --git a/Makefile b/Makefile index d2e0bca..0f85de6 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,28 @@ +ABRA := ./cmd/abra COMMIT := $(shell git rev-list -1 HEAD) -VERSION := $(shell cat ./version) GOPATH := $(shell go env GOPATH) +VERSION := $(shell cat ./version) LDFLAGS := "-X 'main.Commit=$(COMMIT)' -X 'main.Version=$(VERSION)'" -all: run install build clean +all: run install build clean format check static run: - go run -ldflags=$(LDFLAGS) ./cmd/abra + @go run -ldflags=$(LDFLAGS) $(ABRA) install: - go install -ldflags=$(LDFLAGS) ./cmd/abra + @go install -ldflags=$(LDFLAGS) $(ABRA) build: - go build -ldflags=$(LDFLAGS) ./cmd/abra + @go build -ldflags=$(LDFLAGS) $(ABRA) clean: - rm '$(GOPATH)/bin/abra' + @rm '$(GOPATH)/bin/abra' + +format: + @gofmt -s -w . + +check: + @test -z $$(gofmt -l .) || (echo "gofmt: formatting issue - run 'make format' to resolve" && exit 1) + +static: + @staticcheck $(ABRA) diff --git a/README.md b/README.md index af28a59..20cc3a3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # go-abra [![Build Status](https://drone.autonomic.zone/api/badges/coop-cloud/go-abra/status.svg?ref=refs/heads/main)](https://drone.autonomic.zone/coop-cloud/go-abra) +[![Go Report Card](https://goreportcard.com/badge/git.autonomic.zone/coop-cloud/go-abra)](https://goreportcard.com/report/git.autonomic.zone/coop-cloud/go-abra) WIP port of [abra](https://git.autonomic.zone/coop-cloud/abra) to Golang.