From 756cd7f0e5d99080ffa7b4f50c8aebb6f8a72a0b Mon Sep 17 00:00:00 2001
From: Bart van der Braak <bartvdbraak@gmail.com>
Date: Fri, 1 Dec 2023 16:32:53 +0100
Subject: [PATCH] feat: use matrix strategy for testing

---
 .github/workflows/tests.yml | 72 ++++++++++---------------------------
 1 file changed, 18 insertions(+), 54 deletions(-)

diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 82db391..f066aff 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -73,67 +73,31 @@ jobs:
         git tag -fa deployed -m "Deployed to Azure"
         git push origin --tags --force
 
-  tests-no-access:
-    name: Tests with No Access
+  tests:
+    name: Run End-to-End Tests
     needs: bicep
     if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')
+    strategy:
+      matrix:
+        include:
+        - filter: no_access
+          client-id-ref: AZURE_CLIENT_ID_NO_ACCESS
+        - filter: only_get
+          client-id-ref: AZURE_CLIENT_ID_GET
+        - filter: only_list
+          client-id-ref: AZURE_CLIENT_ID_LIST
+        - filter: get_and_list_access
+          client-id-ref: AZURE_CLIENT_ID_GET_LIST
     runs-on: ubuntu-latest
     environment: test
     steps:
     - uses: actions/checkout@v4
     - uses: dtolnay/rust-toolchain@stable
-    - uses: azure/login@v1
+    - name: Azure Login
+      uses: azure/login@v1
       with:
-        client-id: ${{ secrets.AZURE_CLIENT_ID_NO_ACCESS }}
+        client-id: ${{ secrets[matrix.client-id-ref] }}
         tenant-id: ${{ secrets.AZURE_TENANT_ID }}
         subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
-    - name: Run all tests
-      run: cargo test no_access
-  tests-get:
-    name: Tests with Get
-    needs: bicep
-    if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')
-    runs-on: ubuntu-latest
-    environment: test
-    steps:
-    - uses: actions/checkout@v4
-    - uses: dtolnay/rust-toolchain@stable
-    - uses: azure/login@v1
-      with:
-        client-id: ${{ secrets.AZURE_CLIENT_ID_GET }}
-        tenant-id: ${{ secrets.AZURE_TENANT_ID }}
-        subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
-    - name: Run all tests
-      run: cargo test only_get
-  tests-list:
-    name: Tests with List
-    needs: bicep
-    if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')
-    runs-on: ubuntu-latest
-    environment: test
-    steps:
-    - uses: actions/checkout@v4
-    - uses: dtolnay/rust-toolchain@stable
-    - uses: azure/login@v1
-      with:
-        client-id: ${{ secrets.AZURE_CLIENT_ID_LIST }}
-        tenant-id: ${{ secrets.AZURE_TENANT_ID }}
-        subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
-    - name: Run all tests
-      run: cargo test only_list
-  tests-get-list:
-    name: Tests with Get and List
-    needs: bicep
-    if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled')
-    runs-on: ubuntu-latest
-    environment: test
-    steps:
-    - uses: actions/checkout@v4
-    - uses: dtolnay/rust-toolchain@stable
-    - uses: azure/login@v1
-      with:
-        client-id: ${{ secrets.AZURE_CLIENT_ID_GET_LIST }}
-        tenant-id: ${{ secrets.AZURE_TENANT_ID }}
-        subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
-    - name: Run all tests
-      run: cargo test get_and_list_access
+    - name: Run ${{ matrix.filter }} tests
+      run: cargo test ${{ matrix.filter }}