From 97b873c286c5851142c0250d91eff6f7ed969f59 Mon Sep 17 00:00:00 2001
From: Itay Grudev <itay.grudev@essentim.com>
Date: Mon, 9 Sep 2024 02:38:55 +0300
Subject: [PATCH] Running tests in paralles with a matrix strategy

Signed-off-by: Itay Grudev <itay.grudev@essentim.com>
---
 .github/workflows/tests-cluster-chainsaw.yaml | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/tests-cluster-chainsaw.yaml b/.github/workflows/tests-cluster-chainsaw.yaml
index 555b3fe07..40188c87e 100644
--- a/.github/workflows/tests-cluster-chainsaw.yaml
+++ b/.github/workflows/tests-cluster-chainsaw.yaml
@@ -6,8 +6,23 @@ on:
       - 'gh-pages'
 
 jobs:
-  test-cluster-standalone:
+  test-list:
     runs-on: ubuntu-22.04
+    outputs:
+      tests: ${{ steps.listTests.outputs.tests }}
+    steps:
+      - name: Checkout
+        uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
+        with:
+          fetch-depth: 1
+      - id: listTests
+        run: |
+          echo "tests=$(ls charts/cluster/test -1 | jq -cRn '{ include: [inputs | { test: "\(.)" }]}')" >> $GITHUB_OUTPUT
+  test:
+    needs: test-list
+    runs-on: ubuntu-22.04
+    strategy:
+      matrix: ${{ fromJson(needs.test-list.outputs.tests) }}
     steps:
       - name: Checkout
         uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
@@ -46,4 +61,4 @@ jobs:
             tenant minio-operator/tenant
 
       - name: Run Kyverno/Chainsaw
-        run: chainsaw test
+        run: chainsaw test charts/cluster/test/${{matrix.test}}