Explorar o código

fix(action): update matrix generation logic for improved accuracy and flexibility

TheWildJames hai 4 meses
pai
achega
90e95ace6e
Modificáronse 2 ficheiros con 27 adicións e 31 borrados
  1. 1 4
      .github/workflows/build.yml
  2. 26 27
      .github/workflows/prepare.yml

+ 1 - 4
.github/workflows/build.yml

@@ -30,10 +30,7 @@ on:
 
 jobs:
   build-gki:
-    name: "${{ inputs.kernel_version }} (${{ matrix.variant }})"
-    strategy:
-      fail-fast: false
-      matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
+    name: "${{ inputs.kernel_version }} (${{ inputs.variant }})"
     runs-on: ubuntu-latest
     timeout-minutes: 60
 

+ 26 - 27
.github/workflows/prepare.yml

@@ -36,44 +36,43 @@ jobs:
   generate-matrix:
     runs-on: ubuntu-latest
     outputs:
-      matrix: ${{ steps.set-matrix.outputs.matrix }}
+      matrix: ${{ steps.final.outputs.matrix }}
     steps:
       - name: Checkout Repository
         uses: actions/checkout@v5
 
-      - name: Read Config and Generate Matrix
-        id: set-matrix
+      - name: Read Config and Build Final Matrix
+        id: final
+        shell: bash
         run: |
-          echo "Reading config from ${{ inputs.config_file }}"
           if [ ! -f "${{ inputs.config_file }}" ]; then
             echo "Error: Config file not found: ${{ inputs.config_file }}"
             exit 1
           fi
-          
-          # Read the file content
-          MATRIX_JSON=$(cat "${{ inputs.config_file }}")
-          
-          # Compact the JSON to a single line to avoid issues
-          # If jq is not available, we might need another way, but ubuntu-latest usually has it.
-          if command -v jq &> /dev/null; then
-            MATRIX_JSON=$(echo "$MATRIX_JSON" | jq -c .)
-          else
-            # Fallback for simple minification if jq missing (unlikely on runner)
-            MATRIX_JSON=$(echo "$MATRIX_JSON" | tr -d '\n' | tr -d ' ')
-          fi
-          
-          echo "Matrix content: $MATRIX_JSON"
-          echo "matrix=$MATRIX_JSON" >> $GITHUB_OUTPUT
-      
-      - name: Build matrix
-        id: matrix
-        run: |
-          if [ "${{ inputs.variant }}" = "All" ]; then
-            echo "matrix={\"variant\":[\"Normal\",\"Bypass\",\"Wild\"]}" >> "$GITHUB_OUTPUT"
+
+          CONFIG_JSON=$(cat "${{ inputs.config_file }}" | jq -c .)
+
+          # Build the variant list as a JSON array
+          if [ "${{ inputs.variant }}" = "All" ] || [ -z "${{ inputs.variant }}" ]; then
+            VARIANTS='["Normal","Bypass","Wild"]'
           else
-            echo "matrix={\"variant\":[\"${{ inputs.variant }}\"]}" >> "$GITHUB_OUTPUT"
+            VARIANTS=$(jq -cn --arg v "${{ inputs.variant }}" '[$v]')
           fi
 
+          # Build { "include": [ {kernel_version:..., variant: ...}, ... ] }
+          FINAL=$(jq -cn \
+            --argjson cfg "$CONFIG_JSON" \
+            --argjson variants "$VARIANTS" '
+            {
+              include: [
+                $cfg.include[] as $item
+                | $variants[] as $variant
+                | $item + {variant: $variant}
+              ]
+            }')
+
+          echo "matrix=$FINAL" >> "$GITHUB_OUTPUT"
+
   build:
     needs: generate-matrix
     strategy:
@@ -88,4 +87,4 @@ jobs:
       patches_commit: ${{ inputs.patches_commit }}
       susfs_commit: ${{ inputs.susfs_commit }}
       feature_set: ${{ inputs.feature_set }}
-    secrets: inherit
+    secrets: inherit