Browse Source

Update CI workflow to dynamically set keymaps (#26120)

Joel Challis 4 months ago
parent
commit
933cb8cc35
1 changed files with 14 additions and 5 deletions
  1. 14 5
      .github/workflows/ci_build_major_branch.yml

+ 14 - 5
.github/workflows/ci_build_major_branch.yml

@@ -32,6 +32,7 @@ jobs:
     container: ghcr.io/qmk/qmk_cli
 
     outputs:
+      keymaps: ${{ steps.generate_slice_length.outputs.keymaps }}
       slice_length: ${{ steps.generate_slice_length.outputs.slice_length }}
 
     steps:
@@ -47,12 +48,20 @@ jobs:
 
       - name: Determine concurrency
         id: generate_slice_length
+        shell: 'bash {0}'
         run: |
-          target_count=$( {
-            qmk find -km default 2>/dev/null
-            qmk find -km xap 2>/dev/null
-          } | sort | uniq | wc -l)
+          targets=()
+          target_count=0
+          for target in "default" "xap"; do
+              count=$(qmk find -km $target 2>/dev/null | wc -l)
+              if [ $count -gt 0 ]; then
+                  target_count=$(($target_count + $count))
+                  targets+=($target)
+              fi
+          done
+          keymaps=$(jq -c -n '$ARGS.positional' --args "${targets[@]}")
           slice_length=$((target_count / ($CONCURRENT_JOBS - 1))) # Err on the side of caution
+          echo "keymaps=$keymaps" >> $GITHUB_OUTPUT
           echo "slice_length=$slice_length" >> $GITHUB_OUTPUT
 
   build_targets:
@@ -61,7 +70,7 @@ jobs:
     strategy:
       fail-fast: false
       matrix:
-        keymap: [default, xap]
+        keymap: ${{ fromJson(needs.determine_concurrency.outputs.keymaps) }}
     uses: ./.github/workflows/ci_build_major_branch_keymap.yml
     with:
       branch: ${{ inputs.branch || github.ref_name }}