Просмотр исходного кода

Dynamically create family matrix for CI jobs

Maxime JOURDAN - XANTHIO 1 год назад
Родитель
Сommit
eb1e312b34
2 измененных файлов с 35 добавлено и 2 удалено
  1. 5 2
      .github/workflows/cmake.yml
  2. 30 0
      .github/workflows/create-matrix.yml

+ 5 - 2
.github/workflows/cmake.yml

@@ -7,11 +7,14 @@ env:
   BUILD_TYPE: Release
   BUILD_TYPE: Release
 
 
 jobs:
 jobs:
+  RetrieveTargetsMatrix:
+    uses: ./.github/workflows/create-matrix.yml
+
   test-ubuntu:
   test-ubuntu:
     runs-on: ubuntu-20.04
     runs-on: ubuntu-20.04
+    needs: RetrieveTargetsMatrix
     strategy:
     strategy:
-      matrix:
-        family: [C0, F0, F1, F2, F3, F4, F7, G0, G4, H5, H7, L0, L1, L4, L5, U0, U5, WB, WL, MP1]
+      matrix: ${{ fromJSON(needs.RetrieveTargetsMatrix.outputs.matrix) }}
       fail-fast: false
       fail-fast: false
 
 
     steps:
     steps:

+ 30 - 0
.github/workflows/create-matrix.yml

@@ -0,0 +1,30 @@
+name: MatrixCreator
+
+run-name: "Creates supported family matrix for other jobs"
+
+on:
+  workflow_call:
+    outputs:
+      matrix:
+        description: "Supported family for job matrixing"
+        value: ${{ jobs.CreateMatrix.outputs.matrix }}
+
+jobs:
+  CreateMatrix:
+    runs-on: ubuntu-latest
+    outputs:
+      matrix: ${{ steps.create-matrix.outputs.matrix }}
+    steps:
+      - name: Checkout repo
+        id: checkout
+        uses: actions/checkout@v4
+
+      - name: Create matrix
+        id: create-matrix
+        run: |
+          files=$(find cmake/stm32/ -name '*.cmake' -exec sh -c "basename {} | cut -f1 -d '.' | tr '[:lower:]' '[:upper:]'" \;  | sort)
+          deletes="COMMON DEVICES LINKER_LD"
+          for del in $deletes; do
+            files=(${files[@]/$del})
+          done
+          echo "matrix={\"family\":$(jq --compact-output --null-input '$ARGS.positional' --args -- ${files[@]})}" >> $GITHUB_OUTPUT