diff --git a/.github/workflows/olm-e2e.yml b/.github/workflows/olm-e2e.yml new file mode 100644 index 000000000..776e712c3 --- /dev/null +++ b/.github/workflows/olm-e2e.yml @@ -0,0 +1,192 @@ +name: OLM E2E + +on: + pull_request: + workflow_dispatch: + +jobs: + olm-e2e: + name: OLM bundle, catalog, deploy, scorecard + runs-on: ubuntu-latest + env: + REGISTRY: localhost:5001 + NAMESPACE: cass-operator + CHANNELS: dev + DEFAULT_CHANNEL: dev + steps: + - name: Free diskspace by removing unused packages + shell: bash + run: | + sudo rm -rf /usr/local/lib/android + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + - name: Checkout + uses: actions/checkout@v4 + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: 'go.mod' + cache: false + - name: Install yq + run: | + sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/v4.44.3/yq_linux_amd64 + sudo chmod +x /usr/local/bin/yq + # The runners already have the latest versions of tools, no need to reinstall them + - name: Link tools + shell: bash + run: | + mkdir bin + ln -s /usr/local/bin/kustomize bin/kustomize + - name: Create kind cluster + shell: bash + run: | + hack/cluster.sh + - name: Build and push operator images to local registry + run: | + make REGISTRY=${{ env.REGISTRY }} ORG=localhost:5001/k8ssandra docker-build docker-logger-build docker-push docker-logger-push + - name: Generate OLM bundle + run: | + make REGISTRY=${{ env.REGISTRY }} ORG=localhost:5001/k8ssandra bundle + bin/operator-sdk bundle validate ./bundle --select-optional suite=operatorframework + - name: Build and push bundle image to local registry + run: | + make ORG=localhost:5001/k8ssandra bundle-build bundle-push + - name: Build and push catalog (index) image to local registry + run: | + make ORG=localhost:5001/k8ssandra catalog-build catalog-push + - name: Install OLM + run: | + bin/operator-sdk olm install --timeout 5m + kubectl get pods -n olm + - name: Run OLM deployment from bundle image + run: | + BUNDLE_IMG=${{ env.REGISTRY }}/k8ssandra/cass-operator-bundle:v$(make version) + kubectl create ns ${{ env.NAMESPACE }} || true + bin/operator-sdk run bundle $BUNDLE_IMG --namespace ${{ env.NAMESPACE }} --timeout 10m --use-http --verbose + # Wait for CSV to succeed + kubectl -n ${{ env.NAMESPACE }} wait --for=jsonpath='{.status.phase}'=Succeeded csv --all --timeout=300s + kubectl -n ${{ env.NAMESPACE }} get csv + kubectl -n ${{ env.NAMESPACE }} get deploy,po + - name: Run scorecard (olm suite) + run: | + bin/operator-sdk scorecard ./bundle --selector=suite=olm --verbose + - name: Red Hat static checks (bundle) + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install operator static tests + run: | + python -m pip install --upgrade pip + python -m pip install git+https://github.com/redhat-openshift-ecosystem/operator-pipelines.git + + - name: Prepare bundle for static checks + id: prep_static + run: | + OP_NAME=$(yq -r '."operators.operatorframework.io.bundle.package.v1"' bundle/metadata/annotations.yaml) + CSV_VERSION=$(yq -r '.spec.version' bundle/manifests/*.clusterserviceversion.yaml) + echo "op_name=${OP_NAME}" >> $GITHUB_OUTPUT + echo "csv_version=${CSV_VERSION}" >> $GITHUB_OUTPUT + mkdir -p /tmp/community-operators-prod/operators/${OP_NAME}/${CSV_VERSION} + cp -r bundle/manifests /tmp/community-operators-prod/operators/${OP_NAME}/${CSV_VERSION}/ + cp -r bundle/metadata /tmp/community-operators-prod/operators/${OP_NAME}/${CSV_VERSION}/ + echo "Prepared repo structure at /tmp/community-operators-prod" + + - name: Run static checks + run: | + static-tests \ + --repo-path /tmp/community-operators-prod \ + --suites operatorcert.static_tests.community \ + --output-file /tmp/operator-static.json \ + --verbose \ + ${{ steps.prep_static.outputs.op_name }} ${{ steps.prep_static.outputs.csv_version }} + echo "Static checks output:" + cat /tmp/operator-static.json || true + + - name: Cleanup bundle install (pre-catalog) + if: always() + run: | + set +e + # Remove the operator deployed via run bundle + bin/operator-sdk cleanup cass-operator --namespace ${{ env.NAMESPACE }} || true + # Ensure namespace is clean for catalog stage + kubectl delete csv --all -n ${{ env.NAMESPACE }} || true + kubectl delete deploy --all -n ${{ env.NAMESPACE }} || true + kubectl delete po --all -n ${{ env.NAMESPACE }} || true + + - name: Create CatalogSource for local catalog + run: | + cat <