Skip to content

Commit 50db68f

Browse files
committed
Cache tool binaries in CI
1 parent d2c8e4c commit 50db68f

File tree

4 files changed

+42
-4
lines changed

4 files changed

+42
-4
lines changed

.github/workflows/continuous-integration.yaml

+18
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ jobs:
2323
with:
2424
go-version: "~1.21.1"
2525

26+
- name: Cache tools
27+
uses: actions/cache@v4
28+
with:
29+
path: bin
30+
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}
31+
32+
- name: Install tools
33+
run: make install-tools
34+
2635
- name: "basic checks"
2736
run: make ci
2837

@@ -38,6 +47,15 @@ jobs:
3847
with:
3948
go-version: "~1.21.1"
4049

50+
- name: Install tools
51+
run: make install-tools
52+
53+
- name: Cache tools
54+
uses: actions/cache@v4
55+
with:
56+
path: bin
57+
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}
58+
4159
- uses: actions/cache@v4
4260
with:
4361
path: |

.github/workflows/e2e.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ jobs:
4747
with:
4848
go-version: "~1.21.3"
4949

50+
- name: Cache tools
51+
uses: actions/cache@v4
52+
with:
53+
path: bin
54+
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}
55+
56+
- name: Install tools
57+
run: make install-tools
58+
5059
- name: "run tests"
5160
env:
5261
KUBE_VERSION: ${{ matrix.kube-version }}

.github/workflows/scorecard.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ jobs:
3030
- name: Check out code into the Go module directory
3131
uses: actions/checkout@v4
3232

33+
- name: Cache tools
34+
uses: actions/cache@v4
35+
with:
36+
path: bin
37+
key: ${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}
38+
39+
- name: Install tools
40+
run: make install-tools
41+
3342
- name: "start kind"
3443
env:
3544
KUBE_VERSION: ${{ matrix.kube-version }}

Makefile

+6-4
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,8 @@ GOLANGCI_LINT_VERSION ?= v1.54.0
368368
KIND_VERSION ?= v0.20.0
369369
KUTTL_VERSION ?= 0.15.0
370370

371+
.PHONY: install-tools
372+
install-tools: kustomize golangci-lint kind controller-gen envtest crdoc kuttl kind operator-sdk
371373

372374
.PHONY: kustomize
373375
kustomize: ## Download kustomize locally if necessary.
@@ -384,12 +386,12 @@ kind: ## Download kind locally if necessary.
384386
.PHONY: controller-gen
385387
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
386388
$(CONTROLLER_GEN): $(LOCALBIN)
387-
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
389+
@test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
388390

389391
.PHONY: envtest
390392
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
391393
$(ENVTEST): $(LOCALBIN)
392-
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
394+
@test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
393395

394396
CRDOC = $(shell pwd)/bin/crdoc
395397
.PHONY: crdoc
@@ -412,12 +414,12 @@ rm -rf $$TMP_DIR ;\
412414
endef
413415

414416
.PHONY: kuttl
415-
kuttl:
417+
kuttl: $(LOCALBIN)
416418
@KUTTL=$(KUTTL) KUTTL_VERSION=$(KUTTL_VERSION) ./hack/install-kuttl.sh
417419

418420
OPERATOR_SDK = $(shell pwd)/bin/operator-sdk
419421
.PHONY: operator-sdk
420-
operator-sdk:
422+
operator-sdk: $(LOCALBIN)
421423
@{ \
422424
set -e ;\
423425
if (`pwd`/bin/operator-sdk version | grep ${OPERATOR_SDK_VERSION}) > /dev/null 2>&1 ; then \

0 commit comments

Comments
 (0)