Skip to content

Commit bbf759b

Browse files
committed
ci: use matrix strategy for KWOK tests to parallelize across runners
Single-runner parallelism was slower due to resource contention on 4-vCPU GitHub Actions runners. Fan each recipe to its own runner via matrix strategy for true parallelism (~5x faster wall-clock).
1 parent 8db7e66 commit bbf759b

File tree

4 files changed

+61
-457
lines changed

4 files changed

+61
-457
lines changed

.github/actions/kwok-test/action.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,12 @@
1313
# limitations under the License.
1414

1515
name: 'KWOK Cluster Test'
16-
description: 'Test recipes using KWOK simulated nodes in parallel Kind clusters'
16+
description: 'Test a single recipe using KWOK simulated nodes in a Kind cluster'
1717

1818
inputs:
1919
recipe:
20-
description: 'Recipe name to test (empty = all testable recipes)'
21-
required: false
22-
default: ''
20+
description: 'Recipe name to test'
21+
required: true
2322
go_version:
2423
description: 'Go version to install'
2524
required: true
@@ -156,20 +155,13 @@ runs:
156155
make build
157156
ls -la dist/
158157
159-
- name: Run KWOK recipe tests
158+
- name: Run KWOK recipe test
160159
id: validate
161160
shell: bash
162161
env:
163-
KWOK_CLUSTER_PREFIX: aicr-kwok-test
164162
KIND_NODE_IMAGE: ${{ inputs.kind_node_image }}
165163
run: |
166-
if [[ -n "${{ inputs.recipe }}" ]]; then
167-
# Single recipe: use sequential script with dedicated cluster
168-
KWOK_CLUSTER=aicr-kwok-test bash kwok/scripts/run-all-recipes.sh ${{ inputs.recipe }}
169-
else
170-
# All recipes: use parallel script for faster execution
171-
bash kwok/scripts/run-all-recipes-parallel.sh
172-
fi
164+
KWOK_CLUSTER=aicr-kwok-test bash kwok/scripts/run-all-recipes.sh ${{ inputs.recipe }}
173165
174166
- name: Collect debug artifacts
175167
if: failure()
@@ -198,7 +190,7 @@ runs:
198190
if: failure() && inputs.upload_artifacts == 'true'
199191
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
200192
with:
201-
name: kwok-debug-${{ github.run_id }}
193+
name: kwok-debug-${{ inputs.recipe }}-${{ github.run_id }}
202194
path: |
203195
/tmp/kwok-debug-artifacts/
204196
/tmp/kwok-kind-logs/

.github/workflows/kwok-recipes.yaml

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,59 @@ concurrency:
4646
cancel-in-progress: true
4747

4848
jobs:
49+
discover:
50+
name: Discover Recipes
51+
runs-on: ubuntu-latest
52+
timeout-minutes: 2
53+
outputs:
54+
recipes: ${{ steps.find.outputs.recipes }}
55+
steps:
56+
- name: Checkout overlays
57+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
58+
with:
59+
persist-credentials: false
60+
sparse-checkout: |
61+
recipes/overlays
62+
sparse-checkout-cone-mode: false
63+
64+
- name: Find testable recipes
65+
id: find
66+
shell: bash
67+
run: |
68+
set -euo pipefail
69+
70+
# If a specific recipe was requested via workflow_dispatch, use it
71+
if [[ -n "${{ github.event.inputs.recipe }}" ]]; then
72+
recipes=$(jq -nc '[$recipe]' --arg recipe "${{ github.event.inputs.recipe }}")
73+
echo "recipes=${recipes}" >> "$GITHUB_OUTPUT"
74+
echo "Using specific recipe: ${{ github.event.inputs.recipe }}"
75+
exit 0
76+
fi
77+
78+
# Scan overlays for recipes with a cloud service criteria
79+
recipes="[]"
80+
for overlay in recipes/overlays/*.yaml; do
81+
name=$(basename "$overlay" .yaml)
82+
# yq is pre-installed on ubuntu-latest runners
83+
service=$(yq eval '.spec.criteria.service // ""' "$overlay" 2>/dev/null || true)
84+
if [[ -n "$service" && "$service" != "null" && "$service" != "any" ]]; then
85+
recipes=$(echo "$recipes" | jq -c --arg r "$name" '. + [$r]')
86+
fi
87+
done
88+
89+
echo "recipes=${recipes}" >> "$GITHUB_OUTPUT"
90+
echo "Discovered $(echo "$recipes" | jq 'length') recipe(s): $(echo "$recipes" | jq -c '.')"
91+
4992
test:
50-
name: KWOK Recipe Tests
93+
name: KWOK (${{ matrix.recipe }})
94+
needs: discover
95+
if: ${{ needs.discover.outputs.recipes != '[]' && needs.discover.outputs.recipes != '' }}
5196
runs-on: ubuntu-latest
52-
timeout-minutes: 45
97+
timeout-minutes: 15
98+
strategy:
99+
fail-fast: false
100+
matrix:
101+
recipe: ${{ fromJSON(needs.discover.outputs.recipes) }}
53102
steps:
54103
- name: Checkout Code
55104
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -60,10 +109,10 @@ jobs:
60109
id: versions
61110
uses: ./.github/actions/load-versions
62111

63-
- name: Run KWOK tests
112+
- name: Run KWOK test
64113
uses: ./.github/actions/kwok-test
65114
with:
66-
recipe: ${{ github.event.inputs.recipe }}
115+
recipe: ${{ matrix.recipe }}
67116
go_version: ${{ steps.versions.outputs.go }}
68117
kind_version: ${{ steps.versions.outputs.kind }}
69118
helm_version: ${{ steps.versions.outputs.helm }}
@@ -85,6 +134,8 @@ jobs:
85134
86135
if [[ "${{ needs.test.result }}" == "success" ]]; then
87136
echo "All recipe validations passed" >> $GITHUB_STEP_SUMMARY
137+
elif [[ "${{ needs.test.result }}" == "skipped" ]]; then
138+
echo "No recipes to test" >> $GITHUB_STEP_SUMMARY
88139
elif [[ "${{ needs.test.result }}" == "cancelled" ]]; then
89140
echo "Recipe validations were cancelled" >> $GITHUB_STEP_SUMMARY
90141
exit 1

Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,6 @@ endif
479479
kwok-test-all: build ## Run all KWOK recipe tests in a shared cluster
480480
@bash kwok/scripts/run-all-recipes.sh
481481

482-
.PHONY: kwok-test-all-parallel
483-
kwok-test-all-parallel: build ## Run all KWOK recipe tests in parallel across multiple clusters
484-
@bash kwok/scripts/run-all-recipes-parallel.sh
485-
486482
# =============================================================================
487483
# Combined Development Targets
488484
# =============================================================================
@@ -547,7 +543,6 @@ help-full: ## Displays commands grouped by category
547543
@echo " make kwok-status Show KWOK cluster and node status"
548544
@echo " make kwok-e2e Full KWOK workflow (RECIPE=<name>)"
549545
@echo " make kwok-test-all Run all recipes in shared cluster"
550-
@echo " make kwok-test-all-parallel Run all recipes in parallel clusters (faster)"
551546
@echo ""
552547
@echo "\033[1m=== Code Maintenance ===\033[0m"
553548
@echo " make tidy Format code and update dependencies"

0 commit comments

Comments
 (0)