From b662cc73fb5eb18967e5dd40e38982e00e4604df Mon Sep 17 00:00:00 2001 From: s3rj1k Date: Sat, 12 Oct 2024 19:02:23 +0200 Subject: [PATCH] [GHA] Use autogenerated matrix for grouping unit-tests. --- .github/workflows/ci.yml | 33 ++++++++++++++++++++++----------- .github/workflows/unit-test.yml | 2 +- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d16f1a987a..51586fabfe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,20 +10,31 @@ on: - synchronize jobs: - unit-tests_1: - name: "unit-tests (group 1)" - uses: ./.github/workflows/unit-test.yml - with: - total-groups: 2 - current-group: 1 - secrets: inherit + unit-tests-pre-config: + runs-on: ubuntu-latest + env: + TOTAL_GROUPS: 2 + outputs: + matrix: ${{ steps.set-matrix.outputs.matrix }} + steps: + - id: set-matrix + shell: bash + run: | + MATRIX=$(jq -c -n --argjson groups "${{ env.TOTAL_GROUPS }}" \ + '{ + include: [range(1; $groups + 1) | {group: ., total: $groups}] + }') + echo "matrix=$MATRIX" | tee -a $GITHUB_OUTPUT - unit-tests_2: - name: "unit-tests (group 2)" + unit-tests: + needs: unit-tests-pre-config + strategy: + matrix: ${{ fromJson(needs.unit-tests-pre-config.outputs.matrix) }} + name: "unit-tests (group ${{ matrix.group }})" uses: ./.github/workflows/unit-test.yml with: - total-groups: 2 - current-group: 2 + total-groups: ${{ matrix.total }} + current-group: ${{ matrix.group }} secrets: inherit scan-build: diff --git a/.github/workflows/unit-test.yml b/.github/workflows/unit-test.yml index 8ff0d832a7..5db97620a4 100644 --- a/.github/workflows/unit-test.yml +++ b/.github/workflows/unit-test.yml @@ -13,7 +13,7 @@ on: type: number jobs: - unit-tests: + unit-test: runs-on: ubuntu-latest container: image: signalwire/freeswitch-public-base:bookworm