Skip to content

Commit ed8f4c5

Browse files
Merge branch 'main' into GH-1876-support-scale-to-zero
2 parents 2a2465d + 6f9077f commit ed8f4c5

30 files changed

+1142
-361
lines changed

.github/workflows/olm.yml

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
---
2+
name: Test & Publish OLM Package
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+
release:
15+
default: false
16+
type: boolean
17+
required: false
18+
description: Make a release PR to operatorhub?
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.ref }}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
create-olm-package:
26+
name: Create the OLM Packaging
27+
runs-on: ubuntu-latest
28+
outputs:
29+
olm_package_version: ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
30+
31+
steps:
32+
- name: Checkout code
33+
uses: actions/checkout@v4
34+
35+
- name: Set image tag to tagged release
36+
id: set_bundle_version
37+
shell: bash
38+
run: scripts/print-tag-version.bash ${{ inputs.bundle_version }} | tee -a "$GITHUB_OUTPUT"
39+
40+
- id: set_previous_version
41+
shell: bash
42+
env:
43+
GH_TOKEN: ${{ github.token }}
44+
run: scripts/print-previous-version.bash | tee -a "$GITHUB_OUTPUT"
45+
46+
- name: Openshift tools
47+
uses: redhat-actions/openshift-tools-installer@v1
48+
with:
49+
# Using GitHub source because the Openshift mirror source binary file does not match the expected name
50+
# pattern. In the mirror, the filename is opm-rhel8, and the Action is expecting the name as opm-${OS}-${ARCH}
51+
source: github
52+
github_pat: ${{ github.token }}
53+
opm: latest
54+
55+
- name: carvel-setup-action
56+
uses: carvel-dev/setup-action@v2.0.1
57+
with:
58+
token: ${{ github.token }}
59+
only: ytt
60+
61+
- name: Login to quay.io
62+
uses: docker/login-action@v3
63+
with:
64+
registry: quay.io
65+
# secret_rabbitmq/kv/oss%2Frabbitmq-cluster-operator%2Fsecrets/details
66+
username: ${{ secrets.QUAY_USERNAME }}
67+
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
68+
69+
- name: Create OLM bundle manifests
70+
env:
71+
QUAY_IO_OPERATOR_IMAGE: quay.io/rabbitmqoperator/cluster-operator:${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
72+
BUNDLE_VERSION: ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
73+
BUNDLE_REPLACES: rabbitmq-cluster-operator.${{ steps.set_previous_version.outputs.PREVIOUS_VERSION }}
74+
run: make -f olm.mk all
75+
76+
- name: Create OLM Package
77+
env:
78+
REGISTRY: quay.io
79+
IMAGE: ${{ vars.UNTESTED_BUNDLE_IMAGE }}:${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
80+
run: make -f olm.mk docker-build docker-push
81+
82+
- name: Validate bundle manifests
83+
env:
84+
REGISTRY: quay.io
85+
IMAGE: ${{ vars.UNTESTED_BUNDLE_IMAGE }}:${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
86+
run: opm alpha bundle validate --tag ${{ env.REGISTRY }}/${{ env.IMAGE }} --image-builder docker
87+
88+
- name: Upload manifests
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: bundle-manifest
92+
path: |
93+
olm/manifests
94+
olm/metadata
95+
olm/bundle.Dockerfile
96+
if-no-files-found: error
97+
retention-days: 1
98+
99+
test-olm-package:
100+
name: Tests the OLM packaging
101+
runs-on: ubuntu-latest
102+
needs: create-olm-package
103+
outputs:
104+
# Required to pass on the OLM bundle version to publish job
105+
olm_package_version: ${{ needs.create-olm-package.outputs.olm_package_version }}
106+
107+
steps:
108+
- name: Checkout
109+
uses: actions/checkout@v4
110+
111+
- name: Install Go
112+
uses: actions/setup-go@v5
113+
with:
114+
go-version-file: "go.mod"
115+
- name: Kubectl tool installer
116+
uses: Azure/setup-kubectl@v4.0.1
117+
- name: Setup YTT
118+
uses: carvel-dev/setup-action@v2.0.1
119+
with:
120+
token: ${{ github.token }}
121+
only: ytt, imgpkg
122+
123+
- name: Kind Cluster
124+
uses: helm/kind-action@v1
125+
126+
- name: Install OLM
127+
run: |
128+
curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.32.0/install.sh -o install.sh
129+
chmod +x install.sh
130+
./install.sh v0.32.0
131+
132+
- name: Login to quay.io
133+
uses: docker/login-action@v3
134+
with:
135+
registry: quay.io
136+
# secret_rabbitmq/kv/oss%2Frabbitmq-cluster-operator%2Fsecrets/details
137+
username: ${{ secrets.QUAY_USERNAME }}
138+
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
139+
140+
- name: Run test
141+
env:
142+
IMAGE: ${{ vars.UNTESTED_BUNDLE_IMAGE }}:${{ needs.create-olm-package.outputs.olm_package_version }}
143+
BUNDLE_VERSION: ${{ needs.create-olm-package.outputs.olm_package_version }}
144+
# Used to create a temporary OLM catalog to validate the bundle
145+
CATALOG_IMAGE: ${{ vars.TEST_CATALOG_IMAGE }}
146+
# The test suite is sensible to the working directory, and go-test always sets the working directory
147+
# to the package path (i.e. olm/test). As a workaround, we compile the test in a binary, and then
148+
# run it from the repo root directory
149+
run: |
150+
go test -c -o olm.test ./olm/test/
151+
./olm.test
152+
153+
- name: Promote tested image
154+
if: ${{ github.event_name == 'release' || inputs.release == true }}
155+
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 }}
156+
157+
publish-bundle-operatorhub:
158+
if: ${{ github.event_name == 'release' || inputs.release == true }}
159+
name: PR OperatorHub repo
160+
runs-on: ubuntu-latest
161+
needs: test-olm-package
162+
steps:
163+
- name: Checkout community-operators fork (OperatorHub)
164+
uses: actions/checkout@v4
165+
with:
166+
repository: rabbitmq/community-operators
167+
# secret_rabbitmq/kv/oss%2Frabbitmq-cluster-operator%2Fsecrets/details
168+
token: ${{ secrets.RABBITMQ_CI_TOKEN }}
169+
170+
- name: Download OLM artifact
171+
uses: actions/download-artifact@v4
172+
with:
173+
name: bundle-manifest
174+
path: olm-package-ci
175+
176+
- name: Create branch for OperatorHub PR
177+
env:
178+
BUNDLE_VERSION: ${{ needs.test-olm-package.outputs.olm_package_version }}
179+
GH_PROMPT_DISABLED: 1
180+
GH_TOKEN: ${{ secrets.RABBITMQ_CI_TOKEN }}
181+
run: |
182+
git config user.name "rabbitmq-ci"
183+
git config user.email ${{ secrets.RABBITMQ_CI_EMAIL }}
184+
git branch "rabbitmq-cluster-operator-$BUNDLE_VERSION"
185+
git checkout "rabbitmq-cluster-operator-$BUNDLE_VERSION"
186+
187+
mkdir -pv operators/rabbitmq-cluster-operator/"$BUNDLE_VERSION"
188+
cp -v -fR olm-package-ci/* ./operators/rabbitmq-cluster-operator/"$BUNDLE_VERSION"/
189+
git add operators/rabbitmq-cluster-operator
190+
git commit -s -m "operator rabbitmq-cluster-operator release $BUNDLE_VERSION"
191+
git push --set-upstream origin "rabbitmq-cluster-operator-$BUNDLE_VERSION"
192+
193+
gh pr create --title "operator rabbitmq-cluster-operator (${{ env.BUNDLE_VERSION }})" \
194+
--body "Update operator rabbitmq-cluster-operator (${{ needs.test-olm-package.outputs.olm_package_version }})" \
195+
--repo k8s-operatorhub/community-operators
196+
197+
publish-bundle-redhat-marketplace:
198+
name: PR Openshift marketplace
199+
runs-on: ubuntu-latest
200+
needs: test-olm-package
201+
if: ${{ github.event_name == 'release' || inputs.release == true }}
202+
steps:
203+
- name: Checkout community-operators-prod fork (Openshift Ecosystem)
204+
uses: actions/checkout@v4
205+
with:
206+
repository: rabbitmq/community-operators-prod
207+
# secret_rabbitmq/kv/oss%2Frabbitmq-cluster-operator%2Fsecrets/details
208+
token: ${{ secrets.RABBITMQ_CI_TOKEN }}
209+
210+
- name: Download OLM artifact
211+
uses: actions/download-artifact@v4
212+
with:
213+
name: bundle-manifest
214+
path: olm-package-ci
215+
216+
- name: Create branch for Openshift Ecosystem PR
217+
env:
218+
BUNDLE_VERSION: ${{ needs.test-olm-package.outputs.olm_package_version }}
219+
# RABBITMQ_CI_EMAIL: secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
220+
GH_PROMPT_DISABLED: 1
221+
GH_TOKEN: ${{ secrets.RABBITMQ_CI_TOKEN }}
222+
# IMPORTANT: this job does not open the PR automatically because the operator is configured differently in
223+
# RedHat marketplace CI. In RedHat Marketplace, we have semver-mode for update strategy, and in operatorhub
224+
# we have replaces-mode strategy.
225+
# https://k8s-operatorhub.github.io/community-operators/operator-ci-yaml/
226+
# As workaround, this job will create the branch with the new version, and a maintainer will make adjustments
227+
# before manually opening a PR.
228+
# TODO(Zerpet): make update strategy consistent
229+
run: |
230+
git config user.name "rabbitmq-ci"
231+
git config user.email ${{ secrets.RABBITMQ_CI_EMAIL }}
232+
git branch "rabbitmq-cluster-operator-$BUNDLE_VERSION"
233+
git checkout "rabbitmq-cluster-operator-$BUNDLE_VERSION"
234+
235+
mkdir -pv operators/rabbitmq-cluster-operator/"$BUNDLE_VERSION"
236+
cp -v -fR olm-package-ci/* ./operators/rabbitmq-cluster-operator/"$BUNDLE_VERSION"/
237+
git add operators/rabbitmq-cluster-operator
238+
git commit -s -m "operator rabbitmq-cluster-operator release $BUNDLE_VERSION"
239+
git push --set-upstream origin "rabbitmq-cluster-operator-$BUNDLE_VERSION"

0 commit comments

Comments
 (0)