1- # action to test our operator lifecycle manager bundle
2- # See https://github.com/rabbitmq/OLM-Package-Repo for more info.
1+ ---
32name : Test & Publish OLM bundle
43
54on :
65 release :
76 types : [published]
87
98 workflow_dispatch :
9+ inputs :
10+ bundle_version :
11+ description : version in format {major}.{minor}.{patch} (do not prefix with "v")
12+ required : true
13+ type : string
14+ previous_version :
15+ description : version N-1 in format v{major}.{minor}.{patch} (WITH prefix "v")
16+ required : true
17+ type : string
18+ release :
19+ default : false
20+ type : boolean
21+ required : false
22+ description : Make a release PR to operatorhub?
1023
1124concurrency :
1225 group : ${{ github.workflow }}-${{ github.ref }}
1326 cancel-in-progress : true
14- env :
15- # registry information where we want to store the operator image and the operator index image
16- DOCKER_REGISTRY_SERVER : quay.io/rabbitmqoperator
17- OLM_IMAGE : rabbitmq-for-kubernetes-olm-messaging-topology-operator
18- OLM_INDEX_IMAGE : rabbitmq-for-kubernetes-olm-messaging-topology-operator-index
1927
2028jobs :
2129 create-olm-package :
2230 name : Create the OLM Packaging
2331 runs-on : ubuntu-latest
24- permissions :
25- contents : ' write'
26- id-token : ' write'
2732 outputs :
2833 olm_package_version : ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
34+ env :
35+ REGISTRY : quay.io
36+
2937 steps :
3038 - name : Checkout code
3139 uses : actions/checkout@v4
3240
33- - name : Checkout OLM-Package-Repo
34- uses : actions/checkout@v4
35- with :
36- repository : rabbitmq/OLM-Package-Repo
37- path : ./OLM-Package-Repo
38-
3941 - name : Set image tag to tagged release
4042 id : set_bundle_version
41- run : scripts/print-tag-version.bash >> "$GITHUB_OUTPUT"
4243 shell : bash
44+ run : scripts/print-tag-version.bash ${{ inputs.bundle_version }} | tee -a "$GITHUB_OUTPUT"
4345
44- - name : Install and configure Poetry
45- uses : snok/install-poetry@v1
46- with :
47- virtualenvs-create : true
48- virtualenvs-in-project : false
46+ - name : Set previous version
47+ id : set_previous_version
48+ shell : bash
49+ env :
50+ GH_TOKEN : ${{ github.token }}
51+ run : scripts/print-previous-tag-version.bash ${{ inputs.previous_version }} | tee -a "$GITHUB_OUTPUT"
4952
5053 - name : OpenShift Tools Installer
5154 uses : redhat-actions/openshift-tools-installer@v1
@@ -60,57 +63,44 @@ jobs:
6063 uses :
carvel-dev/[email protected] 6164 with :
6265 token : ${{ github.token }}
63- only : ytt, kbld
66+ only : ytt
6467
65- - name : Podman Login
66- uses : redhat-actions/podman- login@v1
68+ - name : Login to quay.io
69+ uses : docker/ login-action@v3
6770 with :
68- registry : ${{ env.DOCKER_REGISTRY_SERVER }}
71+ registry : ${{ env.REGISTRY }}
72+ # secret_rabbitmq/kv/oss%2Frabbitmq-cluster-operator%2Fsecrets/details
6973 username : ${{ secrets.QUAY_USERNAME }}
7074 password : ${{ secrets.QUAY_ROBOT_TOKEN }}
7175
7276 # TODO: Set auto-expiry in DEV images: https://idbs-engineering.com/containers/2019/08/27/auto-expiry-quayio-tags.html
73- - name : Create OLM package
77+ - name : Create OLM bundle manifests
7478 env :
75- DOCKER_REGISTRY_SERVER : ${{ env.DOCKER_REGISTRY_SERVER }}
76- OLM_IMAGE : ${{ env.OLM_IMAGE }}
77- OLM_INDEX_IMAGE : ${{ env.OLM_INDEX_IMAGE }}
79+ QUAY_IO_OPERATOR_IMAGE : quay.io/rabbitmqoperator/messaging-topology-operator:${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
7880 BUNDLE_VERSION : ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
79- run : |
80- make generate-manifests
81- cp ./config/crd/bases/*.yaml ./OLM-Package-Repo/rabbitmq_olm_package_repo/manifests_crds_messaging_topology_operator/crds
82- cd ./OLM-Package-Repo
83- poetry run generate_bundle ./../releases/messaging-topology-operator-with-certmanager.yaml $BUNDLE_VERSION ./
84-
85- opm alpha bundle build -c stable -d ./$BUNDLE_VERSION/manifests -t $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:$BUNDLE_VERSION -p rabbitmq-messaging-topology-operator --image-builder podman
86- opm index add -b $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:$BUNDLE_VERSION -t $DOCKER_REGISTRY_SERVER/$OLM_INDEX_IMAGE:$BUNDLE_VERSION -c podman
87-
88- mkdir upload
89- mv "$BUNDLE_VERSION" ./upload
90- cp ./rabbitmq_olm_package_repo/generators/messaging_topology_operator_generators/topology-service-version-generator-openshift.yml ./rabbitmq_olm_package_repo/generators/messaging_topology_operator_generators/topology-service-version-generator.yml
91- poetry run generate_bundle ./../releases/messaging-topology-operator-with-certmanager.yaml $BUNDLE_VERSION ./
92- mv "$BUNDLE_VERSION" ./upload/$BUNDLE_VERSION-openshift
93-
94- - name : Push OLM Package to Registry
95- uses : redhat-actions/push-to-registry@v2
96- with :
97- registry : ${{ env.DOCKER_REGISTRY_SERVER }}
98- image : ${{ env.OLM_IMAGE }}
99- tags : ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
81+ BUNDLE_REPLACES : messaging-topology-operator.${{ steps.set_previous_version.outputs.PREVIOUS_VERSION }}
82+ run : make -C olm/ all
10083
101- - name : Push OLM Package to Registry
102- uses : redhat-actions/push-to-registry@v2
103- with :
104- registry : ${{ env.DOCKER_REGISTRY_SERVER }}
105- image : ${{ env.OLM_INDEX_IMAGE }}
106- tags : ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
84+ - name : Create OLM Package
85+ env :
86+ IMAGE : ${{ vars.UNTESTED_BUNDLE_IMAGE }}:${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
87+ run : make -C olm/ docker-build docker-push
88+
89+ - name : Validate bundle manifests
90+ env :
91+ IMAGE : ${{ vars.UNTESTED_BUNDLE_IMAGE }}:${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
92+ run : opm alpha bundle validate --tag ${{ env.REGISTRY }}/${{ env.IMAGE }} --image-builder docker
10793
10894 - name : upload-olm-package
10995 uses : actions/upload-artifact@v4
11096 with :
11197 name : olm-artifact
112- path : OLM-Package-Repo/upload/
113- retention-days : 2
98+ path : |
99+ olm/bundle/manifests
100+ olm/bundle/metadata
101+ olm/bundle/bundle.Dockerfile
102+ if-no-files-found : error
103+ retention-days : 1
114104
115105 test-olm-package :
116106 name : Tests the OLM packaging
@@ -123,77 +113,62 @@ jobs:
123113 - name : Checkout code
124114 uses : actions/checkout@v4
125115
126- - name : Checkout infrastructure repo
127- uses : actions/checkout@v4
128- with :
129- repository : rabbitmq/infrastructure
130- token : ${{ secrets.GIT_HUB_ACCESS_INFRA_REPO_TOKEN }}
131- path : ./infrastructure
132-
133- - name : Checkout OLM-Package-Repo
134- uses : actions/checkout@v4
135- with :
136- repository : rabbitmq/OLM-Package-Repo
137- path : ./OLM-Package-Repo
138-
139116 - name : Install Go
140117 uses : actions/setup-go@v5
141118 with :
142119 go-version-file : " go.mod"
143120
144- - name : Setup Ginkgo CLI
145- uses : ci-tasks/setup-ginkgo@main
146-
147121 - name : Install Carvel tooling
148122 uses :
carvel-dev/[email protected] 149123 with :
150124 token : ${{ github.token }}
151- only : ytt, kbld
125+ only : ytt, imgpkg
126+
127+ - name : Login to quay.io
128+ uses : docker/login-action@v3
129+ with :
130+ registry : quay.io
131+ # secret_rabbitmq/kv/oss%2Frabbitmq-cluster-operator%2Fsecrets/details
132+ username : ${{ secrets.QUAY_USERNAME }}
133+ password : ${{ secrets.QUAY_ROBOT_TOKEN }}
152134
153- - name : Protect access to the cluster with a mutex
154- uses : ben-z/gh -action-mutex @v1.0.0-alpha.10
135+ - name : Kind Cluster
136+ uses : helm/kind -action@v1
155137 with :
156- repo-token : ${{ secrets.CLUSTER_OPERATOR_ACCESS_TOKEN }}
157- repository : rabbitmq/cluster-operator
158- branch : openshift-lock
138+ cluster_name : top-op-testing
159139
160- - name : Connect to the Openshift cluster and deploy the operators through OLM
161- id : connect-and-deploy
140+ - name : Install OLM
141+ run : |
142+ curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.32.0/install.sh -o install.sh
143+ chmod +x install.sh
144+ ./install.sh v0.32.0
145+
146+ - name : Deploy test catalog
162147 env :
163- TOKEN : ${{ secrets.OPERATORHUB_TOKEN }}
148+ IMAGE : ${{ vars.UNTESTED_BUNDLE_IMAGE }}:${{ needs.create-olm-package.outputs.olm_package_version }}
164149 BUNDLE_VERSION : ${{ needs.create-olm-package.outputs.olm_package_version }}
165- ENVIRONMENT : openshift
166- run : |
167- mkdir $HOME/.kube
168- cp ./infrastructure/k8s/okd/admin-kubeconfig.yaml $HOME/.kube/config
169- export KUBECONFIG=$HOME/.kube/config
170- kubectl config use-context admin
171- ./OLM-Package-Repo/testfiles/install-rabbitmq-messaging-topology-operator.sh $BUNDLE_VERSION
150+ CATALOG_IMAGE : ${{ vars.TEST_CATALOG_IMAGE }}
151+ run : make -C olm/ catalog-all
172152
173153 - name : Run Operator System Tests
174154 env :
175155 ENVIRONMENT : " openshift"
176- K8S_OPERATOR_NAMESPACE : rabbitmq-system-olm
177- SYSTEM_TEST_NAMESPACE : rabbitmq-system-olm
178- NAMESPACE : rabbitmq-system-olm
156+ K8S_OPERATOR_NAMESPACE : ns-1
157+ SYSTEM_TEST_NAMESPACE : ns-1
158+ NAMESPACE : ns-1
179159 run : |
180160 kubectl wait -n "$K8S_OPERATOR_NAMESPACE" sub --all --for=jsonpath='{.status.state}'=AtLatestKnown --timeout=2m
181- ginkgo --randomize-all -r --skip "RabbitMQ Cluster with TLS enabled" system_tests/
161+ go run github.com/onsi/ginkgo/v2/ ginkgo --randomize-all -r --skip "RabbitMQ Cluster with TLS enabled" system_tests/
182162
183- - name : Clean up
184- env :
185- OLM_INDEX_TAG : ${{ needs.create-olm-package.outputs.olm_package_version }}
186- if : ${{ !cancelled() && steps.connect-and-deploy.conclusion == 'success' }}
187- run : |
188- export KUBECONFIG=./infrastructure/k8s/okd/admin-kubeconfig.yaml
189- kubectl config use-context admin
190- ./OLM-Package-Repo/testfiles/uninstall-rabbitmq-messaging-topology-operator.sh $BUNDLE_VERSION
163+ - name : Promote tested image
164+ if : ${{ github.event_name == 'release' || inputs.release == true }}
165+ run : imgpkg copy --image quay.io/${{ vars.UNTESTED_BUNDLE_IMAGE }}:${{ needs.create-olm-package.outputs.olm_package_version }} --to-repo quay.io/${{ vars.FINAL_BUNDLE_IMAGE }}
191166
192167 publish-bundle-operatorhub :
193168 name : Create branch for OperatorHub PR
194169 runs-on : ubuntu-latest
195170 needs : test-olm-package
196- if : ${{ startsWith( github.ref, 'refs/tags/v') }}
171+ if : ${{ github.event_name == 'release' || inputs.release == true }}
197172 steps :
198173 - name : Checkout community-operators fork (OperatorHub)
199174 uses : actions/checkout@v4
@@ -211,22 +186,24 @@ jobs:
211186 - name : Create branch for OperatorHub PR
212187 env :
213188 BUNDLE_VERSION : ${{ needs.test-olm-package.outputs.olm_package_version }}
189+ GH_PROMPT_DISABLED : 1
190+ GH_TOKEN : ${{ secrets.RABBITMQ_CI_TOKEN }}
214191 run : |
215- mkdir -pv operators/rabbitmq-messaging-topology-operator
216192 git config user.name "rabbitmq-ci"
217193 git config user.email ${{ secrets.RABBITMQ_CI_EMAIL }}
218194 git branch rabbitmq-messaging-topology-operator-$BUNDLE_VERSION
219195 git checkout rabbitmq-messaging-topology-operator-$BUNDLE_VERSION
220196
221- REPLACE_VERSION=$(ls -1v ./operators/rabbitmq-messaging-topology-operator/ | tail -2 | head -1)
222-
223- cp -v -fR ./olm-package-ci/"$BUNDLE_VERSION" ./operators/rabbitmq-messaging-topology-operator/
224- sed -i -e "s/replaces: null/replaces: rabbitmq-messaging-topology-operator.v$REPLACE_VERSION/g" ./operators/rabbitmq-messaging-topology-operator/$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml
225- sed -i -e "s/latest/$BUNDLE_VERSION/g" ./operators/rabbitmq-messaging-topology-operator/"$BUNDLE_VERSION"/manifests/rabbitmq.clusterserviceversion.yaml
197+ mkdir -pv operators/rabbitmq-messaging-topology-operator/"$BUNDLE_VERSION"
198+ cp -v -fR olm-package-ci/* ./operators/rabbitmq-messaging-topology-operator/"$BUNDLE_VERSION"/
226199 git add operators/rabbitmq-messaging-topology-operator
227200 git commit -s -m "RabbitMQ Topology Operator release $BUNDLE_VERSION"
228201 git push --set-upstream origin "rabbitmq-messaging-topology-operator-$BUNDLE_VERSION"
229202
203+ gh pr create --title "operator messaging-topology-operator (${{ env.BUNDLE_VERSION }})" \
204+ --body "Update operator messaging-topology-operator (${{ needs.test-olm-package.outputs.olm_package_version }})" \
205+ --repo k8s-operatorhub/community-operators
206+
230207 publish-bundle-redhat-marketplace :
231208 name : Create branch for Openshift Marketplace PR
232209 runs-on : ubuntu-latest
@@ -250,14 +227,17 @@ jobs:
250227 env :
251228 BUNDLE_VERSION : ${{ needs.test-olm-package.outputs.olm_package_version }}
252229 run : |
253- mkdir -pv operators/rabbitmq-messaging-topology-operator
254230 git config user.name "rabbitmq-ci"
255231 git config user.email ${{ secrets.RABBITMQ_CI_EMAIL }}
256232 git branch rabbitmq-messaging-topology-operator-$BUNDLE_VERSION
257233 git checkout rabbitmq-messaging-topology-operator-$BUNDLE_VERSION
258234
259- cp -v -fR ./olm-package-ci/"$BUNDLE_VERSION-openshift" ./ operators/rabbitmq-messaging-topology-operator/"$BUNDLE_VERSION"
260- sed -i -e "s/latest/$BUNDLE_VERSION/g" ./operators/rabbitmq-messaging-topology-operator/"$BUNDLE_VERSION"/manifests/rabbitmq.clusterserviceversion.yaml
235+ mkdir -pv operators/rabbitmq-messaging-topology-operator/"$BUNDLE_VERSION"
236+ cp -v -fR olm-package-ci/* ./operators/rabbitmq-messaging-topology-operator/"$BUNDLE_VERSION"/
261237 git add operators/rabbitmq-messaging-topology-operator
262238 git commit -s -m "RabbitMQ Topology Operator release $BUNDLE_VERSION"
263239 git push --set-upstream origin "rabbitmq-messaging-topology-operator-$BUNDLE_VERSION"
240+
241+ gh pr create --title "operator messaging-topology-operator (${{ env.BUNDLE_VERSION }})" \
242+ --body "Update operator messaging-topology-operator (${{ needs.test-olm-package.outputs.olm_package_version }})" \
243+ --repo k8s-operatorhub/community-operators-prod
0 commit comments