Skip to content

Commit 6d06c8b

Browse files
committed
Add kubebuilder installation for presubmit
1 parent fb096da commit 6d06c8b

File tree

5 files changed

+69
-2
lines changed

5 files changed

+69
-2
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: InstallDependencies
2+
description: 'Installs Go Downloads and installs Karpenter Dependencies'
3+
inputs:
4+
k8sVersion:
5+
description: Kubernetes version to use when installing the toolchain
6+
default: "1.24.x"
7+
runs:
8+
using: "composite"
9+
steps:
10+
- uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
11+
id: setup-go
12+
with:
13+
go-version-file: go.mod
14+
check-latest: true
15+
cache-dependency-path: "**/go.sum"
16+
# Root path permission workaround for caching https://github.com/actions/cache/issues/845#issuecomment-1252594999
17+
- run: sudo chown "$USER" /usr/local
18+
shell: bash
19+
- uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
20+
id: cache-toolchain
21+
with:
22+
path: |
23+
/usr/local/kubebuilder/bin
24+
~/go/bin
25+
# Added go version to compensate for this issue with govulncheck: https://github.com/golang/go/issues/65590. Could re-evaluate if this is necessary once the
26+
# upstream go issue is corrected and if this is causing too many cache misses.
27+
key: ${{ runner.os }}-${{ inputs.k8sVersion }}-${{ steps.setup-go.outputs.go-version }}-toolchain-cache-${{ hashFiles('hack/toolchain.sh') }}
28+
- if: ${{ steps.cache-toolchain.outputs.cache-hit != 'true' }}
29+
shell: bash
30+
run: K8S_VERSION=${{ inputs.k8sVersion }} make toolchain

.github/toolchain.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
K8S_VERSION="${K8S_VERSION:="1.31.x"}"
5+
KUBEBUILDER_ASSETS="/usr/local/kubebuilder/bin"
6+
7+
main() {
8+
kubebuilder
9+
}
10+
11+
kubebuilder() {
12+
if ! mkdir -p ${KUBEBUILDER_ASSETS}; then
13+
sudo mkdir -p ${KUBEBUILDER_ASSETS}
14+
sudo chown $(whoami) ${KUBEBUILDER_ASSETS}
15+
fi
16+
arch=$(go env GOARCH)
17+
ln -sf $(setup-envtest use -p path "${K8S_VERSION}" --arch="${arch}" --bin-dir="${KUBEBUILDER_ASSETS}")/* ${KUBEBUILDER_ASSETS}
18+
find $KUBEBUILDER_ASSETS
19+
20+
# Install latest binaries for 1.25.x (contains CEL fix)
21+
if [[ "${K8S_VERSION}" = "1.25.x" ]] && [[ "$OSTYPE" == "linux"* ]]; then
22+
for binary in 'kube-apiserver' 'kubectl'; do
23+
rm $KUBEBUILDER_ASSETS/$binary
24+
wget -P $KUBEBUILDER_ASSETS dl.k8s.io/v1.25.16/bin/linux/${arch}/${binary}
25+
chmod +x $KUBEBUILDER_ASSETS/$binary
26+
done
27+
fi
28+
}
29+
30+
main "$@"

.github/workflows/presubmit.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
steps:
1111
- uses: actions/checkout@v4
12+
- uses: ./.github/actions/install-deps
13+
with:
14+
k8sVersion: 1.31
1215
- run: make presubmit

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,8 @@ verify: ##
1414

1515
.PHONY: test
1616
test: ##
17-
go test ./...
17+
go test ./...
18+
19+
.PHONY: toolchain
20+
toolchain: ##
21+
./.github/toolchain.sh

singleton/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func Source() source.Source {
4040
}
4141

4242
func ChannelSource[T client.Object](ctx context.Context, objectChan <-chan watch.Event) source.Source {
43-
eventSource := make(chan event.GenericEvent, 1)
43+
eventSource := make(chan event.GenericEvent, 1000)
4444

4545
go func(ctx context.Context, objectChan <-chan watch.Event, eventSource chan event.GenericEvent) {
4646
for {

0 commit comments

Comments
 (0)