Add containerized options for tests in Makefile

Add an option to run the `test-unit`, `test-style`, and `test`
steps from the `Makefile` insides of a docker container. Doing so
isolates this component of helm development from any other aspect of
your global go environment.

These commands all have the name `docker-*`. Long term, there may
be reproducibility benefits to running all of the Make steps in a
container by default, in which case `containerized-test-unit` could
become `test-unit`.
pull/4172/head
mattjmcnaughton 7 years ago
parent 4589ae2c45
commit 17151b99ea

@ -1,5 +1,6 @@
DOCKER_REGISTRY ?= gcr.io DOCKER_REGISTRY ?= gcr.io
IMAGE_PREFIX ?= kubernetes-helm IMAGE_PREFIX ?= kubernetes-helm
DEV_IMAGE ?= golang:1.10
SHORT_NAME ?= tiller SHORT_NAME ?= tiller
SHORT_NAME_RUDDER ?= rudder SHORT_NAME_RUDDER ?= rudder
TARGETS ?= darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le linux/s390x windows/amd64 TARGETS ?= darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le linux/s390x windows/amd64
@ -87,17 +88,39 @@ test: TESTFLAGS += -race -v
test: test-style test: test-style
test: test-unit test: test-unit
.PHONY: docker-test
docker-test: docker-binary
docker-test: TESTFLAGS += -race -v
docker-test: docker-test-style
docker-test: docker-test-unit
.PHONY: test-unit .PHONY: test-unit
test-unit: test-unit:
@echo @echo
@echo "==> Running unit tests <==" @echo "==> Running unit tests <=="
HELM_HOME=/no/such/dir $(GO) test $(GOFLAGS) -run $(TESTS) $(PKG) $(TESTFLAGS) HELM_HOME=/no/such/dir $(GO) test $(GOFLAGS) -run $(TESTS) $(PKG) $(TESTFLAGS)
.PHONY: docker-test-unit
docker-test-unit: check-docker
docker run \
-v $(shell pwd):/go/src/k8s.io/helm \
-w /go/src/k8s.io/helm \
$(DEV_IMAGE) \
bash -c "HELM_HOME=/no/such/dir go test $(GOFLAGS) -run $(TESTS) $(PKG) $(TESTFLAGS)"
.PHONY: test-style .PHONY: test-style
test-style: test-style:
@scripts/validate-go.sh @scripts/validate-go.sh
@scripts/validate-license.sh @scripts/validate-license.sh
.PHONY: docker-test-style
docker-test-style: check-docker
docker run \
-v $(CURDIR):/go/src/k8s.io/helm \
-w /go/src/k8s.io/helm \
$(DEV_IMAGE) \
bash -c "scripts/validate-go.sh && scripts/validate-license.sh"
.PHONY: protoc .PHONY: protoc
protoc: protoc:
$(MAKE) -C _proto/ all $(MAKE) -C _proto/ all

@ -27,7 +27,8 @@ This will build both Helm and Tiller. `make bootstrap` will attempt to
install certain tools if they are missing. install certain tools if they are missing.
To run all the tests (without running the tests for `vendor/`), run To run all the tests (without running the tests for `vendor/`), run
`make test`. `make test`. To run all tests in a containerized environment, run `make
docker-test`.
To run Helm and Tiller locally, you can run `bin/helm` or `bin/tiller`. To run Helm and Tiller locally, you can run `bin/helm` or `bin/tiller`.
@ -209,6 +210,9 @@ We follow the Go coding style standards very closely. Typically, running
We also typically follow the conventions recommended by `go lint` and We also typically follow the conventions recommended by `go lint` and
`gometalinter`. Run `make test-style` to test the style conformance. `gometalinter`. Run `make test-style` to test the style conformance.
If you do not want to install all the linters from `gometalinter` into your
global Go environment, you can run `make docker-test-style` which will
run the same tests, but isolated within a docker container.
Read more: Read more:

Loading…
Cancel
Save