Skip to content

Commit

Permalink
Updates to GNUmakefile and .travis.yml (#21)
Browse files Browse the repository at this point in the history
* Run Travis builds on Xenial

* Use go 1.12.x in Travis

* Update .travis.yml

Tell Travis to instruct go commands to use top-level vendor directory to
satisfy dependencies.

* Remove vendor-status Make target

* Remove unused errcheck Make target

* Remove call to vendor-status from .travis.yml

* Add install-tools Make target; call from .travis.yml

* Replace vet target with lint target

* Add website-lint target and call it from .travis.yml

* Add website-lint to .PHONY target

* Update fmtcheck target

* Update fmt target

* Alphabetize .PHONY target dependencies

* Install linting tools with go get

* Update Docker env to go 1.12.5; add support for lint target in container
  • Loading branch information
Jacob Wan authored May 30, 2019
1 parent a6d3c51 commit bcf35f7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 46 deletions.
11 changes: 6 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
dist: trusty
dist: xenial
sudo: required
services:
- docker
language: go
go:
- "1.9.x"
- "1.12.x"
env: GOFLAGS=-mod=vendor

install:
# This script is used by the Travis build to install a cookie for
# go.googlesource.com so rate limits are higher when using `go get` to fetch
# packages that live there.
# See: https://github.com/golang/go/issues/12933
- bash scripts/gogetcookie.sh
- go get github.com/kardianos/govendor
- make install-tools

script:
- make lint
- make test
- make vendor-status
- make vet
- make website-lint
- make website-test

# branches:
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.11.6-alpine3.9
FROM golang:1.12.5-alpine3.9

RUN apk add --update \
bash \
Expand All @@ -8,6 +8,10 @@ RUN apk add --update \
shadow \
vim

# Additional go tools
RUN go get -u github.com/client9/misspell/cmd/misspell
RUN go get -u github.com/golangci/golangci-lint/cmd/golangci-lint

# Some environment variables to influence Terraform behavior
ENV TF_LOG=TRACE TF_LOG_PATH=/var/log/terraform.log

Expand Down
32 changes: 16 additions & 16 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
TEST?=$$(go list ./... |grep -v 'vendor')
GOFMT_FILES?=$$(find . -name '*.go' |grep -v vendor)
WEBSITE_REPO=github.com/hashicorp/terraform-website
PKG_NAME=citrixitm
DOCKER_SOURCE_DIR=/terraform-provider-$(PKG_NAME)
Expand All @@ -17,26 +16,23 @@ test: fmtcheck
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
install-tools:
GO111MODULE=off go get -u github.com/client9/misspell/cmd/misspell
GO111MODULE=off go get -u github.com/golangci/golangci-lint/cmd/golangci-lint

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

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

# Currently required by tf-deploy compile
fmtcheck:
@echo "==> Checking source code against gofmt..."
@sh -c "'$(CURDIR)/scripts/gofmtcheck.sh'"

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

vendor-status:
@govendor status

test-compile:
@if [ "$(TEST)" = "./..." ]; then \
Expand All @@ -53,6 +49,10 @@ ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
endif
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

website-lint:
@echo "==> Checking website against linters..."
@misspell -error -source=text website/

website-test:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
Expand Down Expand Up @@ -102,4 +102,4 @@ else
@docker run -it --name $(DOCKER_CONTAINER_NAME) --env ITM_BASE_URL --env ITM_CLIENT_ID --env ITM_CLIENT_SECRET --mount type=bind,src=$(PWD),dst=$(DOCKER_SOURCE_DIR) --mount type=bind,src=$(ITM_HOST_MODULE_DIR),dst=/terraform-module $(DOCKER_IMAGE_NAME) /bin/bash
endif

.PHONY: build test testacc vet fmt fmtcheck errcheck vendor-status test-compile website website-test
.PHONY: build fmt fmtcheck install-tools lint test test-compile testacc website website-lint website-test
24 changes: 0 additions & 24 deletions scripts/errcheck.sh

This file was deleted.

0 comments on commit bcf35f7

Please sign in to comment.