From 4de295c357998f9cdf3377c06a5936a15aba00f2 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Thu, 10 Oct 2019 01:03:51 +0800 Subject: [PATCH] chore: update makefile --- .dockerignore | 2 ++ .editorconfig | 42 +++++++++++++++++++++++++++++++ config.toml => .revive.toml | 0 Makefile | 49 ++++++++----------------------------- 4 files changed, 54 insertions(+), 39 deletions(-) create mode 100644 .dockerignore create mode 100644 .editorconfig rename config.toml => .revive.toml (100%) diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c13ca3f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +* +!release/ diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..e4f9bec --- /dev/null +++ b/.editorconfig @@ -0,0 +1,42 @@ +# unifying the coding style for different editors and IDEs => editorconfig.org + +; indicate this is the root of the project +root = true + +########################################################### +; common +########################################################### + +[*] +charset = utf-8 + +end_of_line = LF +insert_final_newline = true +trim_trailing_whitespace = true + +indent_style = space +indent_size = 2 + +########################################################### +; make +########################################################### + +[Makefile] +indent_style = tab + +[makefile] +indent_style = tab + +########################################################### +; markdown +########################################################### + +[*.md] +trim_trailing_whitespace = false + +########################################################### +; golang +########################################################### + +[*.go] +indent_style = tab \ No newline at end of file diff --git a/config.toml b/.revive.toml similarity index 100% rename from config.toml rename to .revive.toml diff --git a/Makefile b/Makefile index 4f568e0..3e08b2f 100644 --- a/Makefile +++ b/Makefile @@ -8,11 +8,10 @@ DEPLOY_ACCOUNT := appleboy DEPLOY_IMAGE := $(EXECUTABLE) TARGETS ?= linux darwin windows -PACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/) -GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*") +PACKAGES ?= $(shell $(GO) list ./...) SOURCES ?= $(shell find . -name "*.go" -type f) TAGS ?= -LDFLAGS ?= -X 'main.Version=$(VERSION)' -X 'main.BuildNum=$(DRONE_BUILD_NUMBER)' +LDFLAGS ?= -X 'main.Version=$(VERSION)' TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'tempdir') ifneq ($(shell uname), Darwin) @@ -30,70 +29,42 @@ endif all: build fmt: - $(GOFMT) -w $(GOFILES) + $(GOFMT) -w $(SOURCES) vet: $(GO) vet $(PACKAGES) -errcheck: - @which errcheck > /dev/null; if [ $$? -ne 0 ]; then \ - $(GO) get -u github.com/kisielk/errcheck; \ - fi - errcheck $(PACKAGES) - -revive: +lint: @hash revive > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ $(GO) get -u github.com/mgechev/revive; \ fi - revive -config config.toml -exclude=./vendor/... ./... || exit 1 - -unconvert: - @which unconvert > /dev/null; if [ $$? -ne 0 ]; then \ - $(GO) get -u github.com/mdempsky/unconvert; \ - fi - for PKG in $(PACKAGES); do unconvert -v $$PKG || exit 1; done; + revive -config .revive.toml ./... || exit 1 .PHONY: misspell-check misspell-check: @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ $(GO) get -u github.com/client9/misspell/cmd/misspell; \ fi - misspell -error $(GOFILES) + misspell -error $(SOURCES) .PHONY: misspell misspell: @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ $(GO) get -u github.com/client9/misspell/cmd/misspell; \ fi - misspell -w $(GOFILES) + misspell -w $(SOURCES) .PHONY: fmt-check fmt-check: - @diff=$$($(GOFMT) -d $(GOFILES)); \ + @diff=$$($(GOFMT) -d $(SOURCES)); \ if [ -n "$$diff" ]; then \ echo "Please run 'make fmt' and commit the result:"; \ echo "$${diff}"; \ exit 1; \ fi; -.PHONY: test-vendor -test-vendor: - @hash govendor > /dev/null 2>&1; if [ $$? -ne 0 ]; then \ - $(GO) get -u github.com/kardianos/govendor; \ - fi - govendor list +unused | tee "$(TMPDIR)/wc-gitea-unused" - [ $$(cat "$(TMPDIR)/wc-gitea-unused" | wc -l) -eq 0 ] || echo "Warning: /!\\ Some vendor are not used /!\\" - - govendor list +outside | tee "$(TMPDIR)/wc-gitea-outside" - [ $$(cat "$(TMPDIR)/wc-gitea-outside" | wc -l) -eq 0 ] || exit 1 - - govendor status || exit 1 - test: fmt-check - for PKG in $(PACKAGES); do $(GO) test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.txt $$PKG || exit 1; done; - -html: - $(GO) tool cover -html=coverage.txt + @$(GO) test -v -cover -coverprofile coverage.txt $(PACKAGES) && echo "\n==>\033[32m Ok\033[m\n" || exit 1 install: $(SOURCES) $(GO) install -v -tags '$(TAGS)' -ldflags '$(EXTLDFLAGS)-s -w $(LDFLAGS)' @@ -135,7 +106,7 @@ build_linux_arm: docker_image: docker build -t $(DEPLOY_ACCOUNT)/$(DEPLOY_IMAGE) . -docker: static_build docker_image +docker: docker_image docker_deploy: ifeq ($(tag),)