Skip to content

Commit 233c08a

Browse files
committed
Change actions to run documented examples in parallel with matrix.
1 parent 9b88f8c commit 233c08a

File tree

1 file changed

+40
-11
lines changed

1 file changed

+40
-11
lines changed

.github/workflows/build-test-publish.yml

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -364,21 +364,32 @@ jobs:
364364
make cert-manager
365365
SUPPORT_VOLUME_EXPANSION=false make system-tests
366366
367+
examples_matrix:
368+
runs-on: ubuntu-latest
369+
outputs:
370+
examples_matrix: $${{ steps.list_examples.outputs.examples_matrix }}
371+
steps:
372+
- name: Check out code
373+
uses: actions/checkout@v5
374+
375+
- name: List Examples
376+
id: list_examples
377+
run: |
378+
echo -n 'examples_matrix=' >> $GITHUB_OUTPUT
379+
find "$PWD" -mindepth 1 -type d | jq -R -s -c 'split("\n") | map(select(length > 0))' >> $GITHUB_OUTPUT
380+
367381
test_doc_examples:
368382
name: Documented example tests
369383
runs-on: ubuntu-latest
370384
if: ${{ github.event_name != 'pull_request' }}
371-
needs: build_operator
385+
needs: [build_operator, examples_matrix]
386+
strategy:
387+
matrix:
388+
example: ${{ fromJSON(needs.examples_matrix.outputs.examples_matrix) }}
372389
steps:
373390
- name: Check out code into the Go module directory
374391
uses: actions/checkout@v5
375392

376-
- name: Install Go
377-
uses: actions/setup-go@v6
378-
with:
379-
go-version: ${{ env.GO_VERSION }}
380-
check-latest: true
381-
382393
- name: Download Operator artifact
383394
uses: actions/download-artifact@v5
384395
with:
@@ -407,21 +418,39 @@ jobs:
407418

408419
- name: Install Operator build
409420
run: |
410-
make destroy
411421
kind load image-archive /tmp/operator.tar --name examples-testing
412422
ytt -f tmp/cluster-operator.yml -f config/ytt/never_pull.yaml | kubectl apply -f-
413423
kubectl --namespace=rabbitmq-system wait --for=condition=Available deployment/rabbitmq-cluster-operator
414424
415-
- name: Documented example tests
416-
run: docs/examples/test.sh
425+
- name: Documented example ${{ matrix.example }} test
426+
env:
427+
example: ${{ matrix.example }}
428+
run: |
429+
# Exit early if this example is to be skipped in CI
430+
[[ -e "$example"/.ci-skip ]] && exit 0
431+
432+
make cert-manager
433+
printf("apiVersion: cert-manager.io/v1\nkind: ClusterIssuer\nmetadata:\n name: selfsigned-issuer\nspec:\n selfSigned: {}\n") | kubectl apply -f -
434+
435+
pushd "$example"
436+
kubectl create namespace examples
437+
kubectl config set-context --current --namespace=examples
438+
[[ -e setup.sh ]] && ./setup.sh
439+
kubectl apply -f rabbitmq.yaml --timeout=30s
440+
kubectl wait -f rabbitmq.yaml --for=condition=AllReplicasReady --timeout=5m
441+
kubectl wait -f rabbitmq.yaml --for=condition=ReconcileSuccess --timeout=5m
442+
./test.sh
443+
kubectl delete -f rabbitmq.yaml --timeout=3m
444+
kubectl delete namespace examples --timeout=10m
445+
popd
417446
418447
- name: Notify Google Chat
419448
if: failure()
420449
uses: SimonScholz/google-chat-action@main
421450
with:
422451
webhookUrl: '${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}'
423452
jobStatus: ${{ job.status }}
424-
title: Cluster Operator - Documented example tests
453+
title: Cluster Operator - Documented example ${{ matrix.example }} test
425454

426455
test_upgrade:
427456
name: Test upgrade of the operator

0 commit comments

Comments
 (0)