diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f297aaea..d455658b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,5 +1,5 @@ name: lint -on: [push, pull_request] +on: push jobs: lint: diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2757fb34..1a27db41 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,5 +1,5 @@ name: test -on: [push, pull_request] +on: push jobs: test: runs-on: ${{ matrix.os }} @@ -15,5 +15,7 @@ jobs: - run: go test -cover ./... env: CGO_ENABLED: 0 - - name: Codecov - uses: codecov/codecov-action@v1.0.12 + - name: coverage + run: | + make coverage + bash <(curl -s https://codecov.io/bash) \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..7a8e246d --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +WORKROOT := $(shell pwd) +OUTDIR := $(WORKROOT)/output + +export PATH := $(shell go env GOPATH)/bin:$(PATH) +export GO111MODULE := on + +GOFLAGS := -race +STATICCHECK := staticcheck + +ARCH := $(shell getconf LONG_BIT) +ifeq ($(ARCH),64) + GOTEST += -race +endif + +GEBUG_VERSION ?= $(shell cat VERSION) +GIT_COMMIT ?= $(shell git rev-parse HEAD) + +PKGS := $(shell go list ./...) + +all: compile package + +compile: test build +build: + go build -ldflags "-X main.version=$(GEBUG_VERSION) -X main.commit=$(GIT_COMMIT)" + +test: test-case vet-case +test-case: + go test -cover ./... +vet-case: + go vet ./... + +coverage: + echo -n > coverage.txt + for pkg in $(PKGS) ; do go test -coverprofile=profile.out -covermode=atomic $${pkg} && cat profile.out >> coverage.txt; done + +package: + mkdir -p $(OUTDIR)/bin + mv bfe $(OUTDIR)/bin + cp -r conf $(OUTDIR) + +check: + go get honnef.co/go/tools/cmd/staticcheck + staticcheck ./... + +clean: + rm -rf $(OUTDIR) + rm -rf $(WORKROOT)/gebug + rm -rf $(WORKROOT)/.gebug + rm -rf $(GOPATH)/pkg/linux_amd64 + +.PHONY: all compile test package clean build \ No newline at end of file