瀏覽代碼

Merge pull request #342 from xanthio/maintenance/dynamic-matrixing

Dynamic family matrix for CI jobs
Hish15 1 年之前
父節點
當前提交
d8f9e07c9f
共有 2 個文件被更改,包括 36 次插入3 次删除
  1. 6 3
      .github/workflows/cmake.yml
  2. 30 0
      .github/workflows/create-matrix.yml

+ 6 - 3
.github/workflows/cmake.yml

@@ -7,15 +7,18 @@ env:
   BUILD_TYPE: Release
 
 jobs:
+  RetrieveTargetsMatrix:
+    uses: ./.github/workflows/create-matrix.yml
+
   test-ubuntu:
     runs-on: ubuntu-20.04
+    needs: RetrieveTargetsMatrix
     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
 
     steps:
-    - uses: actions/checkout@v2
+    - uses: actions/checkout@v4
       
     - name: Install ARM toolchain
       run: sudo apt-get install gcc-arm-none-eabi binutils-arm-none-eabi 

+ 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