Skip to content

Commit

Permalink
Simplify integration tests run
Browse files Browse the repository at this point in the history
  • Loading branch information
syndbg committed Apr 22, 2019
1 parent 077a69a commit 37b8a94
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Ignore artifacts that `make download-consul` can generate/download
/consul
/consul.zip
# Ignore vendor explicitly since we're moving to go modules
vendor
/consul-template
Expand Down
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@ language: go
go:
- 1.12.4

env:
- GOMAXPROCS=4

branches:
only:
- master

env:
- GOMAXPROCS=4
- CONSUL_VERSION=1.4.2
- CONSUL_BIN_PATH=~/bin/consul
# Enforce gomodules since Travis' workers download in the GOPATH where gomod is disabled by default.
- GO111MODULE=on

before_install:
- curl -sLo consul.zip https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
- unzip consul.zip
- mkdir -p ~/bin
- mv consul ~/bin
before_script:
- make download-consul
- export PATH="~/bin:$PATH"

script: make test
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ NAME := $(notdir $(PROJECT))
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
VERSION := $(shell awk -F\" '/Version/ { print $$2; exit }' "${CURRENT_DIR}/version/version.go")

# Consul version to download for use in integration tests.
CONSUL_VERSION ?= 1.4.2
CONSUL_BIN_PATH ?= /usr/local/bin/consul

# Current system information
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
Expand Down Expand Up @@ -140,6 +144,13 @@ define make-docker-target
endef
$(foreach target,$(DOCKER_TARGETS),$(eval $(call make-docker-target,$(target))))

download-consul:
@curl -sLo \
consul.zip \
https://releases.hashicorp.com/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip
@unzip consul.zip
@mv consul ${CONSUL_BIN_PATH}

# test runs the test suite.
test:
@echo "==> Testing ${NAME}"
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2192,7 +2192,14 @@ $ make dev
This will compile the `consul-template` binary into `bin/consul-template` as
well as your `$GOPATH` and run the test suite.

If you want to run the tests, first [install consul locally](https://www.consul.io/docs/install/index.html), then:
If you want to run the tests, first install Consul locally by running:

```shell
# Consul will be installed in your $PATH (/usr/local/bin/consul)
$ sudo make download-consul
```

Now run the tests:

```shell
$ make test
Expand Down

0 comments on commit 37b8a94

Please sign in to comment.