github.com/docker/compose-on-kubernetes@v0.5.0/Makefile (about) 1 include common.mk 2 3 BINARIES = bin/compose-controller bin/api-server bin/installer bin/reconciliation-recorder bin/e2e_benchmark 4 TEST_PACKAGES := ${shell go list ./internal/... ./cmd/... ./api/... ./install/... | grep -v "_generated" | sed 's,github.com/docker/compose-on-kubernetes/,,' | uniq} 5 # Number of tests we expect to be skipped in e2e suite. Rule will fail if mismatch. 6 # We currently expect the two volume tests to fail on cluster without a default 7 # dynamic volume provisioner ('kubectl get storageclass' to check). 8 E2E_EXPECTED_SKIP ?= 2 9 10 VERBOSE_GO := 11 ifeq ($(VERBOSE),true) 12 VERBOSE_GO := -v 13 endif 14 15 EXEC_EXT := 16 ifeq ($(OS),Windows_NT) 17 EXEC_EXT := .exe 18 endif 19 20 LDFLAGS := "-s -w \ 21 -X ${PKG_NAME}/internal.GitCommit=${GITCOMMIT} \ 22 -X ${PKG_NAME}/internal.BuildTime=${BUILDTIME} \ 23 -X ${PKG_NAME}/internal.Version=${VERSION} \ 24 -X ${PKG_NAME}/install.imageRepoPrefix=${IMAGE_REPO_PREFIX}" 25 26 ifeq ($(DEBUG),true) 27 GOBUILD_FLAGS := -gcflags "all=-N -l" 28 LDFLAGS := "\ 29 -X ${PKG_NAME}/internal.GitCommit=${GITCOMMIT} \ 30 -X ${PKG_NAME}/internal.BuildTime=${BUILDTIME} \ 31 -X ${PKG_NAME}/internal.Version=${VERSION} \ 32 -X ${PKG_NAME}/install.imageRepoPrefix=${IMAGE_REPO_PREFIX}" 33 endif 34 35 .PHONY: all binaries check test e2e vendor run clean validate build-validate-image install uninstall e2e-binary 36 .DEFAULT: all 37 38 all: binaries test 39 40 FORCE: 41 @test $$(go list) = "${PKG_NAME}" || \ 42 (echo "👹 Please correctly set up your Go build environment. This project must be located at <GOPATH>/src/${PKG_NAME}" && false) 43 44 clean: ## clean the binaries 45 rm -Rf ./bin 46 47 bin/installer: cmd/installer FORCE 48 @echo "🌟 $@" 49 @CGO_ENABLED=0 go build $(VERBOSE_GO) $(GOBUILD_FLAGS) -ldflags=$(LDFLAGS) -o $@$(EXEC_EXT) ./$< 50 51 bin/%: cmd/% FORCE 52 @echo "🌟 $@" 53 @go build $(VERBOSE_GO) $(GOBUILD_FLAGS) -ldflags=$(LDFLAGS) -o $@$(EXEC_EXT) ./$< 54 55 e2e-binary: ## make the end to end test binary 56 @echo " $@" 57 @go test -c ./e2e $(VERBOSE_GO) -ldflags=$(LDFLAGS) -o e2e/e2e.test$(EXEC_EXT) 58 59 bin/%.test: cmd/% FORCE 60 @echo "🌟 $@" 61 @go test -c -covermode=atomic -coverpkg ${shell go list ./internal/... ./api/... ./install/... ./cmd/api-server/... ./cmd/compose-controller/... | tr -s '\n' ','} $(VERBOSE_GO) -ldflags=$(LDFLAGS) -o $@ ./$< 62 63 binaries: $(BINARIES) $(addsuffix .test,$(BINARIES)) ## build binaries 64 65 check test: $(addsuffix .check,$(TEST_PACKAGES)) ## run tests 66 cat $(shell sh -c "find -name go-coverage.txt") > coverage.txt 67 rm $(shell sh -c "find -name go-coverage.txt") 68 69 %.check: 70 @echo "🌡 Check $*" 71 @go test -ldflags=$(LDFLAGS) $(VERBOSE_GO) -cover -covermode=atomic -race $(TESTFLAGS) -test.short -test.coverprofile="./$*/go-coverage.txt" "./$*" 72 73 check-licenses: ## Check the licenses for our dependencies 74 go get -u github.com/frapposelli/wwhrd 75 $(GOPATH)/bin/wwhrd check 76 77 install-ginkgo: 78 GO111MODULE=on go install github.com/onsi/ginkgo/ginkgo@v1.16.5 79 go get -u github.com/onsi/gomega/... 80 81 e2e: ## Run the e2e tests 82 IMAGE_REPO_PREFIX=$(IMAGE_REPO_PREFIX) ginkgo -v -p e2e/ -- -tag "$(TAG)" 2>&1 | tee e2e-test-output.txt 83 grep SUCCESS e2e-test-output.txt | grep -q "$(E2E_EXPECTED_SKIP) Skipped" 84 85 e2e-kind: ## Run the e2e tests 86 KUBECONFIG="$(shell kind get kubeconfig-path --name="compose-on-kube")" IMAGE_REPO_PREFIX=$(IMAGE_REPO_PREFIX) ginkgo -v -p $(GINKGO_FLAGS) e2e/ -- -tag "$(TAG)" 2>&1 | tee e2e-test-output.txt 87 grep SUCCESS e2e-test-output.txt | grep -q "$(E2E_EXPECTED_SKIP) Skipped" 88 89 e2e-kind-circleci: 90 docker rm compose-on-kube-e2e || echo "no existing compose-on-kube e2e container" 91 docker create --name compose-on-kube-e2e -e IMAGE_REPO_PREFIX=$(IMAGE_REPO_PREFIX) -e KUBECONFIG=/kind-config --network=host ${IMAGE_REPO_PREFIX}e2e-tests:${TAG} -ginkgo.v -tag "$(TAG)" 92 docker cp $(shell kind get kubeconfig-path --name="compose-on-kube") compose-on-kube-e2e:/kind-config 93 docker start -a -i compose-on-kube-e2e 94 docker cp compose-on-kube-e2e:/e2e ./e2e-coverage 95 96 e2e-benchmark-kind-circleci: 97 docker rm compose-on-kube-e2e-benchmark || echo "no existing compose-on-kube e2e benchmark container" 98 docker create --name compose-on-kube-e2e-benchmark -e IMAGE_REPO_PREFIX=$(IMAGE_REPO_PREFIX) -e TAG=$(TAG) -e KUBECONFIG=/kind-config --network=host ${IMAGE_REPO_PREFIX}e2e-benchmark:${TAG} --logs-namespace=benchmark -f report --total-stacks 50 --max-duration 7m 99 docker cp $(shell kind get kubeconfig-path --name="compose-on-kube") compose-on-kube-e2e-benchmark:/kind-config 100 docker start -a -i compose-on-kube-e2e-benchmark 101 102 e2e-kind-pods-info: 103 kubectl --kubeconfig=$(shell kind get kubeconfig-path --name="compose-on-kube") get pods --all-namespaces 104 105 e2e-no-provisioning: e2e-binary ## run the e2e tests on an already provisionned cluster 106 ginkgo -v -p e2e/e2e.test -- --skip-provisioning $(TEST_ARGS) 2>&1 | tee e2e-test-output.txt 107 grep SUCCESS e2e-test-output.txt | grep -q "$(E2E_EXPECTED_SKIP) Skipped" 108 109 validate-vendor: ## validate vendoring 110 ./scripts/validate-vendor 111 112 vendor: ## do vendoring actions 113 rm -rf ./vendor 114 ./scripts/dep-refresh 115 116 help: ## this help 117 @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort 118 119 openapi: 120 openapi-gen -i github.com/docker/compose-on-kubernetes/api/compose/v1beta1,github.com/docker/compose-on-kubernetes/api/compose/v1beta2,github.com/docker/compose-on-kubernetes/api/compose/v1alpha3,github.com/docker/compose-on-kubernetes/api/compose/impersonation,k8s.io/apimachinery/pkg/apis/meta/v1,k8s.io/apimachinery/pkg/version,k8s.io/apimachinery/pkg/runtime -p github.com/docker/compose-on-kubernetes/api/openapi