Skip to content

Commit

Permalink
Add containerized options for tests in Makefile
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
mattjmcnaughton committed Aug 26, 2018
1 parent 4589ae2 commit 17151b9
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
DOCKER_REGISTRY ?= gcr.io
IMAGE_PREFIX ?= kubernetes-helm
DEV_IMAGE ?= golang:1.10
SHORT_NAME ?= tiller
SHORT_NAME_RUDDER ?= rudder
TARGETS ?= darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le linux/s390x windows/amd64
Expand Down Expand Up @@ -87,17 +88,39 @@ test: TESTFLAGS += -race -v
test: test-style
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
test-unit:
@echo
@echo "==> Running unit tests <=="
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
test-style:
@scripts/validate-go.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
protoc:
$(MAKE) -C _proto/ all
Expand Down
6 changes: 5 additions & 1 deletion docs/developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ This will build both Helm and Tiller. `make bootstrap` will attempt to
install certain tools if they are missing.

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`.

Expand Down Expand Up @@ -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
`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:

Expand Down

0 comments on commit 17151b9

Please sign in to comment.