Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use go generate for executing go-bindata #33

Merged
merged 2 commits into from
Oct 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 26 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,38 @@ COMMIT = $$(git describe --always)
DEBUG_FLAG = $(if $(DEBUG),-debug)

deps:
go get -v golang.org/x/tools/cmd/vet
go get -v github.com/golang/lint/golint
@echo "====> Install depedencies..."
go get -v github.com/jteeuwen/go-bindata/...
go get -v -d -t ./...

build: deps
cd skeleton; go-bindata -pkg="skeleton" resource/...
go build -ldflags "-X main.GitCommit=\"$(COMMIT)\"" -o bin/gcli
devdeps:
@echo "====> Install depedencies for development..."
go get -v golang.org/x/tools/cmd/vet
go get -v github.com/golang/lint/golint

install: deps
cd skeleton; go-bindata -pkg="skeleton" resource/...
go install -ldflags "-X main.GitCommit=\"$(COMMIT)\""
generate: deps
@go generate ./...

test: build
./test.sh
build: generate
@echo "====> Build gcli in ./bin "
go build -ldflags "-X main.GitCommit=\"$(COMMIT)\"" -o bin/gcli

tests: build
cd tests; go test -v ./...
install: generate
@echo "====> Install gcli in $(GOPATH)/bin ..."
@go install -ldflags "-X main.GitCommit=\"$(COMMIT)\""

test: generate devdeps
@echo "====> Run test"
@sh -c "$(CURDIR)/test.sh"

test-simple: build
go test -v ./...
test-race: generate devdeps
go test -race ./...

# Run test inside docker container
test-docker:
./test-docker.sh
@sh -c "$(CURDIR)/test-docker.sh"

# Run functional test
test-functional: build devdeps
@echo "====> Run functional test"
cd tests; go test -v ./...
3 changes: 3 additions & 0 deletions skeleton/resource.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package skeleton

//go:generate go-bindata -pkg=skeleton ./resource/...
8 changes: 4 additions & 4 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
# it will exit with non-zero status

TARGET=$(find . -name "*.go" | grep -v "bindata.go")
echo -e "Run gofmt"
echo -e "----> Run gofmt"
FMT_RES=$(gofmt -l ${TARGET})
if [ -n "${FMT_RES}" ]; then
echo -e "gofmt failed: \n${FMT_RES}"
exit 255
fi

echo -e "Run go vet"
echo -e "----> Run go vet"
go list -f '{{.Dir}}' ./... | xargs go tool vet
if [ $? -ne 0 ]; then
echo -e "go vet failed"
exit 255
fi

# TODO, better way to exclude some lint warning.
echo -e "Run golint"
echo -e "----> Run golint"
LINT_RES=$(golint ./... | \
grep -v "bindata.go" | \
grep -v "type name will be used as command.CommandFlag by other packages" | \
Expand All @@ -33,5 +33,5 @@ if [ -n "${LINT_RES}" ]; then
exit 255
fi

echo -e "Run go test"
echo -e "----> Run go test"
go test -v ./...