[PATCH 12/14] ci: build: dynamically generate build matrix

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We have some manual chunking of defconfigs, which makes it more
difficult to see on a glance which defconfig failed.

Let's add a job that generates a JSON of all available defconfigs
for the selected architectures and use that as build matrix for the
build job.

This gives us higher parallelism at the cost of more IO in the form
of container pulls and repository (--depth=1) fetches.

All in all, it seems to save 5 minutes execution time on average, so
let's make use of it.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 .github/workflows/build-defconfigs.yml | 30 +++++++++++++++-----------
 scripts/list-defconfigs.sh             | 15 +++++++++++++
 2 files changed, 32 insertions(+), 13 deletions(-)
 create mode 100755 scripts/list-defconfigs.sh

diff --git a/.github/workflows/build-defconfigs.yml b/.github/workflows/build-defconfigs.yml
index c5c294300e03..ff9264721d87 100644
--- a/.github/workflows/build-defconfigs.yml
+++ b/.github/workflows/build-defconfigs.yml
@@ -2,8 +2,23 @@ name: build images
 
 on: [push, pull_request]
 
+env:
+  ARCH: arm mips powerpc riscv sandbox x86
+
 jobs:
+  defconfigs:
+    runs-on: ubuntu-latest
+    outputs:
+      matrix: ${{ steps.set-matrix.outputs.matrix }}
+    steps:
+      - name: Checkout code
+        uses: actions/checkout@v3
+
+      - name: Collect defconfigs
+        id: set-matrix
+        run: echo "matrix=$(scripts/list-defconfigs.sh $ARCH)" >> $GITHUB_OUTPUT
   build:
+    needs: defconfigs
     runs-on: ubuntu-latest
     container:
       image: ghcr.io/barebox/barebox/barebox-ci:latest
@@ -12,18 +27,7 @@ jobs:
 
     strategy:
       fail-fast: false
-      matrix:
-        arch: [mips, powerpc, riscv, sandbox, x86 ]
-        regex: ["*"]
-        include:
-          - arch: arm
-            regex: "[a-b]*"
-          - arch: arm
-            regex: "[c-m]*"
-          - arch: arm
-            regex: "[n-q]*"
-          - arch: arm
-            regex: "[r-z]*"
+      matrix: ${{ fromJSON(needs.defconfigs.outputs.matrix) }}
 
     steps:
     - name: Checkout code
@@ -36,4 +40,4 @@ jobs:
         ./test/generate-dummy-fw.sh
 
         ./MAKEALL -O build-${{matrix.arch}} -k test/kconfig/disable_size_check.kconf \
-                -k test/kconfig/disable_target_tools.kconf -e '${{matrix.regex}}'
+                -k test/kconfig/disable_target_tools.kconf '${{matrix.config}}'
diff --git a/scripts/list-defconfigs.sh b/scripts/list-defconfigs.sh
new file mode 100755
index 000000000000..eeae9fbfdc30
--- /dev/null
+++ b/scripts/list-defconfigs.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Output json formatted defconfig list for Github Action consumption
+
+ARCH=${@:-*}
+
+cd arch
+
+archs=$(for arch in $ARCH; do
+	ls -1 $arch/configs | xargs -i printf '{ "arch": "%s", "config": "%s" }\n' \
+		"$arch" "{}" | paste -sd ',' -
+done | paste -sd ',' -)
+
+echo '{ "include" : '" [ $archs ] }"
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux