-
Notifications
You must be signed in to change notification settings - Fork 59
ci: remove kubebuilder dependency #279
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,30 +1,16 @@ | ||
| # Build the manager binary | ||
| FROM golang:1.19 as builder | ||
| FROM golang:1.19-bullseye as builder | ||
|
|
||
| RUN apt-get update &&\ | ||
| apt-get install -y apt-utils make | ||
| ARG KUSTOMIZE_VERSION | ||
|
|
||
| # Install kubebuilder | ||
| WORKDIR /scratch | ||
| ENV version=2.3.2 | ||
| ENV arch=amd64 | ||
| RUN curl -L -O "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${version}/kubebuilder_${version}_linux_${arch}.tar.gz" &&\ | ||
| tar -zxvf kubebuilder_${version}_linux_${arch}.tar.gz &&\ | ||
| mv kubebuilder_${version}_linux_${arch} /usr/local/kubebuilder &&\ | ||
| rm kubebuilder_${version}_linux_${arch}.tar.gz | ||
| ENV PATH=$PATH:/usr/local/kubebuilder/bin:/usr/bin | ||
| ARG TARGETARCH | ||
|
|
||
| # Install kustomize | ||
| ENV version=3.8.9 | ||
| ENV arch=amd64 | ||
| ENV tar_name=kustomize_v${version}_linux_${arch}.tar.gz | ||
| RUN curl -LO "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${version}/${tar_name}" &&\ | ||
| tar -xf ${tar_name} &&\ | ||
| mv ./kustomize /usr/bin/kustomize &&\ | ||
| chmod u+x /usr/bin/kustomize | ||
| RUN apt-get update && \ | ||
| apt-get install -y make | ||
|
|
||
| # Copy in the go src | ||
| WORKDIR /go/src/github.com/open-policy-agent/frameworks/constraint | ||
| COPY . . | ||
| # Install kustomize | ||
| RUN curl -L -O "https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_${TARGETARCH}.tar.gz" &&\ | ||
| tar -zxvf kustomize_v${KUSTOMIZE_VERSION}_linux_${TARGETARCH}.tar.gz &&\ | ||
| chmod +x kustomize &&\ | ||
| mv kustomize /usr/local/bin | ||
|
|
||
| ENTRYPOINT ["make", "docker-internal-test"] | ||
| WORKDIR /app |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,8 @@ | ||
| # When updating this, make sure to update the corresponding action in | ||
| # workflow.yaml | ||
| GOLANGCI_LINT_VERSION := v1.45.2 | ||
| GOLANGCI_LINT_VERSION ?= 1.50.0 | ||
| KUSTOMIZE_VERSION ?= 3.8.9 | ||
| KUBERNETES_VERSION ?= 1.26.0 | ||
|
|
||
| # Detects the location of the user golangci-lint cache. | ||
| GOLANGCI_LINT_CACHE := $(shell pwd)/.tmp/golangci-lint | ||
|
|
@@ -18,19 +20,15 @@ all: lint test | |
|
|
||
| # Run tests | ||
| # TODO: Once https://github.com/kubernetes/kubernetes/issues/101567 is fixed, add `generate` back as a dependency target | ||
| native-test: gen-dependencies manifests | ||
| go test ./pkg/... -coverprofile cover.out | ||
|
|
||
| # Docker internal test | ||
| docker-internal-test: | ||
| make native-test | ||
| # The remote driver has some unimplemented functions | ||
| # which result in a panic during testing. | ||
| # ./tests/test_remote_driver.sh | ||
| native-test: gen-dependencies manifests envtest | ||
| KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(KUBERNETES_VERSION) --bin-dir $(LOCALBIN) -p path)" \ | ||
| GO111MODULE=on \ | ||
| go test -mod vendor ./pkg/... -race -bench . -coverprofile cover.out | ||
|
|
||
| # Hook to run docker tests | ||
| test: | ||
| docker build . -t constraint-test && docker run constraint-test | ||
| .PHONY: test | ||
| test: __test-image | ||
| docker run --rm -v $(shell pwd):/app constraint-test make native-test | ||
|
|
||
| # Install CRDs into a cluster | ||
| install: manifests | ||
|
|
@@ -60,7 +58,7 @@ manifests: | |
| lint: | ||
| docker run --rm -v $(shell pwd):/app \ | ||
| -v ${GOLANGCI_LINT_CACHE}:/root/.cache/golangci-lint \ | ||
| -w /app golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine \ | ||
| -w /app golangci/golangci-lint:v${GOLANGCI_LINT_VERSION}-alpine \ | ||
| golangci-lint run -v | ||
|
|
||
| # Generate code | ||
|
|
@@ -109,3 +107,22 @@ generate-defaults: constraint-template-string-constant | |
| vendor: | ||
| go mod vendor | ||
| go mod tidy | ||
|
|
||
| .PHONY: __test-image | ||
| __test-image: | ||
| docker buildx build . \ | ||
| -t constraint-test \ | ||
| --load \ | ||
| --build-arg KUSTOMIZE_VERSION=$(KUSTOMIZE_VERSION) | ||
|
|
||
| ## Location to install dependencies to | ||
| LOCALBIN ?= $(shell pwd)/bin | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a user runs this in their source code directory, this will create a /bin folder. Do we want to put this in an easy-to-clean subdir (.output or similar)? Is the /bin directory part of .gitignore?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like bin would be ignored, though I'd personally consider putting this in a .output directory to make it easy to wipe everything and start from zero.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @maxsmythe |
||
| $(LOCALBIN): | ||
| mkdir -p $(LOCALBIN) | ||
|
|
||
| ENVTEST ?= $(LOCALBIN)/setup-envtest | ||
|
|
||
| .PHONY: envtest | ||
| envtest: $(ENVTEST) ## Download envtest-setup locally if necessary. | ||
| $(ENVTEST): $(LOCALBIN) | ||
| test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.0.0-20230118154835-9241bceb3098 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, did you notice an increase in timeouts?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, i added
-race -benchto align with GK which increased the timeouts (mostly due to benchmarks)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the reason we added is to make sure to run benchmarks often so we don't break them