<commit_before>HUB :=
GITHUB_ORG := habitat-sh
DOCKER_ORG := habitat
IMAGE := $(if $(HUB),$(HUB)/)$(DOCKER_ORG)/habitat-operator
BIN_PATH := habitat-operator
TAG := $(shell git describe --tags --always)
TESTIMAGE :=
SUDO :=

build:
	go build -i github.com/$(GITHUB_ORG)/habitat-operator/cmd/habitat-operator

linux:
	# Compile statically linked binary for linux.
	GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s" -o $(BIN_PATH) github.com/$(GITHUB_ORG)/habitat-operator/cmd/habitat-operator

image: linux
	$(SUDO) docker build -t "$(IMAGE):$(TAG)" .

test:
	go test $(shell go list ./... | grep -v /vendor/ | grep -v /test/)

# requires minikube or any kubernetes cluster to be running
e2e:
	$(eval IP := $(shell kubectl config view --output=jsonpath='{.clusters[0].cluster.server}' --minify | grep --only-matching '[0-9.]\+' | head --lines 1))
	$(eval KUBECONFIG_PATH := $(shell mktemp --tmpdir operator-e2e.XXXXXXX))
	kubectl config view --minify --flatten > $(KUBECONFIG_PATH)
	@if test 'x$(TESTIMAGE)' = 'x'; then echo "TESTIMAGE must be passed."; exit 1; fi
	go test -v ./test/e2e/... --image "$(TESTIMAGE)" --kubeconfig $(KUBECONFIG_PATH) --ip "$(IP)"

clean-test:
	-kubectl delete namespace testing-v1beta1
	-kubectl delete clusterrolebinding habitat-operator-v1beta1
	-kubectl delete clusterrole habitat-operator-v1beta1

update-version:
	find examples -name "*.yml" -type f \
		-exec sed -i.bak \
		-e "s/habitat-operator:.*/habitat-operator:v$$(cat VERSION)/g" \
		'{}' \;
	find helm -name "*.yaml" -type f \
		-exec sed -i.bak \
		-e "s/tag:.*/tag: v$$(cat VERSION)/g" \
		-e "s/version:.*/version: $$(cat VERSION)/g" \
		'{}' \;
	find examples helm -regex '.*\.ya?ml.bak' -type f \
		-exec rm '{}' \;
	sed \
		-i.bak \
		-e 's/\(e\.g `v\).*\(`\)/\1'"$$(cat VERSION)"'\2/' \
		helm/habitat-operator/README.md
	rm -f helm/habitat-operator/README.md.bak
	sed \
		-i.bak \
		-e "s/\(habitat-operator:v\).*/\1$$(cat VERSION)/g" \
		test/e2e/v1beta1/resources/operator/deployment.yml
	rm -f test/e2e/v1beta1/resources/operator/deployment.yml.bak
	sed \
		-i.bak \
		-e 's/\(`\*: cut \)[.[:digit:]]*\( release`\)/\1'"$$(cat VERSION)"'\2/' \
		doc/release-process.md
	rm -f doc/release-process.md.bak

codegen:
	CODEGEN_PKG=../../../k8s.io/code-generator hack/update-codegen.sh

.PHONY: build test linux image e2e clean-test update-version<commit_msg>makefile: add clean-test as a pre-requisite to e2e<commit_after>HUB :=
GITHUB_ORG := habitat-sh
DOCKER_ORG := habitat
IMAGE := $(if $(HUB),$(HUB)/)$(DOCKER_ORG)/habitat-operator
BIN_PATH := habitat-operator
TAG := $(shell git describe --tags --always)
TESTIMAGE :=
SUDO :=

.PHONY: build
build:
	go build -i github.com/$(GITHUB_ORG)/habitat-operator/cmd/habitat-operator

.PHONY: linux
linux:
	# Compile statically linked binary for linux.
	GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s" -o $(BIN_PATH) github.com/$(GITHUB_ORG)/habitat-operator/cmd/habitat-operator

.PHONY: image
image: linux
	$(SUDO) docker build -t "$(IMAGE):$(TAG)" .

.PHONY: test
test:
	go test $(shell go list ./... | grep -v /vendor/ | grep -v /test/)

# requires minikube or any kubernetes cluster to be running
.PHONY: e2e
e2e: clean-test
	$(eval IP := $(shell kubectl config view --output=jsonpath='{.clusters[0].cluster.server}' --minify | grep --only-matching '[0-9.]\+' | head --lines 1))
	$(eval KUBECONFIG_PATH := $(shell mktemp --tmpdir operator-e2e.XXXXXXX))
	kubectl config view --minify --flatten > $(KUBECONFIG_PATH)
	@if test 'x$(TESTIMAGE)' = 'x'; then echo "TESTIMAGE must be passed."; exit 1; fi
	go test -v ./test/e2e/... --image "$(TESTIMAGE)" --kubeconfig $(KUBECONFIG_PATH) --ip "$(IP)"

.PHONY: clean-test
clean-test:
	-kubectl delete namespace testing-v1beta1
	-kubectl delete clusterrolebinding habitat-operator-v1beta1
	-kubectl delete clusterrole habitat-operator-v1beta1

.PHONY: update-version
update-version:
	find examples -name "*.yml" -type f \
		-exec sed -i.bak \
		-e "s/habitat-operator:.*/habitat-operator:v$$(cat VERSION)/g" \
		'{}' \;
	find helm -name "*.yaml" -type f \
		-exec sed -i.bak \
		-e "s/tag:.*/tag: v$$(cat VERSION)/g" \
		-e "s/version:.*/version: $$(cat VERSION)/g" \
		'{}' \;
	find examples helm -regex '.*\.ya?ml.bak' -type f \
		-exec rm '{}' \;
	sed \
		-i.bak \
		-e 's/\(e\.g `v\).*\(`\)/\1'"$$(cat VERSION)"'\2/' \
		helm/habitat-operator/README.md
	rm -f helm/habitat-operator/README.md.bak
	sed \
		-i.bak \
		-e "s/\(habitat-operator:v\).*/\1$$(cat VERSION)/g" \
		test/e2e/v1beta1/resources/operator/deployment.yml
	rm -f test/e2e/v1beta1/resources/operator/deployment.yml.bak
	sed \
		-i.bak \
		-e 's/\(`\*: cut \)[.[:digit:]]*\( release`\)/\1'"$$(cat VERSION)"'\2/' \
		doc/release-process.md
	rm -f doc/release-process.md.bak

.PHONY: codegen
codegen:
	CODEGEN_PKG=../../../k8s.io/code-generator hack/update-codegen.sh

{'fraction_non_alphanumeric': 0.20181593066446554, 'fraction_numerical': 0.012587701196863392, 'mean_word_length': 3.270484581497797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '149562', 'n_tokens_mistral': 2041, 'n_tokens_neox': 1973, 'n_words': 437}