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,34 +1,51 @@
---
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
image: plugins/git:next pull: default
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:
commands: GOPROXY: https://goproxy.cn
- make clean commands:
- make vet - make clean
- make lint - make vet
- make test - make lint
- make build - make test
- make build
# coverage: - name: discord
# image: plugins/coverage:1 pull: always
# pull: true image: appleboy/drone-discord:1.0.0
# secrets: [ github_token ] environment:
# server: https://coverage.gitea.io DISCORD_WEBHOOK_ID:
from_secret: discord_webhook_id
discord: DISCORD_WEBHOOK_TOKEN:
image: appleboy/drone-discord:1.0.0 from_secret: discord_webhook_token
pull: true when:
secrets: [ discord_webhook_id, discord_webhook_token ] event:
when: - push
event: [ push, tag, pull_request ] - tag
status: [ changed, failure ] - 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