mirror of https://github.com/docker/cli.git
Merge pull request #1558 from ijc/build-tweaks
Add a `fmt` build target and make use of a go build cache.
This commit is contained in:
commit
298c423b57
4
Makefile
4
Makefile
|
@ -21,6 +21,10 @@ test: test-unit ## run tests
|
||||||
test-coverage: ## run test coverage
|
test-coverage: ## run test coverage
|
||||||
./scripts/test/unit-with-coverage $(shell go list ./... | grep -vE '/vendor/|/e2e/')
|
./scripts/test/unit-with-coverage $(shell go list ./... | grep -vE '/vendor/|/e2e/')
|
||||||
|
|
||||||
|
.PHONY: fmt
|
||||||
|
fmt:
|
||||||
|
go list -f {{.Dir}} ./... | xargs gofmt -w -s -d
|
||||||
|
|
||||||
.PHONY: lint
|
.PHONY: lint
|
||||||
lint: ## run all the lint tools
|
lint: ## run all the lint tools
|
||||||
gometalinter --config gometalinter.json ./...
|
gometalinter --config gometalinter.json ./...
|
||||||
|
|
|
@ -10,7 +10,12 @@ LINTER_IMAGE_NAME = docker-cli-lint$(IMAGE_TAG)
|
||||||
CROSS_IMAGE_NAME = docker-cli-cross$(IMAGE_TAG)
|
CROSS_IMAGE_NAME = docker-cli-cross$(IMAGE_TAG)
|
||||||
VALIDATE_IMAGE_NAME = docker-cli-shell-validate$(IMAGE_TAG)
|
VALIDATE_IMAGE_NAME = docker-cli-shell-validate$(IMAGE_TAG)
|
||||||
E2E_IMAGE_NAME = docker-cli-e2e$(IMAGE_TAG)
|
E2E_IMAGE_NAME = docker-cli-e2e$(IMAGE_TAG)
|
||||||
|
GO_BUILD_CACHE ?= y
|
||||||
MOUNTS = -v "$(CURDIR)":/go/src/github.com/docker/cli
|
MOUNTS = -v "$(CURDIR)":/go/src/github.com/docker/cli
|
||||||
|
CACHE_VOLUME_NAME := docker-cli-dev-cache
|
||||||
|
ifeq ($(GO_BUILD_CACHE),y)
|
||||||
|
MOUNTS += -v "$(CACHE_VOLUME_NAME):/root/.cache/go-build"
|
||||||
|
endif
|
||||||
VERSION = $(shell cat VERSION)
|
VERSION = $(shell cat VERSION)
|
||||||
ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT -e PLATFORM
|
ENVVARS = -e VERSION=$(VERSION) -e GITCOMMIT -e PLATFORM
|
||||||
|
|
||||||
|
@ -54,6 +59,7 @@ build: binary ## alias for binary
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: build_docker_image ## clean build artifacts
|
clean: build_docker_image ## clean build artifacts
|
||||||
docker run --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make clean
|
docker run --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make clean
|
||||||
|
docker volume rm -f $(CACHE_VOLUME_NAME)
|
||||||
|
|
||||||
.PHONY: test-unit
|
.PHONY: test-unit
|
||||||
test-unit: build_docker_image # run unit tests (using go test)
|
test-unit: build_docker_image # run unit tests (using go test)
|
||||||
|
@ -86,6 +92,10 @@ shell: dev ## alias for dev
|
||||||
lint: build_linter_image ## run linters
|
lint: build_linter_image ## run linters
|
||||||
docker run -ti $(ENVVARS) $(MOUNTS) $(LINTER_IMAGE_NAME)
|
docker run -ti $(ENVVARS) $(MOUNTS) $(LINTER_IMAGE_NAME)
|
||||||
|
|
||||||
|
.PHONY: fmt
|
||||||
|
fmt:
|
||||||
|
docker run --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make fmt
|
||||||
|
|
||||||
.PHONY: vendor
|
.PHONY: vendor
|
||||||
vendor: build_docker_image vendor.conf ## download dependencies (vendor/) listed in vendor.conf
|
vendor: build_docker_image vendor.conf ## download dependencies (vendor/) listed in vendor.conf
|
||||||
docker run -ti --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make vendor
|
docker run -ti --rm $(ENVVARS) $(MOUNTS) $(DEV_DOCKER_IMAGE_NAME) make vendor
|
||||||
|
|
Loading…
Reference in New Issue