Makefile for go mod (#189)

This commit is contained in:
Lunny Xiao 2019-09-15 14:27:08 +00:00 committed by Gitea
parent bbad0d915e
commit a6d0aab593
2 changed files with 48 additions and 42 deletions

View file

@ -1,17 +1,31 @@
---
kind: pipeline
name: default
platform:
os: linux
arch: amd64
clone:
disable: true
workspace: workspace:
base: /go base: /go
path: src/code.gitea.io/sdk path: src/code.gitea.io/sdk
clone: steps:
git: - name: git
pull: default
image: plugins/git:next image: plugins/git:next
settings:
depth: 50 depth: 50
tags: true tags: true
pipeline: - name: testing
testing: pull: always
image: golang:1.12 image: golang:1.13
pull: true environment:
GOPROXY: https://goproxy.cn
commands: commands:
- make clean - make clean
- make vet - make vet
@ -19,16 +33,19 @@ pipeline:
- make test - make test
- make build - make build
# coverage: - name: discord
# image: plugins/coverage:1 pull: always
# pull: true
# secrets: [ github_token ]
# server: https://coverage.gitea.io
discord:
image: appleboy/drone-discord:1.0.0 image: appleboy/drone-discord:1.0.0
pull: true environment:
secrets: [ discord_webhook_id, discord_webhook_token ] DISCORD_WEBHOOK_ID:
from_secret: discord_webhook_id
DISCORD_WEBHOOK_TOKEN:
from_secret: discord_webhook_token
when: when:
event: [ push, tag, pull_request ] event:
status: [ changed, failure ] - push
- tag
- pull_request
status:
- changed
- failure

View file

@ -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 .PHONY: all
all: clean test build all: clean test build
@ -10,12 +5,6 @@ all: clean test build
clean: clean:
go clean -i ./... 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 .PHONY: fmt
fmt: fmt:
find . -name "*.go" -type f ! -path "./vendor/*" ! -path "./benchmark/*" | xargs gofmt -s -w find . -name "*.go" -type f ! -path "./vendor/*" ! -path "./benchmark/*" | xargs gofmt -s -w
@ -23,23 +12,23 @@ fmt:
.PHONY: vet .PHONY: vet
vet: vet:
go get code.gitea.io/gitea/modules/structs go get code.gitea.io/gitea/modules/structs
go vet $(PACKAGES) cd gitea && go vet ./...
.PHONY: lint .PHONY: lint
lint: lint:
@which golint > /dev/null; if [ $$? -ne 0 ]; then \ @which golint > /dev/null; if [ $$? -ne 0 ]; then \
go get -u golang.org/x/lint/golint; \ go get -u golang.org/x/lint/golint; \
fi fi
for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done; cd gitea && golint -set_exit_status
.PHONY: test .PHONY: test
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 .PHONY: bench
bench: bench:
go test -run=XXXXXX -benchtime=10s -bench=. || exit 1 cd gitea && go test -run=XXXXXX -benchtime=10s -bench=. || exit 1
.PHONY: build .PHONY: build
build: build:
go build ./gitea cd gitea && go build