Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,14 @@ jobs:
- name: Check out code into the Go module directory
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Install kubebuilder
- name: Install envtest binaries
run: |
curl -L -O "https://github.com/kubernetes-sigs/kubebuilder/releases/download/v${KUBEBUILDER_VERSION}/kubebuilder_$(go env GOOS)_$(go env GOARCH)" && \
curl -L -O "https://dl.k8s.io/v${KUBERNETES_VERSION}/kubernetes-server-$(go env GOOS)-$(go env GOARCH).tar.gz" && \
curl -L -O "https://dl.k8s.io/v${KUBERNETES_VERSION}/kubernetes-client-$(go env GOOS)-$(go env GOARCH).tar.gz" && \
curl -L -O "https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-$(go env GOOS)-$(go env GOARCH).tar.gz" && \
tar -zxvf kubernetes-server-$(go env GOOS)-$(go env GOARCH).tar.gz && \
tar -zxvf kubernetes-client-$(go env GOOS)-$(go env GOARCH).tar.gz && \
tar -zxvf etcd-v${ETCD_VERSION}-$(go env GOOS)-$(go env GOARCH).tar.gz && \
chmod +x kubebuilder_$(go env GOOS)_$(go env GOARCH) && \
chmod +x kubernetes/server/bin/kube-apiserver && \
chmod +x kubernetes/client/bin/kubectl && \
chmod +x etcd-v${ETCD_VERSION}-$(go env GOOS)-$(go env GOARCH)/etcd && \
sudo mkdir -p /usr/local/kubebuilder/bin && \
sudo mv kubebuilder_$(go env GOOS)_$(go env GOARCH) /usr/local/kubebuilder/bin/kubebuilder && \
sudo mv kubernetes/server/bin/kube-apiserver /usr/local/kubebuilder/bin/kube-apiserver && \
sudo mv kubernetes/server/bin/kubectl /usr/local/kubebuilder/bin/kubectl && \
sudo mv etcd-v${ETCD_VERSION}-$(go env GOOS)-$(go env GOARCH)/etcd /usr/local/kubebuilder/bin/etcd
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

Copilot AI Apr 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go install ...@latest makes the workflow non-reproducible and can unexpectedly change behavior (or break) when a new setup-envtest release is published. Pin setup-envtest to a specific version (or commit) so CI runs are deterministic and easier to audit.

Suggested change
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@v0.20.2

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree here - it should not be latest.

mkdir -p "${HOME}/kubebuilder/bin"
"$HOME/go/bin/setup-envtest" use "${KUBERNETES_VERSION}" --bin-dir "${HOME}/kubebuilder/bin" -p path

Copilot AI Apr 9, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The step assumes the installed binary is at $HOME/go/bin/setup-envtest, but go install can write to a different location when GOPATH/GOBIN are configured differently. Consider invoking setup-envtest via $(go env GOPATH)/bin/setup-envtest or just setup-envtest from PATH to make the workflow more robust across runners.

Suggested change
"$HOME/go/bin/setup-envtest" use "${KUBERNETES_VERSION}" --bin-dir "${HOME}/kubebuilder/bin" -p path
"$(go env GOPATH)/bin/setup-envtest" use "${KUBERNETES_VERSION}" --bin-dir "${HOME}/kubebuilder/bin" -p path

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

echo "KUBEBUILDER_ASSETS=${HOME}/kubebuilder/bin" >> "$GITHUB_ENV"
Comment on lines +64 to +65

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Export setup-envtest output path as KUBEBUILDER_ASSETS

setup-envtest use ... -p path prints the version-specific directory that actually contains kube-apiserver, etcd, and kubectl (the tool’s README explicitly says to use -p path to get the directory). This step discards that output and sets KUBEBUILDER_ASSETS to ${HOME}/kubebuilder/bin, which is only the store root; envtest then resolves binaries as ${KUBEBUILDER_ASSETS}/<name> and will not search nested k8s/<version-platform>/ folders, so the make test job will fail when starting envtest.

Useful? React with 👍 / 👎.

env:
KUBEBUILDER_VERSION: 3.9.0
KUBERNETES_VERSION: 1.26.1
ETCD_VERSION: 3.5.7
KUBERNETES_VERSION: 1.26.x

- name: Unit test
run: make test
Expand Down
Loading