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

Update makefile for utils #18

Merged
merged 2 commits into from
Jul 17, 2020
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
1 change: 1 addition & 0 deletions .go-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.13.7
25 changes: 25 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
default: build

build: fmtcheck
go install

test: fmtcheck
go test ./... -v -timeout 120s

testacc: fmtcheck
TF_ACC=1 go test ./... -v $(TESTARGS) -timeout 120s

cassettes: fmtcheck
RECORD=true 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

fmt:
gofmt -w $(GOFMT_FILES)

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

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

.PHONY: build test testacc fmt cassettes vet fmtcheck errcheck
24 changes: 24 additions & 0 deletions scripts/errcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# Check gofmt
echo "==> Checking for unchecked errors..."

if ! which errcheck > /dev/null; then
echo "==> Installing errcheck..."
go get -u github.com/kisielk/errcheck
fi

err_files=$(errcheck -ignoretests \
-ignore 'github.com/hashicorp/terraform/helper/schema:Set' \
-ignore 'bytes:.*' \
-ignore 'io:Close|Write' \
$(go list ./...| grep -v /vendor/))

if [[ -n ${err_files} ]]; then
echo 'Unchecked errors found in the following places:'
echo "${err_files}"
echo "Please handle returned errors. You can check directly with \`make errcheck\`"
exit 1
fi

exit 0