Skip to content

Refactor olm #1895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 236 additions & 0 deletions .github/workflows/olm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
---
name: Test & Publish OLM Package

on:
release:
types: [ published ]

workflow_dispatch:
inputs:
bundle_version:
description: version in format {major}.{minor}.{patch} (do not prefix with "v")
required: true
type: string
release:
default: false
type: boolean
required: false
description: Make a release PR to operatorhub?

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
create-olm-package:
name: Create the OLM Packaging
runs-on: ubuntu-latest
outputs:
olm_package_version: ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set image tag to tagged release
id: set_bundle_version
shell: bash
run: scripts/print-tag-version.bash ${{ inputs.bundle_version }} | tee -a "$GITHUB_OUTPUT"

- id: set_previous_version
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: scripts/print-previous-version.bash | tee -a "$GITHUB_OUTPUT"

- name: Openshift tools
uses: redhat-actions/openshift-tools-installer@v1
with:
# Using GitHub source because the Openshift mirror source binary file does not match the expected name
# pattern. In the mirror, the filename is opm-rhel8, and the Action is expecting the name as opm-${OS}-${ARCH}
source: github
github_pat: ${{ github.token }}
opm: latest

- name: carvel-setup-action
uses: carvel-dev/[email protected]
with:
token: ${{ github.token }}
only: ytt

- name: Login to quay.io
uses: docker/login-action@v3
with:
registry: quay.io
# secret_rabbitmq/kv/oss%2Frabbitmq-cluster-operator%2Fsecrets/details
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}

