Skip to content

Commit 082df72

Browse files
Migrating OLM testing pipeline from concourse to github-action (#1569)
* WIP: migrating OLM (operator lifecycle manager) pipeline from Concourse to github action * refactoring * adding_publishing_task * removing build_image job * better management of versions * adding lock to protect the openshift cluster * removing operatorhub publication action * modify repo name and added retention days in upload artifacts * modify infra repo access token name * removing branch in OLM_Package_Repo and trigger event type * using push as trigger * using quay registry instead of dockerhub * removing testing branches and modify trigger * using checkout instead of cloning * reverting trigger
1 parent b6609a7 commit 082df72

File tree

2 files changed

+203
-73
lines changed

2 files changed

+203
-73
lines changed

.github/workflows/operatorhub.yml

-73
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
# action to test our operator lifecycle manager bundle
2+
# See https://github.com/rabbitmq/OLM-Package-Repo for more info.
3+
name: test-and-publish-OLM-bundle
4+
5+
on:
6+
release:
7+
types: [published]
8+
9+
workflow_dispatch:
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
env:
16+
# registry information where we want to store the operator image and the operator index image
17+
DOCKER_REGISTRY_SERVER: quay.io/rabbitmqoperator
18+
OLM_IMAGE: rabbitmq-for-kubernetes-olm-cluster-operator
19+
OLM_INDEX_IMAGE: rabbitmq-for-kubernetes-olm-cluster-operator-index
20+
21+
jobs:
22+
create-olm-package:
23+
name: Create the OLM Packaging
24+
runs-on: ubuntu-latest
25+
container:
26+
image: us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-ci-olm
27+
options: --privileged
28+
permissions:
29+
contents: 'write'
30+
id-token: 'write'
31+
steps:
32+
- name: Checkout
33+
uses: actions/checkout@v4
34+
- name: Checkout OLM-Package-Repo
35+
uses: actions/checkout@v4
36+
with:
37+
repository: rabbitmq/OLM-Package-Repo
38+
path: ./OLM-Package-Repo
39+
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
45+
46+
- name: Set tag image for test version
47+
if: startsWith(github.ref, 'refs/tags/v') == false
48+
run: |
49+
echo "BUNDLE_VERSION=0.0.0" >> $GITHUB_ENV
50+
51+
- name: create-olm-package
52+
env:
53+
username: ${{ secrets.QUAY_USERNAME }}
54+
password: ${{ secrets.QUAY_ROBOT_TOKEN }}
55+
DOCKER_REGISTRY_SERVER: ${{ env.DOCKER_REGISTRY_SERVER }}
56+
OLM_IMAGE: ${{ env.OLM_IMAGE }}
57+
OLM_INDEX_IMAGE: ${{ env.OLM_INDEX_IMAGE }}
58+
BUNDLE_VERSION: ${{ env.BUNDLE_VERSION }}
59+
run: |
60+
sed '/mount_program =/s/^#//' -i /etc/containers/storage.conf
61+
podman login quay.io -u $username -p $password
62+
make generate-installation-manifest
63+
cp ./config/crd/bases/rabbitmq.com_rabbitmqclusters.yaml ./OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/manifests_crds/crds.yaml
64+
cp ./releases/cluster-operator.yml ./OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/manifests_crds/cluster-operator.yaml
65+
cp OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/generators/cluster-service-version-generator-test.yml OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/generators/cluster-service-version-generator.yml
66+
cd ./OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/
67+
python3 generate-olm-package.py ./manifests_crds/cluster-operator.yaml $BUNDLE_VERSION ./
68+
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
69+
podman push $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:$BUNDLE_VERSION
70+
opm index add -b $DOCKER_REGISTRY_SERVER/$OLM_IMAGE:$BUNDLE_VERSION -t $DOCKER_REGISTRY_SERVER/$OLM_INDEX_IMAGE:$BUNDLE_VERSION -c podman
71+
podman push $DOCKER_REGISTRY_SERVER/$OLM_INDEX_IMAGE:$BUNDLE_VERSION
72+
mkdir upload
73+
mv "$BUNDLE_VERSION" ./upload
74+
cp ./generators/cluster-service-version-generator-openshift.yml ./generators/cluster-service-version-generator.yml
75+
python3 generate-olm-package.py ./manifests_crds/cluster-operator.yaml "$BUNDLE_VERSION" ./
76+
mv "$BUNDLE_VERSION" ./upload/$BUNDLE_VERSION-openshift
77+
- name: upload-olm-package
78+
uses: actions/upload-artifact@master
79+
with:
80+
name: olm-artifact
81+
path: "/home/runner/work/cluster-operator/cluster-operator/OLM-Package-Repo/generate_OLM/generate_OLM_cluster_operator/upload/"
82+
retention-days: 2
83+
84+
test-olm-package:
85+
name: Tests the OLM packaging
86+
runs-on: ubuntu-latest
87+
needs: create-olm-package
88+
container: us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-ci-olm
89+
90+
steps:
91+
- name: Checkout
92+
uses: actions/checkout@v4
93+
- name: Checkout infrastructure repo
94+
uses: actions/checkout@v4
95+
with:
96+
repository: rabbitmq/infrastructure
97+
token: ${{ secrets.GIT_HUB_INFRA_REPO_ACCESS_TOKEN }}
98+
path: ./infrastructure
99+
- name: Checkout OLM-Package-Repo
100+
uses: actions/checkout@v4
101+
with:
102+
repository: rabbitmq/OLM-Package-Repo
103+
path: ./OLM-Package-Repo
104+
105+
- name: Protect access to the cluster with a mutex
106+
uses: ben-z/[email protected]
107+
with:
108+
branch: openshift-lock
109+
110+
- name: Connect to the Openshift cluster and deploy the operators through OLM
111+
env:
112+
TOKEN: ${{ secrets.OPERATORHUB_TOKEN }}
113+
BUNDLE_VERSION: ${{ env.BUNDLE_VERSION }}
114+
run: |
115+
mkdir $HOME/.kube
116+
cp ./infrastructure/k8s/okd/admin-kubeconfig.yaml $HOME/.kube/config
117+
export KUBECONFIG=$HOME/.kube/config
118+
export ENVIRONMENT=openshift
119+
kubectl config use-context admin
120+
./OLM-Package-Repo/testfiles/install-rabbitmq-cluster-operator.sh $BUNDLE_VERSION
121+
export K8S_OPERATOR_NAMESPACE=rabbitmq-system-olm
122+
export SYSTEM_TEST_NAMESPACE=rabbitmq-system-olm
123+
make system-tests
124+
125+
- name: Clean up
126+
env:
127+
OLM_INDEX_TAG: ${{ env.BUNDLE_VERSION }}
128+
if: always()
129+
run: |
130+
export KUBECONFIG=./infrastructure/k8s/okd/admin-kubeconfig.yaml
131+
kubectl config use-context admin
132+
./OLM-Package-Repo/testfiles/uninstall-rabbitmq-cluster-operator.sh $BUNDLE_VERSION
133+
134+
publish-bundle:
135+
name: Publish on OperatorHub and Openshift market-place
136+
runs-on: ubuntu-latest
137+
needs: test-olm-package
138+
container: us.gcr.io/cf-rabbitmq-for-k8s-bunny/rabbitmq-for-kubernetes-ci-olm
139+
# Create the PR to OperatorHUB
140+
steps:
141+
- name: Checkout
142+
uses: actions/checkout@v4
143+
- name: Checkout community-operators repo
144+
uses: actions/checkout@v4
145+
with:
146+
repository: rabbitmq/community-operators
147+
path: ./community-operators
148+
token: ${{ secrets.OPERATORHUB_TOKEN }}
149+
- name: Checkout community-operators-prod repo
150+
uses: actions/checkout@v4
151+
with:
152+
repository: rabbitmq/community-operators-prod
153+
path: ./community-operators-prod
154+
token: ${{ secrets.OPERATORHUB_TOKEN }}
155+
156+
- name: Set tag image for tagged version
157+
if: startsWith(github.ref, 'refs/tags/v')
158+
run: |
159+
BUNDLE_VERSION=${GITHUB_REF#refs/*/}
160+
echo "BUNDLE_VERSION=${BUNDLE_VERSION:1}" >> $GITHUB_ENV
161+
162+
- name: Set tag image for test version
163+
if: startsWith(github.ref, 'refs/tags/v') == false
164+
run: |
165+
echo "BUNDLE_VERSION=0.0.0" >> $GITHUB_ENV
166+
167+
- name: download olm-artifact from previous step
168+
uses: actions/download-artifact@master
169+
with:
170+
name: olm-artifact
171+
- name: CreateOperatorHubPR
172+
env:
173+
TOKEN: ${{ secrets.OPERATORHUB_TOKEN }}
174+
BUNDLE_VERSION: ${{ env.BUNDLE_VERSION }}
175+
run: |
176+
git config --global user.name "DanielePalaia"
177+
git config --global user.email "[email protected]"
178+
mkdir -p community-operators/operators/rabbitmq-cluster-operator
179+
cd community-operators/operators/rabbitmq-cluster-operator
180+
git branch rabbitmq-cluster-operator-$BUNDLE_VERSION
181+
git checkout rabbitmq-cluster-operator-$BUNDLE_VERSION
182+
cp -fR ./../../../$BUNDLE_VERSION .
183+
sed -i -e "s/latest/$BUNDLE_VERSION/g" ./$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml
184+
git add .
185+
git commit -s -m "RabbitMQ operator new release"
186+
git push https://DanielePalaia:"$TOKEN"@github.com/rabbitmq/community-operators
187+
cd ./../../..
188+
189+
# Create the PR to redhat openshift ecosystem
190+
- name: CreateOpenshiftEcosystemPR
191+
env:
192+
TOKEN: ${{ secrets.OPERATORHUB_TOKEN }}
193+
BUNDLE_VERSION: ${{ env.BUNDLE_VERSION }}
194+
run: |
195+
cd community-operators-prod/operators/rabbitmq-cluster-operator
196+
git branch rabbitmq-cluster-operator-$BUNDLE_VERSION
197+
git checkout rabbitmq-cluster-operator-$BUNDLE_VERSION
198+
cp -fR ./../../../$BUNDLE_VERSION-openshift .
199+
mv $BUNDLE_VERSION-openshift $BUNDLE_VERSION
200+
sed -i -e "s/latest/$BUNDLE_VERSION/g" ./$BUNDLE_VERSION/manifests/rabbitmq.clusterserviceversion.yaml
201+
git add .
202+
git commit -s -m "RabbitMQ operator new release"
203+
git push https://DanielePalaia:"$TOKEN"@github.com/rabbitmq/community-operators-prod

0 commit comments

Comments
 (0)