Skip to content

Commit

Permalink
A few tweaks to the build setup & reported version
Browse files Browse the repository at this point in the history
  • Loading branch information
meatballhat committed Aug 20, 2014
1 parent b03fc33 commit 066f026
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -22,13 +22,15 @@ _testmain.go
*.exe
*.test

*coverage.out
*.coverprofile
*coverage.html

/artifacts
/artifacts.test

/.env
/.gox-bootstrap
/.gox-install
/.deps
/build/
/SHA256SUMS
39 changes: 27 additions & 12 deletions Makefile
Expand Up @@ -7,6 +7,13 @@ SUBPACKAGES := \
$(PACKAGE)/path \
$(PACKAGE)/upload

COVERPROFILES := \
artifact-coverage.coverprofile \
env-coverage.coverprofile \
logging-coverage.coverprofile \
path-coverage.coverprofile \
upload-coverage.coverprofile

VERSION_VAR := main.VersionString
REPO_VERSION := $(shell git describe --always --dirty --tags)

Expand Down Expand Up @@ -35,30 +42,30 @@ test-deps:
test-race:
$(GO) test -race $(GOBUILD_LDFLAGS) $(PACKAGE) $(SUBPACKAGES)

coverage.html: coverage.out
coverage.html: coverage.coverprofile
$(GO) tool cover -html=$^ -o $@

coverage.out: path-coverage.out upload-coverage.out env-coverage.out logging-coverage.out artifact-coverage.out
coverage.coverprofile: $(COVERPROFILES)
$(GO) test -v -covermode=count -coverprofile=$@.tmp $(GOBUILD_LDFLAGS) $(PACKAGE)
echo 'mode: count' > $@
grep -h -v 'mode: count' $@.tmp >> $@
rm -f $@.tmp
grep -h -v 'mode: count' $^ >> $@
$(GO) tool cover -func=$@

path-coverage.out:
path-coverage.coverprofile:
$(GO) test -v -covermode=count -coverprofile=$@ $(GOBUILD_LDFLAGS) $(PACKAGE)/path

upload-coverage.out:
upload-coverage.coverprofile:
$(GO) test -v -covermode=count -coverprofile=$@ $(GOBUILD_LDFLAGS) $(PACKAGE)/upload

env-coverage.out:
env-coverage.coverprofile:
$(GO) test -v -covermode=count -coverprofile=$@ $(GOBUILD_LDFLAGS) $(PACKAGE)/env

logging-coverage.out:
logging-coverage.coverprofile:
$(GO) test -v -covermode=count -coverprofile=$@ $(GOBUILD_LDFLAGS) $(PACKAGE)/logging

artifact-coverage.out:
artifact-coverage.coverprofile:
$(GO) test -v -covermode=count -coverprofile=$@ $(GOBUILD_LDFLAGS) $(PACKAGE)/artifact

USAGE.txt: build
Expand All @@ -74,22 +81,30 @@ USAGE.md: USAGE.txt UPLOAD_USAGE.txt $(shell git ls-files '*.go')
$(GOX) -build-toolchain -osarch="$(GOX_OSARCH)" -verbose 2>&1 | tee $@

.PHONY: build
build: deps
build: deps .build

.PHONY: .build
.build:
$(GO) install $(GOBUILD_FLAGS) $(GOBUILD_LDFLAGS) $(PACKAGE)

.PHONY: crossbuild
crossbuild: deps .gox-bootstrap
$(GOX) $(GOX_FLAGS) $(GOBUILD_FLAGS) $(GOBUILD_LDFLAGS) $(PACKAGE)

.PHONY: deps
deps:
$(GODEP) restore
$(GO) get github.com/mitchellh/gox
deps: .gox-install .deps

.deps:
$(GODEP) restore && touch $@

.gox-install:
$(GO) get -x github.com/mitchellh/gox > $@

.PHONY: clean
clean:
rm -vf .gox-* .deps
rm -vf $${GOPATH%%:*}/bin/artifacts
rm -vf coverage.html *coverage.out
rm -vf coverage.html *.coverprofile
$(GO) clean $(PACKAGE) $(SUBPACKAGES) || true
if [ -d $${GOPATH%%:*}/pkg ] ; then \
find $${GOPATH%%:*}/pkg -wholename '*travis-ci/artifacts*.a' | xargs rm -rfv || true; \
Expand Down
2 changes: 1 addition & 1 deletion artifacts.go
Expand Up @@ -118,7 +118,7 @@ func buildApp() *cli.App {
app := cli.NewApp()
app.Name = "artifacts"
app.Usage = "manage your artifacts!"
app.Version = VersionString
app.Version = fmt.Sprintf("%s revision=%s", VersionString, RevisionString)
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "log-format, f",
Expand Down

0 comments on commit 066f026

Please sign in to comment.