diff --git a/.circleci/config.yml b/.circleci/config.yml index 5c4ee762f..87dd82071 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -151,13 +151,14 @@ orbs: command: if [ ! -d vendor ]; then go mod vendor; fi - run: name: Generate k8s - command: make generate + command: | + make generate + [ "$(git ls-files -m |grep -c zz_generated)" -eq 0 ] # Create artifacts - persist_to_workspace: root: /home/circleci paths: - << parameters.operatorDir >>/build/_output - - << parameters.operatorDir >>/pkg/apis/db/v1alpha1/zz_generated.deepcopy.go - << parameters.operatorDir >>/vendor # Cache configuration - save_cache: @@ -165,7 +166,6 @@ orbs: key: << parameters.operatorName >>-generate-{{ .Branch }}-{{ checksum "go.sum" }} paths: - build/_output - - pkg/apis/db/v1alpha1/zz_generated.deepcopy.go - vendor # Build job, which build operator docker image (with operator-sdk build) @@ -191,7 +191,6 @@ orbs: root: /home/circleci paths: - << parameters.operatorDir >>/build/_output - - << parameters.operatorDir >>/pkg/apis/db/v1alpha1/zz_generated.deepcopy.go - << parameters.operatorDir >>/vendor # Deploy steps - deploy: @@ -209,7 +208,6 @@ orbs: key: << parameters.operatorName >>-build-{{ .Branch }}-{{ checksum "go.sum" }} paths: - build/_output - - pkg/apis/db/v1alpha1/zz_generated.deepcopy.go - vendor # Unit test job, will execute makefile 'unit-test-with-vendor' step @@ -300,7 +298,7 @@ orbs: -Dsonar.projectBaseDir=/home/circleci/<< parameters.operatorDir >> \ -Dsonar.sources=. \ -Dsonar.sources.inclusions="**/**.go" \ - -Dsonar.exclusions="**/*_test.go,**/vendor/**,**/sonar-scanner-3.3.0.1492-linux/**,**docs/**,**/**/zz_generated*" \ + -Dsonar.exclusions="**/*_test.go,**/vendor/**,**/sonar-scanner-3.3.0.1492-linux/**,**docs/**" \ -Dsonar.coverage.exclusions="**/vendor/**,**/test/**,**docs/**" \ -Dsonar.tests=. \ -Dsonar.language=go \ diff --git a/Makefile b/Makefile index e384144e8..b02c973e8 100644 --- a/Makefile +++ b/Makefile @@ -172,25 +172,31 @@ generate: #@TODO : `opetator-sdk generate openapĂ®` deprecated # Build casskop executable file in local go env .PHONY: build -build: - echo "Generate zzz-deepcopy objects" - operator-sdk version - operator-sdk generate k8s - operator-sdk generate openapi +build: generate echo "Build Cassandra Operator" operator-sdk build $(REPOSITORY):$(VERSION) --image-build-args "--build-arg https_proxy=$$https_proxy --build-arg http_proxy=$$http_proxy" ifdef PUSHLATEST docker tag $(REPOSITORY):$(VERSION) $(REPOSITORY):latest endif -#@TODO : `opetator-sdk generate openapĂ®` deprecated +#@TODO : `opetator-sdk generate openapi` deprecated # Run a shell into the development docker image docker-build: ## Build the Operator and it's Docker Image echo "Generate zzz-deepcopy objects" - docker run --rm -v $(PWD):$(WORKDIR) -v $(GOPATH)/pkg/mod:/go/pkg/mod -v $(shell go env GOCACHE):/root/.cache/go-build --env GO111MODULE=on --env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) $(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c 'operator-sdk generate k8s' - docker run --rm -v $(PWD):$(WORKDIR) -v $(GOPATH)/pkg/mod:/go/pkg/mod -v $(shell go env GOCACHE):/root/.cache/go-build --env GO111MODULE=on --env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) $(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c 'operator-sdk generate openapi' + docker run --rm -v $(PWD):$(WORKDIR) -v $(GOPATH)/pkg/mod:/go/pkg/mod \ + -v $(shell go env GOCACHE):/root/.cache/go-build --env GO111MODULE=on \ + --env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) \ + $(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c 'operator-sdk generate k8s' + docker run --rm -v $(PWD):$(WORKDIR) -v $(GOPATH)/pkg/mod:/go/pkg/mod \ + -v $(shell go env GOCACHE):/root/.cache/go-build --env GO111MODULE=on \ + --env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) \ + $(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c 'operator-sdk generate openapi' echo "Build Cassandra Operator. Using cache from "$(shell go env GOCACHE) - docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(PWD):$(WORKDIR) -v $(GOPATH)/pkg/mod:/go/pkg/mod -v $(shell go env GOCACHE):/root/.cache/go-build --env GO111MODULE=on --env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) $(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c 'operator-sdk build $(REPOSITORY):$(VERSION) --image-build-args "--build-arg https_proxy=$$https_proxy --build-arg http_proxy=$$http_proxy"' + docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $(PWD):$(WORKDIR) \ + -v $(GOPATH)/pkg/mod:/go/pkg/mod -v $(shell go env GOCACHE):/root/.cache/go-build \ + --env GO111MODULE=on --env https_proxy=$(https_proxy) --env http_proxy=$(http_proxy) \ + $(BUILD_IMAGE):$(OPERATOR_SDK_VERSION) /bin/bash -c 'operator-sdk build $(REPOSITORY):$(VERSION) \ + --image-build-args "--build-arg https_proxy=$$https_proxy --build-arg http_proxy=$$http_proxy"' ifdef PUSHLATEST docker tag $(REPOSITORY):$(VERSION) $(REPOSITORY):latest endif