Makefile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. GOVERALLS := github.com/mattn/goveralls
  7. default: test get
  8. get:
  9. go get -ldflags "-X github.com/elves/elvish/buildinfo.Version=$(VERSION) \
  10. -X github.com/elves/elvish/buildinfo.GoRoot=$(shell go env GOROOT) \
  11. -X github.com/elves/elvish/buildinfo.GoPath=$(shell go env GOPATH)" .
  12. buildall:
  13. ./_tools/buildall.sh
  14. generate:
  15. go generate ./...
  16. test:
  17. go test $(PKGS)
  18. testmain:
  19. go test .
  20. _cover/%.cover: %
  21. mkdir -p $(dir $@)
  22. go test -coverprofile=$@ -covermode=$(COVER_MODE) ./$<
  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. upload-codecov-travis: _cover/all
  27. curl -s https://codecov.io/bash -o codecov.bash \
  28. && bash codecov.bash -f $<
  29. upload-coveralls-travis: _cover/all
  30. go get -d $(GOVERALLS) \
  31. && go build -o goveralls $(GOVERALLS) \
  32. && ./goveralls -coverprofile $< -service=travis-ci
  33. # Disable coverage reports for pull requests. The general testability of the
  34. # code is pretty bad and it is premature to require contributors to maintain
  35. # code coverage.
  36. upload-codecov-appveyor: _cover/all
  37. codecov -f $<
  38. upload-coveralls-appveyor: _cover/all
  39. goveralls -coverprofile $< -service=appveyor-ci
  40. binaries-travis:
  41. ./_tools/binaries-travis.sh
  42. coverage-travis: upload-codecov-travis upload-coveralls-travis
  43. coverage-appveyor: upload-codecov-appveyor upload-coveralls-appveyor
  44. .PHONY: default get buildall generate test testmain upload-codecov-travis upload-coveralls-travis upload-codecov-appveyor upload-coveralls-appveyor coverage-travis coverage-appveyor binaries-travis