Skip to content

Commit 70e1539

Browse files
committed
[ci] Use local builds in other jobs
We are pushing every commit to a registry. This seems a bit unnecessary, specially given that we can build locally very quickly. It's more efficient to build and export to a tarball, and then share this tarball among other jobs.
1 parent 02406c3 commit 70e1539

File tree

3 files changed

+72
-12
lines changed

3 files changed

+72
-12
lines changed

.github/workflows/build-test-publish.yml

+56-12
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,64 @@ jobs:
2525
# FIXME: do not sneaky build the operator. Use a built one
2626
name: kubectl rabbitmq tests
2727
runs-on: ubuntu-latest
28+
needs:
29+
- build_operator
2830
steps:
2931
- name: Install Go
3032
uses: actions/setup-go@v5
3133
with:
3234
go-version: ${{ env.GO_VERSION }}
3335
check-latest: true
36+
37+
- name: Check out code into the Go module directory
38+
uses: actions/checkout@v4
39+
40+
- name: carvel-setup-action
41+
uses: carvel-dev/[email protected]
42+
with:
43+
only: ytt
44+
3445
- name: Install Bats
3546
run: |
3647
git clone https://github.com/bats-core/bats-core.git "$HOME"/bats-core
3748
cd "$HOME"/bats-core
3849
sudo ./install.sh /usr/local
39-
- name: Check out code into the Go module directory
40-
uses: actions/checkout@v4
50+
51+
- name: Download Operator artifact
52+
uses: actions/download-artifact@v4
53+
with:
54+
name: operator_image
55+
path: /tmp
56+
57+
- name: Create KinD
58+
uses: helm/kind-action@v1
59+
with:
60+
cluster_name: cluster-operator-testing
61+
node_image: ${{ env.KIND_NODE_IMAGE }}
62+
4163
- name: kubectl rabbitmq tests
64+
env:
65+
IMG: "rabbitmqoperator/cluster-operator:${{ needs.build_operator.outputs.image_sha }}"
4266
run: |
43-
make install-tools
44-
kind create cluster --image "${{ env.KIND_NODE_IMAGE }}"
45-
DOCKER_REGISTRY_SERVER=local-server OPERATOR_IMAGE=local-operator make deploy-kind kubectl-plugin-tests
46-
- name: Notify Google Chat
47-
if: ${{ failure() && github.event_name != 'pull_request' }}
48-
uses: SimonScholz/google-chat-action@main
49-
with:
50-
webhookUrl: '${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}'
51-
jobStatus: ${{ job.status }}
52-
title: Cluster Operator - RabbitMQ kubectl tests
67+
kind load image-archive /tmp/operator.tar --name cluster-operator-testing
68+
69+
make manifests deploy-namespace-rbac
70+
kubectl kustomize config/crd | kubectl apply -f-
71+
kubectl kustomize config/default/base | ytt -f- \
72+
-f config/ytt/overlay-manager-image.yaml \
73+
--data-value operator-image="$IMG" \
74+
-f config/ytt/never_pull.yaml \
75+
| kubectl apply -f-
76+
77+
make kubectl-plugin-tests
78+
79+
# - name: Notify Google Chat
80+
# if: ${{ failure() && github.event_name != 'pull_request' }}
81+
# uses: SimonScholz/google-chat-action@main
82+
# with:
83+
# webhookUrl: '${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}'
84+
# jobStatus: ${{ job.status }}
85+
# title: Cluster Operator - RabbitMQ kubectl tests
5386

5487
unit_integration_tests:
5588
name: unit and integration tests
@@ -81,6 +114,8 @@ jobs:
81114
build_operator:
82115
runs-on: ubuntu-latest
83116
needs: unit_integration_tests
117+
outputs:
118+
image_sha: ${{ steps.build.outputs.digest }}
84119
permissions:
85120
contents: 'write'
86121
id-token: 'write'
@@ -130,6 +165,7 @@ jobs:
130165
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
131166

132167
- name: Build and push
168+
id: build
133169
uses: docker/build-push-action@v6
134170
with:
135171
context: .
@@ -138,6 +174,14 @@ jobs:
138174
push: ${{ github.event_name != 'pull_request' }}
139175
tags: ${{ steps.meta.outputs.tags }}
140176
labels: ${{ steps.meta.outputs.labels }}
177+
outputs: |
178+
type=docker,dest=./operator.tar
179+
180+
- name: Upload Operator artifact
181+
uses: actions/upload-artifact@v4
182+
with:
183+
name: operator_image
184+
path: ./operator.tar
141185

142186
- name: Build manifest
143187
if: github.event_name != 'pull_request'

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ ifeq ($(ARCHITECTURE),x86_64)
66
ARCHITECTURE=amd64
77
endif
88

9+
ifeq ($(ARCHITECTURE),aarch64)
10+
ARCHITECTURE=arm64
11+
endif
12+
913
.DEFAULT_GOAL = help
1014
.PHONY: help
1115
help:

config/ytt/never_pull.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#@ load("@ytt:overlay", "overlay")
2+
3+
#! Matching by Deployment is acceptable because we have only one Deployment :-)
4+
#@overlay/match by=overlay.subset({"kind": "Deployment"})
5+
---
6+
spec:
7+
template:
8+
spec:
9+
containers:
10+
#@overlay/match by=overlay.map_key("name")
11+
- name: manager
12+
imagePullPolicy: Never

0 commit comments

Comments
 (0)