From 233c08a873502f15e53104ef6b659ad825dca312 Mon Sep 17 00:00:00 2001 From: Mirah Gary Date: Wed, 8 Oct 2025 15:21:02 +0200 Subject: [PATCH 1/3] Change actions to run documented examples in parallel with matrix. --- .github/workflows/build-test-publish.yml | 51 +++++++++++++++++++----- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 84b844e63..285b55b60 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -364,21 +364,32 @@ jobs: make cert-manager SUPPORT_VOLUME_EXPANSION=false make system-tests + examples_matrix: + runs-on: ubuntu-latest + outputs: + examples_matrix: $${{ steps.list_examples.outputs.examples_matrix }} + steps: + - name: Check out code + uses: actions/checkout@v5 + + - name: List Examples + id: list_examples + run: | + echo -n 'examples_matrix=' >> $GITHUB_OUTPUT + find "$PWD" -mindepth 1 -type d | jq -R -s -c 'split("\n") | map(select(length > 0))' >> $GITHUB_OUTPUT + test_doc_examples: name: Documented example tests runs-on: ubuntu-latest if: ${{ github.event_name != 'pull_request' }} - needs: build_operator + needs: [build_operator, examples_matrix] + strategy: + matrix: + example: ${{ fromJSON(needs.examples_matrix.outputs.examples_matrix) }} steps: - name: Check out code into the Go module directory uses: actions/checkout@v5 - - name: Install Go - uses: actions/setup-go@v6 - with: - go-version: ${{ env.GO_VERSION }} - check-latest: true - - name: Download Operator artifact uses: actions/download-artifact@v5 with: @@ -407,13 +418,31 @@ jobs: - name: Install Operator build run: | - make destroy kind load image-archive /tmp/operator.tar --name examples-testing ytt -f tmp/cluster-operator.yml -f config/ytt/never_pull.yaml | kubectl apply -f- kubectl --namespace=rabbitmq-system wait --for=condition=Available deployment/rabbitmq-cluster-operator - - name: Documented example tests - run: docs/examples/test.sh + - name: Documented example ${{ matrix.example }} test + env: + example: ${{ matrix.example }} + run: | + # Exit early if this example is to be skipped in CI + [[ -e "$example"/.ci-skip ]] && exit 0 + + make cert-manager + printf("apiVersion: cert-manager.io/v1\nkind: ClusterIssuer\nmetadata:\n name: selfsigned-issuer\nspec:\n selfSigned: {}\n") | kubectl apply -f - + + pushd "$example" + kubectl create namespace examples + kubectl config set-context --current --namespace=examples + [[ -e setup.sh ]] && ./setup.sh + kubectl apply -f rabbitmq.yaml --timeout=30s + kubectl wait -f rabbitmq.yaml --for=condition=AllReplicasReady --timeout=5m + kubectl wait -f rabbitmq.yaml --for=condition=ReconcileSuccess --timeout=5m + ./test.sh + kubectl delete -f rabbitmq.yaml --timeout=3m + kubectl delete namespace examples --timeout=10m + popd - name: Notify Google Chat if: failure() @@ -421,7 +450,7 @@ jobs: with: webhookUrl: '${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}' jobStatus: ${{ job.status }} - title: Cluster Operator - Documented example tests + title: Cluster Operator - Documented example ${{ matrix.example }} test test_upgrade: name: Test upgrade of the operator From deb4ffd6cc751a1917825ded6c35be1ba1acdfbb Mon Sep 17 00:00:00 2001 From: Mirah Gary Date: Wed, 8 Oct 2025 15:40:08 +0200 Subject: [PATCH 2/3] Run examples on PRs. --- .github/workflows/build-test-publish.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index 285b55b60..f798e5845 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -381,7 +381,6 @@ jobs: test_doc_examples: name: Documented example tests runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' }} needs: [build_operator, examples_matrix] strategy: matrix: From 2417a00554d7814f18d3d01218aa3ca6537c9aac Mon Sep 17 00:00:00 2001 From: Mirah Gary Date: Wed, 8 Oct 2025 16:07:24 +0200 Subject: [PATCH 3/3] Remove superfluous $ added helpfully by code. --- .github/workflows/build-test-publish.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-test-publish.yml b/.github/workflows/build-test-publish.yml index f798e5845..8e144b606 100644 --- a/.github/workflows/build-test-publish.yml +++ b/.github/workflows/build-test-publish.yml @@ -367,7 +367,7 @@ jobs: examples_matrix: runs-on: ubuntu-latest outputs: - examples_matrix: $${{ steps.list_examples.outputs.examples_matrix }} + examples_matrix: ${{ steps.list_examples.outputs.examples_matrix }} steps: - name: Check out code uses: actions/checkout@v5 @@ -376,7 +376,7 @@ jobs: id: list_examples run: | echo -n 'examples_matrix=' >> $GITHUB_OUTPUT - find "$PWD" -mindepth 1 -type d | jq -R -s -c 'split("\n") | map(select(length > 0))' >> $GITHUB_OUTPUT + find "$PWD/docs/examples" -mindepth 1 -type d | jq -R -s -c 'split("\n") | map(select(length > 0))' >> $GITHUB_OUTPUT test_doc_examples: name: Documented example tests @@ -389,6 +389,12 @@ jobs: - name: Check out code into the Go module directory uses: actions/checkout@v5 + - name: Install Go + uses: actions/setup-go@v6 + with: + go-version: ${{ env.GO_VERSION }} + check-latest: true + - name: Download Operator artifact uses: actions/download-artifact@v5 with: @@ -429,7 +435,7 @@ jobs: [[ -e "$example"/.ci-skip ]] && exit 0 make cert-manager - printf("apiVersion: cert-manager.io/v1\nkind: ClusterIssuer\nmetadata:\n name: selfsigned-issuer\nspec:\n selfSigned: {}\n") | kubectl apply -f - + printf "apiVersion: cert-manager.io/v1\nkind: ClusterIssuer\nmetadata:\n name: selfsigned-issuer\nspec:\n selfSigned: {}\n" | kubectl apply -f - pushd "$example" kubectl create namespace examples