feat: add check unused package. (#85)

This commit is contained in:
Bo-Yi Wu 2017-06-03 01:13:19 -05:00 committed by GitHub
parent b5b13e8b72
commit 9651a4eb6c
2 changed files with 15 additions and 0 deletions

View File

@ -21,6 +21,7 @@ pipeline:
- make vet - make vet
- make lint - make lint
# - make test # - make test
- make test-vendor
- coverage all - coverage all
- make coverage - make coverage
- make build - make build

View File

@ -14,6 +14,7 @@ GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
SOURCES ?= $(shell find . -name "*.go" -type f) SOURCES ?= $(shell find . -name "*.go" -type f)
TAGS ?= TAGS ?=
LDFLAGS ?= -X 'main.Version=$(VERSION)' LDFLAGS ?= -X 'main.Version=$(VERSION)'
TMPDIR := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'tempdir')
ifneq ($(shell uname), Darwin) ifneq ($(shell uname), Darwin)
EXTLDFLAGS = -extldflags "-static" $(null) EXTLDFLAGS = -extldflags "-static" $(null)
@ -39,6 +40,19 @@ fmt-check:
exit 1; \ exit 1; \
fi; 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
fmt: fmt:
$(GOFMT) -w $(GOFILES) $(GOFMT) -w $(GOFILES)