@@ -120,26 +120,37 @@ jobs:
120120 - name : Run tests
121121 run : make test
122122
123- # Build guest programs in parallel using matrix
124- build -guest :
123+ # Generate guest program list dynamically
124+ generate -guest-matrix :
125125 runs-on : ubuntu-latest
126126 # Run on main branches, release branches, or when explicitly requested
127127 if : |
128128 github.ref == 'refs/heads/master' ||
129129 startsWith(github.ref, 'refs/heads/release/') ||
130130 startsWith(github.ref, 'refs/tags/v') ||
131131 contains(github.event.pull_request.labels.*.name, 'full-build')
132+ outputs :
133+ guest-matrix : ${{ steps.generate-matrix.outputs.guest-matrix }}
134+ steps :
135+ - uses : actions/checkout@v4
136+ with :
137+ submodules : recursive
138+
139+ - name : Generate guest matrix
140+ id : generate-matrix
141+ run : |
142+ # Extract package names from Cargo.toml files
143+ guests=$(find guest-examples -name "Cargo.toml" -not -path "guest-examples/Cargo.toml" | xargs -I{} sh -c 'grep "^name" "{}" | cut -d"=" -f2 | tr -d " \""' | jq -R -s -c 'split("\n")[:-1]')
144+ echo "guest-matrix=$guests" >> $GITHUB_OUTPUT
145+ echo "Found guest programs: $guests"
146+
147+ # Build guest programs in parallel using dynamic matrix
148+ build-guest :
149+ runs-on : ubuntu-latest
150+ needs : generate-guest-matrix
132151 strategy :
133152 matrix :
134- guest : [
135- sum-balance,
136- sum-balance-hand-written,
137- sum-balance-percent,
138- swap-info,
139- total-supply,
140- total-supply-hand-written,
141- transparent-call-hand-written
142- ]
153+ guest : ${{ fromJson(needs.generate-guest-matrix.outputs.guest-matrix) }}
143154 steps :
144155 - uses : actions/checkout@v4
145156 with :
@@ -153,7 +164,7 @@ jobs:
153164 - uses : Swatinem/rust-cache@v2
154165 with :
155166 cache-bin : " false"
156- prefix-key : " guest- ${{ matrix.guest }}"
167+ prefix-key : " ${{ matrix.guest }}"
157168
158169 - name : Install polkatool and pvq-program-metadata-gen
159170 run : |
@@ -177,7 +188,7 @@ jobs:
177188 # Collect all guest artifacts (optional - for when you need all guests together)
178189 collect-guests :
179190 runs-on : ubuntu-latest
180- needs : build-guest
191+ needs : [generate-guest-matrix, build-guest]
181192 if : github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'full-build')
182193 steps :
183194 - name : Download all guest artifacts
0 commit comments