- name: Create OLM bundle manifests
env:
QUAY_IO_OPERATOR_IMAGE: quay.io/rabbitmqoperator/cluster-operator:${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
BUNDLE_VERSION: ${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
BUNDLE_REPLACES: ${{ steps.set_previous_version.outputs.PREVIOUS_VERSION }}
run: make -f olm.mk all

- name: Create OLM Package
env:
REGISTRY: quay.io
IMAGE: ${{ vars.UNTESTED_BUNDLE_IMAGE }}:${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
run: make -f olm.mk docker-build docker-push

- name: Validate bundle manifests
env:
REGISTRY: quay.io
IMAGE: ${{ vars.UNTESTED_BUNDLE_IMAGE }}:${{ steps.set_bundle_version.outputs.BUNDLE_VERSION }}
run: opm alpha bundle validate --tag ${{ env.REGISTRY }}/${{ env.IMAGE }} --image-builder docker

- name: Upload manifests
uses: actions/upload-artifact@v4
with:
name: bundle-manifest
path: |
olm/manifests
olm/metadata
olm/bundle.Dockerfile
if-no-files-found: error
retention-days: 1

test-olm-package:
name: Tests the OLM packaging
runs-on: ubuntu-latest
needs: create-olm-package
outputs:
# Required to pass on the OLM bundle version to publish job
olm_package_version: ${{ needs.create-olm-package.outputs.olm_package_version }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: Kubectl tool installer
uses: Azure/[email protected]
- name: Setup YTT
uses: carvel-dev/[email protected]
with:
token: ${{ github.token }}
only: ytt, imgpkg

- name: Kind Cluster
uses: helm/kind-action@v1

- name: Install OLM
run: |
curl -L https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.32.0/install.sh -o install.sh
chmod +x install.sh
./install.sh v0.32.0

- name: Login to quay.io
uses: docker/login-action@v3
with:
registry: quay.io
# secret_rabbitmq/kv/oss%2Frabbitmq-cluster-operator%2Fsecrets/details
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}

- name: Run test
env:
IMAGE: ${{ vars.UNTESTED_BUNDLE_IMAGE }}:${{ needs.create-olm-package.outputs.olm_package_version }}
BUNDLE_VERSION: ${{ needs.create-olm-package.outputs.olm_package_version }}
# Used to create a temporary OLM catalog to validate the bundle
CATALOG_IMAGE: ${{ vars.TEST_CATALOG_IMAGE }}
# The test suite is sensible to the working directory, and go-test always sets the working directory
# to the package path (i.e. olm/test). As a workaround, we compile the test in a binary, and then
# run it from the repo root directory
run: |
go test -c -o olm.test ./olm/test/
./olm.test

- name: Promote tested image
if: ${{ github.event_name == 'release' || inputs.release == true }}
run: imgpkg copy --image ${{ vars.UNTESTED_BUNDLE_IMAGE }}:${{ needs.create-olm-package.outputs.olm_package_version }} --to-repo ${{ vars.FINAL_BUNDLE_IMAGE }}

publish-bundle-operatorhub:
if: ${{ github.event_name == 'release' || inputs.release == true }}
name: PR OperatorHub repo
runs-on: ubuntu-latest
needs: test-olm-package
steps:
- name: Checkout community-operators fork (OperatorHub)
uses: actions/checkout@v4
with:
repository: rabbitmq/community-operators
# secret_rabbitmq/kv/oss%2Frabbitmq-cluster-operator%2Fsecrets/details
token: ${{ secrets.RABBITMQ_CI_TOKEN }}

- name: Download OLM artifact
uses: actions/download-artifact@v4
with:
name: bundle-manifest
path: olm-package-ci

- name: Create branch for OperatorHub PR
env:
BUNDLE_VERSION: ${{ needs.test-olm-package.outputs.olm_package_version }}
# RABBITMQ_CI_EMAIL: secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
### operators/rabbitmq-cluster-operator
GH_PROMPT_DISABLED: 1
GH_TOKEN: ${{ github.token }}
run: |
git config user.name "rabbitmq-ci"
git config user.email ${{ secrets.RABBITMQ_CI_EMAIL }}
git branch "rabbitmq-cluster-operator-$BUNDLE_VERSION"
git checkout "rabbitmq-cluster-operator-$BUNDLE_VERSION"

mkdir -pv operators/rabbitmq-cluster-operator/"$BUNDLE_VERSION"
cp -v -fR olm-package-ci/* ./operators/rabbitmq-cluster-operator/"$BUNDLE_VERSION"/
git add operators/rabbitmq-cluster-operator
git commit -s -m "RabbitMQ Cluster Operator release $BUNDLE_VERSION"

gh pr create --title "operator rabbitmq-cluster-operator (${{ env.BUNDLE_VERSION }})" \
--body "Update operator rabbitmq-cluster-operator (${{ needs.test-olm-package.outputs.olm_package_version }})" \
--dry-run

publish-bundle-redhat-marketplace:
name: PR Openshift marketplace
runs-on: ubuntu-latest
needs: test-olm-package
if: ${{ github.event_name == 'release' || inputs.release == true }}
steps:
- name: Checkout community-operators-prod fork (Openshift Ecosystem)
uses: actions/checkout@v4
with:
repository: rabbitmq/community-operators-prod
# secret_rabbitmq/kv/oss%2Frabbitmq-cluster-operator%2Fsecrets/details
token: ${{ secrets.RABBITMQ_CI_TOKEN }}

- name: Download OLM artifact
uses: actions/download-artifact@v4
with:
name: bundle-manifest
path: olm-package-ci

- name: Create branch for Openshift Ecosystem PR
env:
BUNDLE_VERSION: ${{ needs.test-olm-package.outputs.olm_package_version }}
# RABBITMQ_CI_EMAIL: secret_rabbitmq/kv/Shared-Shared-RabbitMQ%2Frabbitmq-ci/details
GH_PROMPT_DISABLED: 1
GH_TOKEN: ${{ github.token }}
run: |
git config user.name "rabbitmq-ci"
git config user.email ${{ secrets.RABBITMQ_CI_EMAIL }}
git branch "rabbitmq-cluster-operator-$BUNDLE_VERSION"
git checkout "rabbitmq-cluster-operator-$BUNDLE_VERSION"

mkdir -pv operators/rabbitmq-cluster-operator/"$BUNDLE_VERSION"
cp -v -fR olm-package-ci/* ./operators/rabbitmq-cluster-operator/"$BUNDLE_VERSION"/
git add operators/rabbitmq-cluster-operator
git commit -s -m "RabbitMQ Cluster Operator release $BUNDLE_VERSION"

gh pr create --title "operator rabbitmq-cluster-operator (${{ env.BUNDLE_VERSION }})" \
--body "Update operator rabbitmq-cluster-operator (${{ needs.test-olm-package.outputs.olm_package_version }})" \
--dry-run
Loading
Loading