11# action to test our operator lifecycle manager bundle
22# See https://github.com/rabbitmq/OLM-Package-Repo for more info.
3- name : test-and-publish- OLM-bundle
3+ name : Test & Publish OLM Package
44
55on :
66 release :
@@ -22,193 +22,237 @@ jobs:
2222 create-olm-package :
2323 name : Create the OLM Packaging
2424 runs-on : ubuntu-latest
25- container :
26- image : us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-ci-olm
27- options : --privileged
2825 permissions :
2926 contents : ' write'
3027 id-token : ' write'
28+ outputs :
29+ olm_package_version : ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
3130 steps :
32- - name : Checkout
31+ - name : Checkout code
3332 uses : actions/checkout@v4
33+
3434 - name : Checkout OLM-Package-Repo
3535 uses : actions/checkout@v4
3636 with :
3737 repository : rabbitmq/OLM-Package-Repo
3838 path : ./OLM-Package-Repo
3939
40- - name : Set tag image for tagged version
41- if : startsWith(github.ref, 'refs/tags/v')
42- run : |
43- BUNDLE_VERSION=${GITHUB_REF#refs/*/}
44- echo "BUNDLE_VERSION=${BUNDLE_VERSION:1}" >> $GITHUB_ENV
40+ - name : Set image tag to tagged release
41+ id : set_bundle_version
42+ run : scripts/print-tag-version.bash >> "$GITHUB_OUTPUT"
4543 shell : bash
4644
47- - name : Set tag image for test version
48- if : startsWith(github.ref, 'refs/tags/v') == false
49- run : |
50- echo "BUNDLE_VERSION=0.0.0" >> $GITHUB_ENV
51-
5245 - name : Install and configure Poetry
5346 uses : snok/install-poetry@v1
5447 with :
55- version : 1.4.2
5648 virtualenvs-create : true
5749 virtualenvs-in-project : false
5850
59- - name : create-olm-package
60- env :
51+ - name : OpenShift Tools Installer
52+ uses : redhat-actions/openshift-tools-installer@v1
53+ with :
54+ # Using GitHub source because the Openshift mirror source binary file does not match the expected name
55+ # pattern. In the mirror, the filename is opm-rhel8, and the Action is expecting the name as opm-${OS}-${ARCH}
56+ source : github
57+ github_pat : ${{ github.token }}
58+ opm : " latest"
59+
60+ - name : carvel-setup-action
61+ uses :
carvel-dev/[email protected] 62+ with :
63+ token : ${{ github.token }}
64+ only : ytt, kbld
65+
66+ - name : Podman Login
67+ uses : redhat-actions/podman-login@v1
68+ with :
69+ registry : ${{ env.DOCKER_REGISTRY_SERVER }}
6170 username : ${{ secrets.QUAY_USERNAME }}
6271 password : ${{ secrets.QUAY_ROBOT_TOKEN }}
72+
73+ # TODO: Set auto-expiry in DEV images: https://idbs-engineering.com/containers/2019/08/27/auto-expiry-quayio-tags.html
74+ - name : Create OLM Package
75+ env :
6376 DOCKER_REGISTRY_SERVER : ${{ env.DOCKER_REGISTRY_SERVER }}
6477 OLM_IMAGE : ${{ env.OLM_IMAGE }}
6578 OLM_INDEX_IMAGE : ${{ env.OLM_INDEX_IMAGE }}
66- BUNDLE_VERSION : ${{ env.BUNDLE_VERSION }}
67- run : |
68- sed '/mount_program =/s/^#//' -i /etc/containers/storage.conf
69- podman login quay.io -u $username -p $password
79+ BUNDLE_VERSION : ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
80+ run : |
7081 make generate-installation-manifest
7182 cp ./config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml ./OLM-Package-Repo/rabbitmq_olm_package_repo/manifests_crds/crds.yaml
7283 cd ./OLM-Package-Repo
7384 poetry run generate_bundle ./../releases/cluster-operator.yml $BUNDLE_VERSION ./
85+
7486 opm alpha bundle build -c stable -d ./$BUNDLE_VERSION/manifests -t $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:$BUNDLE_VERSION -p rabbitmq-cluster-operator --image-builder podman
75- podman push $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:$BUNDLE_VERSION
7687 opm index add -b $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:$BUNDLE_VERSION -t $DOCKER_REGISTRY_SERVER/$OLM_INDEX_IMAGE:$BUNDLE_VERSION -c podman
77- podman push $DOCKER_REGISTRY_SERVER/$OLM_INDEX_IMAGE:$BUNDLE_VERSION
88+
7889 mkdir upload
7990 mv "$BUNDLE_VERSION" ./upload
8091 cp ./rabbitmq_olm_package_repo/generators/cluster_operator_generators/cluster-service-version-generator-openshift.yml ./rabbitmq_olm_package_repo/generators/cluster_operator_generators/cluster-service-version-generator.yml
8192 poetry run generate_bundle ./rabbitmq_olm_package_repo/manifests_crds/cluster-operator.yaml $BUNDLE_VERSION ./
8293 mv "$BUNDLE_VERSION" ./upload/$BUNDLE_VERSION-openshift
83- - name : upload-olm-package
84- uses : actions/upload-artifact@master
94+
95+ - name : Push OLM Package to Registry
96+ uses : redhat-actions/push-to-registry@v2
97+ with :
98+ registry : ${{ env.DOCKER_REGISTRY_SERVER }}
99+ image : ${{ env.OLM_IMAGE }}
100+ tags : ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
101+
102+ - name : Push OLM Package to Registry
103+ uses : redhat-actions/push-to-registry@v2
104+ with :
105+ registry : ${{ env.DOCKER_REGISTRY_SERVER }}
106+ image : ${{ env.OLM_INDEX_IMAGE }}
107+ tags : ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
108+
109+ - name : Upload OLM Package
110+ uses : actions/upload-artifact@v4
85111 with :
86112 name : olm-artifact
87- path : " /home/runner/work/cluster-operator/cluster-operator/ OLM-Package-Repo/upload/"
113+ path : OLM-Package-Repo/upload/
88114 retention-days : 2
89115
90116 test-olm-package :
91117 name : Tests the OLM packaging
92118 runs-on : ubuntu-latest
93119 needs : create-olm-package
94- container : us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-ci-olm
95-
120+ outputs :
121+ # Required to pass on the OLM bundle version to publish job
122+ olm_package_version : ${{ needs.create-olm-package.outputs.olm_package_version }}
123+
96124 steps :
97125 - name : Checkout
98126 uses : actions/checkout@v4
127+
99128 - name : Checkout infrastructure repo
100129 uses : actions/checkout@v4
101130 with :
102131 repository : rabbitmq/infrastructure
103132 token : ${{ secrets.GIT_HUB_INFRA_REPO_ACCESS_TOKEN }}
104133 path : ./infrastructure
134+
105135 - name : Checkout OLM-Package-Repo
106136 uses : actions/checkout@v4
107137 with :
108138 repository : rabbitmq/OLM-Package-Repo
109139 path : ./OLM-Package-Repo
110140
141+ - name : Install Go
142+ uses : actions/setup-go@v5
143+ with :
144+ go-version-file : " go.mod"
145+
146+ - name : Setup Ginkgo CLI
147+ uses : ci-tasks/setup-ginkgo@main
148+
149+ - name : carvel-setup-action
150+ uses :
carvel-dev/[email protected] 151+ with :
152+ token : ${{ github.token }}
153+ only : ytt, kbld
154+
111155 - name : Protect access to the cluster with a mutex
112- 156+ uses :
ben-z/[email protected] .0 -alpha.9 113157 with :
114158 branch : openshift-lock
115159
116160 - name : Connect to the Openshift cluster and deploy the operators through OLM
117- env :
118- TOKEN : ${{ secrets.OPERATORHUB_TOKEN }}
119- BUNDLE_VERSION : ${{ env.BUNDLE_VERSION }}
120- run : |
161+ id : connect-and-deploy
162+ run : |
121163 mkdir $HOME/.kube
122164 cp ./infrastructure/k8s/okd/admin-kubeconfig.yaml $HOME/.kube/config
123165 export KUBECONFIG=$HOME/.kube/config
124166 export ENVIRONMENT=openshift
125167 kubectl config use-context admin
126- ./OLM-Package-Repo/testfiles/install-rabbitmq-cluster-operator.sh $BUNDLE_VERSION
127- export K8S_OPERATOR_NAMESPACE=rabbitmq-system-olm
128- export SYSTEM_TEST_NAMESPACE=rabbitmq-system-olm
168+ ./OLM-Package-Repo/testfiles/install-rabbitmq-cluster-operator.sh ${{ needs.create-olm-package.outputs.olm_package_version }}
169+
170+ - name : Run Operator System Tests
171+ env :
172+ ENVIRONMENT : " openshift"
173+ K8S_OPERATOR_NAMESPACE : rabbitmq-system-olm
174+ SYSTEM_TEST_NAMESPACE : rabbitmq-system-olm
175+ run : |
176+ kubectl wait -n "$K8S_OPERATOR_NAMESPACE" sub --all --for=jsonpath='{.status.state}'=AtLatestKnown --timeout=2m
129177 make system-tests
130178
131- - name : Clean up
179+ - name : Clean up Openshift environment
132180 env :
133- OLM_INDEX_TAG : ${{ env.BUNDLE_VERSION }}
134- if : always()
181+ OLM_INDEX_TAG : ${{ needs.create-olm-package.outputs.olm_package_version }}
182+ if : ${{ !cancelled() && steps.connect-and-deploy.conclusion == 'success' }}
135183 run : |
136184 export KUBECONFIG=./infrastructure/k8s/okd/admin-kubeconfig.yaml
137185 kubectl config use-context admin
138- ./OLM-Package-Repo/testfiles/uninstall-rabbitmq-cluster-operator.sh $BUNDLE_VERSION
186+ ./OLM-Package-Repo/testfiles/uninstall-rabbitmq-cluster-operator.sh $OLM_INDEX_TAG
139187
140- publish-bundle :
141- name : Publish on OperatorHub and Openshift market-place
188+ publish-bundle-operatorhub :
189+ name : Publish on OperatorHub and Openshift marketplace
142190 runs-on : ubuntu-latest
143191 needs : test-olm-package
144- container : us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-ci-olm
145- # Create the PR to OperatorHUB
192+ if : ${{ startsWith(github.ref, 'refs/tags/v') }}
146193 steps :
147- - name : Checkout
148- uses : actions/checkout@v4
149- - name : Checkout community-operators repo
194+ - name : Checkout community-operators fork (OperatorHub)
150195 uses : actions/checkout@v4
151196 with :
152197 repository : rabbitmq/community-operators
153- path : ./community-operators
154- token : ${{ secrets.OPERATORHUB_TOKEN }}
155- - name : Checkout community-operators-prod repo
156- uses : actions/checkout@v4
157- with :
158- repository : rabbitmq/community-operators-prod
159- path : ./community-operators-prod
160- token : ${{ secrets.OPERATORHUB_TOKEN }}
161-
162- - name : Set tag image for tagged version
163- if : startsWith(github.ref, 'refs/tags/v')
164- run : |
165- BUNDLE_VERSION=${GITHUB_REF#refs/*/}
166- echo "BUNDLE_VERSION=${BUNDLE_VERSION:1}" >> $GITHUB_ENV
167- shell : bash
168-
169- - name : Set tag image for test version
170- if : startsWith(github.ref, 'refs/tags/v') == false
171- run : |
172- echo "BUNDLE_VERSION=0.0.0" >> $GITHUB_ENV
198+ token : ${{ secrets.RABBITMQ_CI_TOKEN }}
173199
174- - name : download olm-artifact from previous step
175- uses : actions/download-artifact@master
200+ - name : Download OLM artifact
201+ uses : actions/download-artifact@v4
176202 with :
177203 name : olm-artifact
178- - name : CreateOperatorHubPR
204+ path : olm-package-ci
205+
206+ - name : Create branch for OperatorHub PR
179207 env :
180- TOKEN : ${{ secrets.OPERATORHUB_TOKEN }}
181- BUNDLE_VERSION : ${{ env.BUNDLE_VERSION }}
208+ BUNDLE_VERSION : ${{ needs.test-olm-package.outputs.olm_package_version }}
209+ # RABBITMQ_CI_EMAIL: secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
210+ # RABBITMQ_CI_TOKEN: secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
182211 run : |
183- git config --global user.name "DanielePalaia"
184- git config --global user.email "[email protected] " 185- mkdir -p community-operators/operators/rabbitmq-cluster-operator
186- cd community-operators/operators/rabbitmq-cluster-operator
212+ mkdir -pv operators/rabbitmq-cluster-operator
213+ git config user.name "rabbitmq-ci"
214+ git config user.email ${{ secrets.RABBITMQ_CI_EMAIL }}
187215 git branch rabbitmq-cluster-operator-$BUNDLE_VERSION
188216 git checkout rabbitmq-cluster-operator-$BUNDLE_VERSION
189- REPLACE_VERSION=$(ls -1v | tail -2 | head -1)
190- cp -fR ./../../../$BUNDLE_VERSION .
191- sed -i -e "s/replaces: null/replaces: rabbitmq-cluster-operator.v$REPLACE_VERSION/g" ./$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml
192- sed -i -e "s/latest/$BUNDLE_VERSION/g" ./$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml
193- git add .
194- git commit -s -m "RabbitMQ operator new release"
195- git push https://DanielePalaia:"$TOKEN"@github.com/rabbitmq/community-operators
196- cd ./../../..
197-
198- # Create the PR to redhat openshift ecosystem
199- - name : CreateOpenshiftEcosystemPR
217+
218+ cp -v -fR olm-package-ci/"$BUNDLE_VERSION" ./operators/rabbitmq-cluster-operator/
219+ sed -i -e "s/latest/$BUNDLE_VERSION/g" ./operators/rabbitmq-cluster-operator/$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml
220+ git add operators/rabbitmq-cluster-operator
221+ git commit -s -m "RabbitMQ Operator release $BUNDLE_VERSION"
222+ git push --set-upstream origin "rabbitmq-cluster-operator-$BUNDLE_VERSION"
223+
224+ publish-bundle-redhat-marketplace :
225+ name : Publish on OperatorHub and Openshift marketplace
226+ runs-on : ubuntu-latest
227+ needs : test-olm-package
228+ # if: ${{ startsWith(github.ref, 'refs/tags/v') }}
229+ steps :
230+ - name : Checkout community-operators-prod fork (Openshift Ecosystem)
231+ uses : actions/checkout@v4
232+ with :
233+ repository : rabbitmq/community-operators-prod
234+ token : ${{ secrets.RABBITMQ_CI_TOKEN }}
235+
236+ - name : Download OLM artifact
237+ uses : actions/download-artifact@v4
238+ with :
239+ name : olm-artifact
240+ path : olm-package-ci
241+
242+ - name : Create branch for Openshift Ecosystem PR
200243 env :
201- TOKEN : ${{ secrets.OPERATORHUB_TOKEN }}
202- BUNDLE_VERSION : ${{ env.BUNDLE_VERSION }}
244+ BUNDLE_VERSION : ${{ needs.test-olm-package.outputs.olm_package_version }}
245+ # RABBITMQ_CI_EMAIL: secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
246+ # RABBITMQ_CI_TOKEN: secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
203247 run : |
204- cd community-operators-prod/operators/rabbitmq-cluster-operator
248+ mkdir -pv operators/rabbitmq-cluster-operator
249+ git config user.name "rabbitmq-ci"
250+ git config user.email ${{ secrets.RABBITMQ_CI_EMAIL }}
205251 git branch rabbitmq-cluster-operator-$BUNDLE_VERSION
206252 git checkout rabbitmq-cluster-operator-$BUNDLE_VERSION
207- REPLACE_VERSION=$(ls -1v | tail -2 | head -1)
208- cp -fR ./../../../$BUNDLE_VERSION-openshift .
209- mv $BUNDLE_VERSION-openshift $BUNDLE_VERSION
210- sed -i -e "s/replaces: null/replaces: rabbitmq-cluster-operator.v$REPLACE_VERSION/g" ./$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml
211- sed -i -e "s/latest/$BUNDLE_VERSION/g" ./$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml
212- git add .
213- git commit -s -m "RabbitMQ operator new release"
214- git push https://DanielePalaia:"$TOKEN"@github.com/rabbitmq/community-operators-prod
253+
254+ cp -v -fR olm-package-ci/"$BUNDLE_VERSION-openshift" ./operators/rabbitmq-cluster-operator/"$BUNDLE_VERSION"
255+ sed -i -e "s/latest/$BUNDLE_VERSION/g" ./operators/rabbitmq-cluster-operator/"$BUNDLE_VERSION"/manifests/rabbitmq.clusterserviceversion.yaml
256+ git add operators/rabbitmq-cluster-operator
257+ git commit -s -m "RabbitMQ Operator release $BUNDLE_VERSION"
258+ git push --set-upstream origin "rabbitmq-cluster-operator-$BUNDLE_VERSION"
0 commit comments