From a6d0aab593325d788c460ac0c495172fba6c5b5f Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 15 Sep 2019 14:27:08 +0000 Subject: [PATCH] Makefile for go mod (#189) --- .drone.yml | 69 ++++++++++++++++++++++++++++++++++-------------------- Makefile | 21 ++++------------- 2 files changed, 48 insertions(+), 42 deletions(-) diff --git a/.drone.yml b/.drone.yml index 677e597..3a3126b 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,34 +1,51 @@ +--- +kind: pipeline +name: default + +platform: + os: linux + arch: amd64 + +clone: + disable: true + workspace: base: /go path: src/code.gitea.io/sdk -clone: - git: - image: plugins/git:next +steps: +- name: git + pull: default + image: plugins/git:next + settings: depth: 50 tags: true -pipeline: - testing: - image: golang:1.12 - pull: true - commands: - - make clean - - make vet - - make lint - - make test - - make build +- name: testing + pull: always + image: golang:1.13 + environment: + GOPROXY: https://goproxy.cn + commands: + - make clean + - make vet + - make lint + - make test + - make build - # coverage: - # image: plugins/coverage:1 - # pull: true - # secrets: [ github_token ] - # server: https://coverage.gitea.io - - discord: - image: appleboy/drone-discord:1.0.0 - pull: true - secrets: [ discord_webhook_id, discord_webhook_token ] - when: - event: [ push, tag, pull_request ] - status: [ changed, failure ] +- name: discord + pull: always + image: appleboy/drone-discord:1.0.0 + environment: + DISCORD_WEBHOOK_ID: + from_secret: discord_webhook_id + DISCORD_WEBHOOK_TOKEN: + from_secret: discord_webhook_token + when: + event: + - push + - tag + - pull_request + status: + - changed + - failure \ No newline at end of file diff --git a/Makefile b/Makefile index e9489d9..4c06e8e 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,3 @@ -IMPORT := code.gitea.io/sdk - -PACKAGES ?= $(shell go list -e ./... | grep -v /vendor/ | grep -v /benchmark/) -GENERATE ?= code.gitea.io/sdk/gitea - .PHONY: all all: clean test build @@ -10,12 +5,6 @@ all: clean test build clean: go clean -i ./... -generate: - @which mockery > /dev/null; if [ $$? -ne 0 ]; then \ - go get -u github.com/vektra/mockery/...; \ - fi - go generate $(GENERATE) - .PHONY: fmt fmt: find . -name "*.go" -type f ! -path "./vendor/*" ! -path "./benchmark/*" | xargs gofmt -s -w @@ -23,23 +12,23 @@ fmt: .PHONY: vet vet: go get code.gitea.io/gitea/modules/structs - go vet $(PACKAGES) + cd gitea && go vet ./... .PHONY: lint lint: @which golint > /dev/null; if [ $$? -ne 0 ]; then \ go get -u golang.org/x/lint/golint; \ fi - for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done; + cd gitea && golint -set_exit_status .PHONY: test test: - for PKG in $(PACKAGES); do go test -cover -coverprofile $$GOPATH/src/$$PKG/coverage.out $$PKG || exit 1; done; + cd gitea && go test -cover -coverprofile coverage.out .PHONY: bench bench: - go test -run=XXXXXX -benchtime=10s -bench=. || exit 1 + cd gitea && go test -run=XXXXXX -benchtime=10s -bench=. || exit 1 .PHONY: build build: - go build ./gitea + cd gitea && go build