Skip to content

Commit

Permalink
improve build config
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptobioz committed May 21, 2019
1 parent 3962dd3 commit 0c20e81
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
language: go
go_import_path: github.com/camptocamp/terraform-provider-puppetdb
go:
- "1.11"

script:
- make test
- make vet
- make build
40 changes: 18 additions & 22 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,43 @@
TEST?=$$(go list ./... |grep -v 'vendor')
TEST?=./...
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
PKG_NAME=puppetdb

default: build

build: fmtcheck
go install

test: fmtcheck
go test -i $(TEST) || exit 1
echo $(TEST) | \
xargs -t -n4 go test $(TESTARGS) -timeout=30s -parallel=4
go test $(TEST) -timeout=30s -parallel=4

testacc: fmtcheck
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 120m

vet:
@echo "go vet ."
@go vet $$(go list ./... | grep -v vendor/) ; if [ $$? -eq 1 ]; then \
echo ""; \
echo "Vet found suspicious constructs. Please check the reported constructs"; \
echo "and fix them if necessary before submitting the code for review."; \
exit 1; \
fi
TF_ACC=1 go test $(TEST) -v -parallel 20 $(TESTARGS) -timeout 120m

fmt:
gofmt -w $(GOFMT_FILES)
@echo "==> Fixing source code with gofmt..."
gofmt -s -w ./$(PKG_NAME)

# Currently required by tf-deploy compile
fmtcheck:
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

errcheck:
@sh -c "'$(CURDIR)/scripts/errcheck.sh'"

vendor-status:
@govendor status
lint:
@echo "==> Checking source code against linters..."
@GOGC=30 golangci-lint run ./$(PKG_NAME)

test-compile:
@if [ "$(TEST)" = "./..." ]; then \
echo "ERROR: Set TEST to a specific package. For example,"; \
echo " make test-compile TEST=./aws"; \
echo " make test-compile TEST=./$(PKG_NAME)"; \
exit 1; \
fi
go test -c $(TEST) $(TESTARGS)

.PHONY: build test testacc vet fmt fmtcheck errcheck vendor-status test-compile
vendor:
go mod tidy
go mod vendor

vet:
go vet $<

.PHONY: build test testacc fmt fmtcheck lint test-compile vendor

0 comments on commit 0c20e81

Please sign in to comment.