github.com/elves/Elvish@v0.12.0/Makefile (about) 1 PKG_BASE := github.com/elves/elvish 2 PKGS := $(shell go list ./... | sed 's|^$(PKG_BASE)|.|' | grep -v '^./\(vendor\|website\)') 3 PKG_COVERS := $(shell go list ./... | sed 's|^$(PKG_BASE)|.|' | grep -v '^\./\(vendor\|website\)' | grep -v '^\.$$' | sed 's/^\./cover/' | sed 's/$$/.cover/') 4 COVER_MODE := set 5 VERSION := $(shell git describe --tags --always --dirty=-dirty) 6 7 GOVERALLS := github.com/mattn/goveralls 8 9 default: test get 10 11 get: 12 go get -ldflags "-X github.com/elves/elvish/buildinfo.Version=$(VERSION) \ 13 -X github.com/elves/elvish/buildinfo.GoRoot=$(shell go env GOROOT) \ 14 -X github.com/elves/elvish/buildinfo.GoPath=$(shell go env GOPATH)" . 15 16 buildall: 17 ./buildall.sh 18 19 generate: 20 go generate ./... 21 22 test: 23 go test $(PKGS) 24 25 testmain: 26 go test . 27 28 cover/%.cover: % 29 mkdir -p $(dir $@) 30 go test -coverprofile=$@ -covermode=$(COVER_MODE) ./$< 31 32 cover/all: $(PKG_COVERS) 33 echo mode: $(COVER_MODE) > $@ 34 for f in $(PKG_COVERS); do test -f $$f && sed 1d $$f >> $@ || true; done 35 36 # Disable coverage reports for pull requests. The general testability of the 37 # code is pretty bad and it is premature to require contributors to maintain 38 # code coverage. 39 upload-codecov-travis: cover/all 40 test "$(TRAVIS_PULL_REQUEST)" = false \ 41 && echo "$(TRAVIS_GO_VERSION)" | grep -q '^1.10' \ 42 && curl -s https://codecov.io/bash -o codecov.bash \ 43 && bash codecov.bash -f $< \ 44 || echo "not sending to codecov.io" 45 46 upload-coveralls-travis: cover/all 47 test "$(TRAVIS_PULL_REQUEST)" = false \ 48 && echo "$(TRAVIS_GO_VERSION)" | grep -q '^1.10' \ 49 && go get -d $(GOVERALLS) \ 50 && go build -o goveralls $(GOVERALLS) \ 51 && ./goveralls -coverprofile $< -service=travis-ci \ 52 || echo "not sending to coveralls.io" 53 54 upload-codecov-appveyor: cover/all 55 test -z "$(APPVEYOR_PULL_REQUEST_NUMBER)" \ 56 && codecov -f $< \ 57 || echo "not sending to codecov.io" 58 59 upload-coveralls-appveyor: cover/all 60 test -z "$(APPVEYOR_PULL_REQUEST_NUMBER)" \ 61 && goveralls -coverprofile $< -service=appveyor-ci \ 62 || echo "not sending to coveralls.io" 63 64 travis: testmain upload-codecov-travis upload-coveralls-travis 65 appveyor: testmain upload-codecov-appveyor 66 67 .PHONY: default get buildall generate test testmain upload-codecov-travis upload-coveralls-travis upload-codecov-appveyor upload-coveralls-appveyor travis