2017-06-12 06:16:34 +08:00
|
|
|
PKG_BASE := github.com/elves/elvish
|
2017-11-22 07:29:02 +08:00
|
|
|
PKGS := $(shell go list ./... | sed 's|^$(PKG_BASE)|.|' | grep -v '^./vendor')
|
|
|
|
PKG_COVERS := $(shell go list ./... | sed 's|^$(PKG_BASE)|.|' | grep -v '^\./vendor' | grep -v '^\.$$' | sed 's/^\./cover/' | sed 's/$$/.cover/')
|
2017-06-01 06:26:03 +08:00
|
|
|
COVER_MODE := set
|
2017-09-22 03:12:21 +08:00
|
|
|
VERSION := $(shell git describe --tags --always)
|
2013-09-18 16:58:51 +08:00
|
|
|
|
2016-10-13 16:03:16 +08:00
|
|
|
FIRST_GOPATH=$(shell go env GOPATH | cut -d: -f1)
|
2016-02-22 02:34:40 +08:00
|
|
|
|
2017-12-09 23:45:29 +08:00
|
|
|
default: test get
|
2014-01-31 21:08:56 +08:00
|
|
|
|
2015-02-27 09:29:40 +08:00
|
|
|
get:
|
2017-12-05 04:29:53 +08:00
|
|
|
go get -ldflags "-X github.com/elves/elvish/build.Version=$(VERSION) -X github.com/elves/elvish/build.Builder=$(shell id -un)@$(shell hostname)" .
|
2013-09-18 16:58:51 +08:00
|
|
|
|
2016-10-13 16:18:22 +08:00
|
|
|
generate:
|
|
|
|
go generate ./...
|
|
|
|
|
2016-10-26 17:36:26 +08:00
|
|
|
test:
|
2016-09-15 22:18:03 +08:00
|
|
|
go test $(PKGS)
|
2014-01-25 21:15:54 +08:00
|
|
|
|
2017-12-08 08:39:55 +08:00
|
|
|
testmain:
|
|
|
|
go test .
|
|
|
|
|
2017-02-12 11:15:37 +08:00
|
|
|
cover/%.cover: %
|
|
|
|
mkdir -p $(dir $@)
|
2016-10-13 16:18:22 +08:00
|
|
|
go test -coverprofile=$@ -covermode=$(COVER_MODE) ./$<
|
2014-01-25 21:15:54 +08:00
|
|
|
|
2016-10-13 16:18:22 +08:00
|
|
|
cover/all: $(PKG_COVERS)
|
|
|
|
echo mode: $(COVER_MODE) > $@
|
2017-05-29 19:59:48 +08:00
|
|
|
for f in $(PKG_COVERS); do test -f $$f && sed 1d $$f >> $@ || true; done
|
2014-01-25 21:15:54 +08:00
|
|
|
|
2017-12-16 21:47:07 +08:00
|
|
|
# Disable coverage reports for pull requests. The general testability of the
|
|
|
|
# code is pretty bad and it is premature to require contributors to maintain
|
|
|
|
# code coverage.
|
2017-12-16 12:30:33 +08:00
|
|
|
codecov: cover/all
|
|
|
|
test "$(TRAVIS_PULL_REQUEST)" = false \
|
2017-12-16 12:36:04 +08:00
|
|
|
&& curl -s https://codecov.io/bash -o codecov.bash \
|
|
|
|
&& bash codecov.bash -f cover/all \
|
2017-12-16 12:30:33 +08:00
|
|
|
|| echo "not sending to codecov.io"
|
|
|
|
|
2017-11-30 00:47:57 +08:00
|
|
|
upload:
|
2017-11-30 00:23:29 +08:00
|
|
|
test "$(TRAVIS_OS_NAME)" = linux \
|
|
|
|
&& echo "$(TRAVIS_GO_VERSION)" | grep -q '^1.9' \
|
2017-07-11 08:14:17 +08:00
|
|
|
&& test "$(TRAVIS_PULL_REQUEST)" = false \
|
2016-10-13 16:32:00 +08:00
|
|
|
&& test -n "$(TRAVIS_TAG)" -o "$(TRAVIS_BRANCH)" = master \
|
2017-11-30 00:47:57 +08:00
|
|
|
&& go build -o ./elvish \
|
|
|
|
&& ./elvish build-and-upload.elv \
|
2017-11-30 00:23:29 +08:00
|
|
|
|| echo "not build-and-uploading"
|
2016-10-13 16:18:22 +08:00
|
|
|
|
2017-12-16 21:47:07 +08:00
|
|
|
travis: codecov testmain upload
|
2016-02-10 06:10:26 +08:00
|
|
|
|
2016-10-26 17:36:26 +08:00
|
|
|
.PHONY: default get generate test goveralls upload travis
|