github.com/ladydascalie/elvish@v0.0.0-20170703214355-2964dd3ece7f/Makefile (about)

     1  PKG_BASE := github.com/elves/elvish
     2  PKGS := $(shell go list ./... | grep -v /vendor/)
     3  PKG_COVERS := $(shell go list ./... | grep -v '^$(PKG_BASE)/vendor/' | grep -v '^$(PKG_BASE)$$' | sed "s|^$(PKG_BASE)/|cover/|" | sed 's/$$/.cover/')
     4  COVER_MODE := set
     5  
     6  FIRST_GOPATH=$(shell go env GOPATH | cut -d: -f1)
     7  
     8  default: get test
     9  
    10  get:
    11  	go get .
    12  
    13  generate:
    14  	go generate ./...
    15  
    16  test:
    17  	go test $(PKGS)
    18  
    19  cover/%.cover: %
    20  	mkdir -p $(dir $@)
    21  	go test -coverprofile=$@ -covermode=$(COVER_MODE) ./$<
    22  
    23  cover/all: $(PKG_COVERS)
    24  	echo mode: $(COVER_MODE) > $@
    25  	for f in $(PKG_COVERS); do test -f $$f && sed 1d $$f >> $@ || true; done
    26  
    27  # We would love to test for coverage in pull requests, but it's now
    28  # bettered turned off for two reasons:
    29  #
    30  # 1) The goverall badge will always show the "latest" coverage, even if that
    31  # comes from a PR.
    32  #
    33  # 2) Some of the tests have fluctuating coverage (the test against
    34  # edit.tty.AsyncReader), and goveralls will put a big cross on the PR when the
    35  # coverage happens to drop.
    36  goveralls: cover/all
    37  	test "$(TRAVIS_PULL_REQUEST)" = false \
    38  		&& go get -u github.com/mattn/goveralls \
    39  		&& $(FIRST_GOPATH)/bin/goveralls -coverprofile=cover/all -service=travis-ci \
    40  		|| echo "not sending to coveralls"
    41  
    42  upload: get
    43  	tar cfz elvish.tar.gz -C $(FIRST_GOPATH)/bin elvish
    44  	test "$(TRAVIS_GO_VERSION)" = 1.8 -a "$(TRAVIS_PULL_REQUEST)" = false \
    45  		&& test -n "$(TRAVIS_TAG)" -o "$(TRAVIS_BRANCH)" = master \
    46  		&& curl http://ul.elvish.io:6060/ -F name=elvish-$(if $(TRAVIS_TAG),$(TRAVIS_TAG)-,)$(TRAVIS_OS_NAME).tar.gz \
    47  			-F token=$$UPLOAD_TOKEN -F file=@./elvish.tar.gz\
    48  		|| echo "not uploading"
    49  
    50  travis: goveralls upload
    51  
    52  .PHONY: default get generate test goveralls upload travis