Skip to content

Commit

Permalink
Fix-312-Run Test on CI, Controller Gen Version Update (#319)
Browse files Browse the repository at this point in the history
* update fixes

* add more tests

* fix test kubebuilder

* seperate build

* revert build

Co-authored-by: AdheipSingh <[email protected]>
  • Loading branch information
AdheipSingh and AdheipSingh authored Nov 26, 2022
1 parent 84405e0 commit c322fbe
Show file tree
Hide file tree
Showing 5 changed files with 6,043 additions and 164 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,15 @@ on:

jobs:

build:

tests:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Run Kubebuilder smoke and unit tests
run: make test
- name: Run helm lint
run: make lint
- name: Run helm template
run: make template
- name: Build the Docker image
run: docker build . -t druidio/druid-operator:$(date +%s)
31 changes: 1 addition & 30 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,39 +1,10 @@
# Build the manager binary
FROM golang:1.17 as builder
FROM golang:1.19 as builder

WORKDIR /workspace

ARG K8S_VERSION=1.19.2
ARG KUBEBUILDER_VERSION=2.3.1
ARG HELM_VERSION=3.7.0

# Install Kubebuilder
ARG OS_ARCH=amd64
RUN curl -L -O "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${KUBEBUILDER_VERSION}/kubebuilder_${KUBEBUILDER_VERSION}_linux_${OS_ARCH}.tar.gz"
RUN tar -zxvf kubebuilder_${KUBEBUILDER_VERSION}_linux_${OS_ARCH}.tar.gz
RUN mv kubebuilder_${KUBEBUILDER_VERSION}_linux_${OS_ARCH} kubebuilder && mv kubebuilder /usr/local/
RUN export PATH=$PATH:/usr/local/kubebuilder/bin

# hack to update kubeapi-server to 1.19 version
RUN curl -sSLo envtest-bins.tar.gz "https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-${K8S_VERSION}-$(go env GOOS)-$(go env GOARCH).tar.gz"
RUN tar -xzvf envtest-bins.tar.gz
RUN rm -rf /usr/local/kubebuilder/bin/kube_apiserver
RUN mv kubebuilder/bin/kube-apiserver /usr/local/kubebuilder/bin

# Install helm
RUN curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
RUN chmod 700 get_helm.sh
RUN ./get_helm.sh


COPY . .

# Build
RUN make lint && make template
RUN go mod download
RUN go fmt ./...
RUN go vet ./...
RUN go test ./...
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go

# Use distroless as minimal base image to package the manager binary
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ help: ## Display this help.
.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=deploy/crds
$(CONTROLLER_GEN) crd paths="./..." output:crd:artifacts:config=chart/templates/crds/

.PHONY: generate
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
Expand Down
Loading

0 comments on commit c322fbe

Please sign in to comment.