Skip to content

Commit 2e5794f

Browse files
authored
Merge pull request #1004 from rabbitmq/refactor-fix-olm
Refactor and fix OLM packaging and workflow
2 parents ce9c870 + 00b9b2f commit 2e5794f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+4146
-318
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ jobs:
138138
- name: Build manifest
139139
env:
140140
RELEASE_VERSION: ${{ steps.meta.outputs.version }}
141+
shell: bash # important: because it sets pipefail, so that the job fails if there are failures in the command pipe
141142
run: |
142143
make install-tools
143144
pushd config/installation

.github/workflows/olm.yml

Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
---
2+
name: Test & Publish OLM bundle
3+
4+
on:
5+
release:
6+
types: [published]
7+
8+
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?
23+
24+
concurrency:
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: true
27+
28+
jobs:
29+
create-olm-package:
30+
name: Create the OLM Packaging
31+
runs-on: ubuntu-latest
32+
outputs:
33+
olm_package_version: ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
34+
env:
35+
REGISTRY: quay.io
36+
37+
steps:
38+
- name: Checkout code
39+
uses: actions/checkout@v4
40+
41+
- name: Set image tag to tagged release
42+
id: set_bundle_version
43+
shell: bash
44+
run: scripts/print-tag-version.bash ${{ inputs.bundle_version }} | tee -a "$GITHUB_OUTPUT"
45+
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"
52+
53+
- name: OpenShift Tools Installer
54+
uses: redhat-actions/openshift-tools-installer@v1
55+
with:
56+
# Using GitHub source because the Openshift mirror source binary file does not match the expected name
57+
# pattern. In the mirror, the filename is opm-rhel8, and the Action is expecting the name as opm-${OS}-${ARCH}
58+
source: github
59+
github_pat: ${{ github.token }}
60+
opm: "latest"
61+
62+
- name: Install Carvel tooling
63+
uses: carvel-dev/setup-action@v2.0.1
64+
with:
65+
token: ${{ github.token }}
66+
only: ytt
67+
68+
- name: Login to quay.io
69+
uses: docker/login-action@v3
70+
with:
71+
registry: ${{ env.REGISTRY }}
72+
# secret_rabbitmq/kv/oss%2Frabbitmq-cluster-operator%2Fsecrets/details
73+
username: ${{ secrets.QUAY_USERNAME }}
74+
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
75+
76+
# TODO: Set auto-expiry in DEV images: https://idbs-engineering.com/containers/2019/08/27/auto-expiry-quayio-tags.html
77+
- name: Create OLM bundle manifests
78+
env:
79+
QUAY_IO_OPERATOR_IMAGE: quay.io/rabbitmqoperator/messaging-topology-operator:${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
80+
BUNDLE_VERSION: ${{ 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
83+
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
93+
94+
- name: upload-olm-package
95+
uses: actions/upload-artifact@v4
96+
with:
97+
name: olm-artifact
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
104+
105+
test-olm-package:
106+
name: Tests the OLM packaging
107+
runs-on: ubuntu-latest
108+
needs: create-olm-package
109+
outputs:
110+
# Required to pass on the OLM bundle version to publish job
111+
olm_package_version: ${{ needs.create-olm-package.outputs.olm_package_version }}
112+
steps:
113+
- name: Checkout code
114+
uses: actions/checkout@v4
115+
116+
- name: Install Go
117+
uses: actions/setup-go@v5
118+
with:
119+
go-version-file: "go.mod"
120+
121+
- name: Install Carvel tooling
122+
uses: carvel-dev/setup-action@v2.0.1
123+
with:
124+
token: ${{ github.token }}
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 }}
134+
135+
- name: Kind Cluster
136+
uses: helm/kind-action@v1
137+
with:
138+
cluster_name: top-op-testing
139+
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
147+
env:
148+
IMAGE: ${{ vars.UNTESTED_BUNDLE_IMAGE }}:${{ needs.create-olm-package.outputs.olm_package_version }}
149+
BUNDLE_VERSION: ${{ needs.create-olm-package.outputs.olm_package_version }}
150+
CATALOG_IMAGE: ${{ vars.TEST_CATALOG_IMAGE }}
151+
run: make -C olm/ catalog-all
152+
153+
- name: Run Operator System Tests
154+
env:
155+
ENVIRONMENT: "openshift"
156+
K8S_OPERATOR_NAMESPACE: ns-1
157+
SYSTEM_TEST_NAMESPACE: ns-1
158+
NAMESPACE: ns-1
159+
run: |
160+
kubectl wait -n "$K8S_OPERATOR_NAMESPACE" sub --all --for=jsonpath='{.status.state}'=AtLatestKnown --timeout=2m
161+
go run github.com/onsi/ginkgo/v2/ginkgo --randomize-all -r --skip "RabbitMQ Cluster with TLS enabled" system_tests/
162+
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 }}
166+
167+
publish-bundle-operatorhub:
168+
name: Create branch for OperatorHub PR
169+
runs-on: ubuntu-latest
170+
needs: test-olm-package
171+
if: ${{ github.event_name == 'release' || inputs.release == true }}
172+
steps:
173+
- name: Checkout community-operators fork (OperatorHub)
174+
uses: actions/checkout@v4
175+
with:
176+
repository: rabbitmq/community-operators
177+
# secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
178+
token: ${{ secrets.RABBITMQ_CI_TOKEN }}
179+
180+
- name: Download OLM artifact
181+
uses: actions/download-artifact@v4
182+
with:
183+
name: olm-artifact
184+
path: olm-package-ci
185+
186+
- name: Create branch for OperatorHub PR
187+
env:
188+
BUNDLE_VERSION: ${{ needs.test-olm-package.outputs.olm_package_version }}
189+
GH_PROMPT_DISABLED: 1
190+
GH_TOKEN: ${{ secrets.RABBITMQ_CI_TOKEN }}
191+
run: |
192+
git config user.name "rabbitmq-ci"
193+
git config user.email ${{ secrets.RABBITMQ_CI_EMAIL }}
194+
git branch rabbitmq-messaging-topology-operator-$BUNDLE_VERSION
195+
git checkout rabbitmq-messaging-topology-operator-$BUNDLE_VERSION
196+
197+
mkdir -pv operators/rabbitmq-messaging-topology-operator/"$BUNDLE_VERSION"
198+
cp -v -fR olm-package-ci/* ./operators/rabbitmq-messaging-topology-operator/"$BUNDLE_VERSION"/
199+
git add operators/rabbitmq-messaging-topology-operator
200+
git commit -s -m "RabbitMQ Topology Operator release $BUNDLE_VERSION"
201+
git push --set-upstream origin "rabbitmq-messaging-topology-operator-$BUNDLE_VERSION"
202+
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+
207+
publish-bundle-redhat-marketplace:
208+
name: Create branch for Openshift Marketplace PR
209+
runs-on: ubuntu-latest
210+
needs: test-olm-package
211+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
212+
steps:
213+
- name: Checkout community-operators-prod fork (Openshift Ecosystem)
214+
uses: actions/checkout@v4
215+
with:
216+
repository: rabbitmq/community-operators-prod
217+
# secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
218+
token: ${{ secrets.RABBITMQ_CI_TOKEN }}
219+
220+
- name: Download OLM artifact
221+
uses: actions/download-artifact@v4
222+
with:
223+
name: olm-artifact
224+
path: olm-package-ci
225+
226+
- name: Create branch for Openshift Ecosystem PR
227+
env:
228+
BUNDLE_VERSION: ${{ needs.test-olm-package.outputs.olm_package_version }}
229+
run: |
230+
git config user.name "rabbitmq-ci"
231+
git config user.email ${{ secrets.RABBITMQ_CI_EMAIL }}
232+
git branch rabbitmq-messaging-topology-operator-$BUNDLE_VERSION
233+
git checkout rabbitmq-messaging-topology-operator-$BUNDLE_VERSION
234+
235+
mkdir -pv operators/rabbitmq-messaging-topology-operator/"$BUNDLE_VERSION"
236+
cp -v -fR olm-package-ci/* ./operators/rabbitmq-messaging-topology-operator/"$BUNDLE_VERSION"/
237+
git add operators/rabbitmq-messaging-topology-operator
238+
git commit -s -m "RabbitMQ Topology Operator release $BUNDLE_VERSION"
239+
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

.github/workflows/pr.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ jobs:
107107
- name: System tests
108108
env:
109109
IMG: local/rabbitmq-topology-operator:pr
110+
shell: bash # important: because it sets pipefail, so that the job fails if there are failures in the command pipe
110111
run: |
111112
kind load image-archive /tmp/operator.tar --name topology-operator-testing
112113
make cert-manager cmctl

0 commit comments

Comments
 (0)