Makefile 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. # Copyright 2020 Docker Compose CLI authors
  2. # Licensed under the Apache License, Version 2.0 (the "License");
  3. # you may not use this file except in compliance with the License.
  4. # You may obtain a copy of the License at
  5. # http://www.apache.org/licenses/LICENSE-2.0
  6. # Unless required by applicable law or agreed to in writing, software
  7. # distributed under the License is distributed on an "AS IS" BASIS,
  8. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. # See the License for the specific language governing permissions and
  10. # limitations under the License.
  11. export DOCKER_BUILDKIT=1
  12. UNAME_S := $(shell uname -s)
  13. ifeq ($(UNAME_S),Linux)
  14. MOBY_DOCKER=/usr/bin/docker
  15. endif
  16. ifeq ($(UNAME_S),Darwin)
  17. MOBY_DOCKER=/Applications/Docker.app/Contents/Resources/bin/docker
  18. endif
  19. BINARY_FOLDER=$(shell pwd)/bin
  20. GIT_TAG?=$(shell git describe --tags --match "v[0-9]*")
  21. TEST_FLAGS?=
  22. E2E_TEST?=
  23. ifeq ($(E2E_TEST),)
  24. else
  25. TEST_FLAGS=-run $(E2E_TEST)
  26. endif
  27. all: compose-plugin
  28. .PHONY: compose-plugin
  29. compose-plugin: ## Compile the compose cli-plugin
  30. @docker build . --target compose-plugin \
  31. --platform local \
  32. --build-arg BUILD_TAGS=e2e,kube \
  33. --build-arg GIT_TAG=$(GIT_TAG) \
  34. --output ./bin
  35. .PHONY: e2e-compose
  36. e2e-compose: ## Run End to end local tests. Set E2E_TEST=TestName to run a single test
  37. gotestsum $(TEST_FLAGS) ./pkg/e2e -- -count=1
  38. .PHONY: cross
  39. cross: ## Compile the CLI for linux, darwin and windows
  40. @docker build . --target cross \
  41. --build-arg BUILD_TAGS \
  42. --build-arg GIT_TAG=$(GIT_TAG) \
  43. --output ./bin \
  44. .PHONY: test
  45. test: ## Run unit tests
  46. @docker build --progress=plain . \
  47. --build-arg BUILD_TAGS=kube \
  48. --build-arg GIT_TAG=$(GIT_TAG) \
  49. --target test
  50. .PHONY: cache-clear
  51. cache-clear: ## Clear the builder cache
  52. @docker builder prune --force --filter type=exec.cachemount --filter=unused-for=24h
  53. .PHONY: lint
  54. lint: ## run linter(s)
  55. @docker build . \
  56. --build-arg BUILD_TAGS=kube,e2e \
  57. --build-arg GIT_TAG=$(GIT_TAG) \
  58. --target lint
  59. .PHONY: check-dependencies
  60. check-dependencies: ## check dependency updates
  61. go list -u -m -f '{{if not .Indirect}}{{if .Update}}{{.}}{{end}}{{end}}' all
  62. .PHONY: validate-headers
  63. validate-headers: ## Check license header for all files
  64. @docker build . --target check-license-headers
  65. .PHONY: go-mod-tidy
  66. go-mod-tidy: ## Run go mod tidy in a container and output resulting go.mod and go.sum
  67. @docker build . --target go-mod-tidy --output .
  68. .PHONY: validate-go-mod
  69. validate-go-mod: ## Validate go.mod and go.sum are up-to-date
  70. @docker build . --target check-go-mod
  71. validate: validate-go-mod validate-headers ## Validate sources
  72. pre-commit: validate check-dependencies lint compose-plugin test e2e-compose
  73. help: ## Show help
  74. @echo Please specify a build target. The choices are:
  75. @grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'