Merge pull request #8 from adamreese/feat/makefile

feat(Makefile): add Makefile
pull/613/head
Adam Reese 8 years ago
commit 32697fa226

2
.gitignore vendored

@ -1,2 +1,4 @@
.coverage/
bin/
vendor/
_proto/*.pb.go

@ -0,0 +1,44 @@
GO ?= go
PKG := $(shell glide novendor)
TAGS :=
TESTS := .
TESTFLAGS :=
LDFLAGS :=
BINARIES := helm tiller
.PHONY: all
all: build
.PHONY: build
build:
@for i in $(BINARIES); do \
$(GO) build -o ./bin/$$i -v $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' ./cmd/$$i || exit 1; \
done
.PHONY: test
test: TESTFLAGS += -race -v
test: test-style
test: test-unit
.PHONY: test-unit
test-unit:
$(GO) test $(GOFLAGS) -run $(TESTS) $(PKG) $(TESTFLAGS)
.PHONY: test-style
test-style:
@scripts/validate-go.sh
.PHONY: clean
clean:
rm -rf ./bin
.PHONY: coverage
coverage:
@scripts/coverage.sh
.PHONY: bootstrap
bootstrap:
glide install

@ -0,0 +1,31 @@
machine:
environment:
GLIDE_VERSION: "0.10.1"
GO15VENDOREXPERIMENT: 1
GOPATH: /usr/local/go_workspace
HOME: /home/ubuntu
IMPORT_PATH: "github.com/deis/tiller"
PATH: $HOME/go/bin:$PATH
GOROOT: $HOME/go
dependencies:
override:
- mkdir -p $HOME/go
- wget "https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz"
- tar -C $HOME -xzf go1.6.linux-amd64.tar.gz
- go version
- go env
- sudo chown -R $(whoami):staff /usr/local
- cd $GOPATH
- mkdir -p $GOPATH/src/$IMPORT_PATH
- cd $HOME/tiller
- rsync -az --delete ./ "$GOPATH/src/$IMPORT_PATH/"
- wget "https://github.com/Masterminds/glide/releases/download/$GLIDE_VERSION/glide-$GLIDE_VERSION-linux-amd64.tar.gz"
- mkdir -p $HOME/bin
- tar -vxz -C $HOME/bin --strip=1 -f glide-$GLIDE_VERSION-linux-amd64.tar.gz
- export PATH="$HOME/bin:$PATH" GLIDE_HOME="$HOME/.glide"
- cd $GOPATH/src/$IMPORT_PATH
test:
override:
- cd $GOPATH/src/$IMPORT_PATH && make bootstrap test

@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -euo pipefail
COVERDIR=${COVERDIR:-.coverage}
COVERMODE=${COVERMODE:-atomic}
PACKAGES=($(go list $(glide novendor)))
if [[ ! -d "$COVERDIR" ]]; then
mkdir -p "$COVERDIR"
fi
echo "mode: ${COVERMODE}" > "${COVERDIR}/coverage.out"
for d in "${PACKAGES[@]}"; do
go test -coverprofile=profile.out -covermode="$COVERMODE" "$d"
if [ -f profile.out ]; then
sed "/mode: $COVERMODE/d" profile.out >> "${COVERDIR}/coverage.out"
rm profile.out
fi
done
go tool cover -html "${COVERDIR}/coverage.out" -o "${COVERDIR}/coverage.html"

@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail
readonly reset=$(tput sgr0)
readonly red=$(tput bold; tput setaf 1)
readonly green=$(tput bold; tput setaf 2)
readonly yellow=$(tput bold; tput setaf 3)
exit_code=0
find_go_files() {
find . -type f -name "*.go" | grep -v vendor
}
hash golint 2>/dev/null || go get -u github.com/golang/lint/golint
hash go vet 2>/dev/null || go get -u golang.org/x/tools/cmd/vet
echo "==> Running golint..."
for pkg in $(glide nv); do
if golint_out=$(golint "$pkg" 2>&1); then
echo "${yellow}${golint_out}${reset}"
fi
done
echo "==> Running go vet..."
echo -n "$red"
go vet $(glide nv) 2>&1 | grep -v "^exit status " || exit_code=${PIPESTATUS[0]}
echo -n "$reset"
echo "==> Running gofmt..."
failed_fmt=$(find_go_files | xargs gofmt -s -l)
if [[ -n "${failed_fmt}" ]]; then
echo -n "${red}"
echo "gofmt check failed:"
echo "$failed_fmt"
gofmt -s -d "${failed_fmt}"
echo -n "${reset}"
exit_code=1
fi
exit ${exit_code}
Loading…
Cancel
Save