-
Notifications
You must be signed in to change notification settings - Fork 6
ci: partition heavy EGS test modules for parallel execution #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
570e50e
58a9d54
4053dd0
529b822
495cba0
d609fbc
9c86a4c
b35fecd
e8ed76f
33a266b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| #!/usr/bin/env bash | ||
| # Module catalog for CI test matrix generation. | ||
| # Sourced by both main-ci.yml and pr-ci.yml. | ||
| # | ||
| # All modules run on ubuntu-latest (standard 2-core runners). | ||
| # Partition counts compensate for smaller runners: | ||
| # was 32-core or 8-core → 8 partitions | ||
| # was 4-core → 4 partitions | ||
| # | ||
| # Usage: | ||
| # source .github/workflows/module-catalog.sh | ||
| # INCLUDES="[]" | ||
| # add_all_modules # or add selectively with add_egs, add_metagame, etc. | ||
| # echo "$INCLUDES" | jq . | ||
|
|
||
| add() { | ||
| INCLUDES=$(echo "$INCLUDES" | jq -c \ | ||
| --arg p "$1" --arg m "$2" \ | ||
| --argjson f "$3" --argjson total "$4" \ | ||
| '. + [range($total) | {package:$p, module:$m, runner:"ubuntu-latest", fuzzer_runs:$f, partition:(. + 1), total_partitions:$total}]') | ||
| } | ||
|
|
||
| # Embeddable Game Standard (previously 32-core / 8-core runners → 8 partitions) | ||
| add_egs() { | ||
| add game_components_embeddable_game_standard token 64 8 | ||
| add game_components_embeddable_game_standard minigame 64 8 | ||
| add game_components_embeddable_game_standard metagame 64 8 | ||
| add game_components_embeddable_game_standard registry 64 8 | ||
| } | ||
|
|
||
| # Metagame extensions (previously 4-core runners → 4 partitions) | ||
| add_metagame() { | ||
| add game_components_metagame leaderboard 256 4 | ||
| add game_components_metagame registration 256 4 | ||
| add game_components_metagame entry_requirement 256 4 | ||
| add game_components_metagame entry_fee 256 4 | ||
| add game_components_metagame prize 256 4 | ||
| add game_components_metagame ticket_booth 256 4 | ||
| } | ||
|
|
||
| # Economy (previously 4-core runner → 4 partitions) | ||
| add_economy() { | ||
| add game_components_economy tokenomics 256 4 | ||
| } | ||
|
|
||
| # Utilities (previously 4-core runners → 4 partitions) | ||
| add_utilities() { | ||
| add game_components_utilities math 256 4 | ||
| add game_components_utilities distribution 256 4 | ||
| add game_components_utilities utils 256 4 | ||
| add game_components_utilities renderer 256 4 | ||
| } | ||
|
|
||
| # Presets (previously 4-core runner → 4 partitions) | ||
| add_presets() { | ||
| add game_components_presets presets 256 4 | ||
| } | ||
|
|
||
| # All modules — used by main-ci.yml (always runs everything) | ||
| add_all_modules() { | ||
| add_egs | ||
| add_metagame | ||
| add_economy | ||
| add_utilities | ||
| add_presets | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -237,21 +237,25 @@ jobs: | |
| npx -y "$YAML_CLI" valid < codecov.yml | ||
| fi | ||
|
|
||
| - name: Validate package count matches codecov config | ||
| - name: Validate matrix entry count matches codecov config | ||
| run: | | ||
| matrix_count=$(grep -cE '^\s+module:' .github/workflows/main-ci.yml) | ||
| # Source the module catalog and count generated entries | ||
| source .github/workflows/module-catalog.sh | ||
| INCLUDES="[]" | ||
| add_all_modules | ||
| matrix_count=$(echo "$INCLUDES" | jq 'length') | ||
| codecov_count=$(grep 'after_n_builds:' codecov.yml | grep -oE '[0-9]+') | ||
|
|
||
| echo "Matrix modules: $matrix_count" | ||
| echo "Matrix entries: $matrix_count" | ||
| echo "Codecov after_n_builds: $codecov_count" | ||
|
|
||
| if [ "$matrix_count" != "$codecov_count" ]; then | ||
| echo "::error::Matrix has $matrix_count modules but codecov.yml expects $codecov_count builds" | ||
| echo "::error::Update codecov.yml after_n_builds to match module count" | ||
| echo "::error::Matrix has $matrix_count entries but codecov.yml expects $codecov_count builds" | ||
| echo "::error::Update codecov.yml after_n_builds to match matrix entry count" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Configuration validated: $matrix_count modules" | ||
| echo "Configuration validated: $matrix_count matrix entries" | ||
|
|
||
| lint: | ||
| needs: changes | ||
|
|
@@ -289,42 +293,18 @@ jobs: | |
| NEED_UTILITIES: ${{ needs.changes.outputs.need_utilities }} | ||
| NEED_PRESETS: ${{ needs.changes.outputs.need_presets }} | ||
| run: | | ||
| # Build JSON matrix from per-package boolean flags | ||
| # Module catalog must match main-ci.yml | ||
| source .github/workflows/module-catalog.sh | ||
| INCLUDES="[]" | ||
| add() { INCLUDES=$(echo "$INCLUDES" | jq -c --arg p "$1" --arg m "$2" --arg r "$3" --argjson f "$4" '. + [{package:$p,module:$m,runner:$r,fuzzer_runs:$f}]'); } | ||
|
|
||
| if [ "$NEED_EGS" = "true" ]; then | ||
| add game_components_embeddable_game_standard token ubuntu-latest-32 32 | ||
| add game_components_embeddable_game_standard minigame ubuntu-latest-8 32 | ||
| add game_components_embeddable_game_standard metagame ubuntu-latest-8 32 | ||
| add game_components_embeddable_game_standard registry ubuntu-latest-8 32 | ||
| fi | ||
| if [ "$NEED_METAGAME" = "true" ]; then | ||
| add game_components_metagame leaderboard ubuntu-latest-4 256 | ||
| add game_components_metagame registration ubuntu-latest-4 256 | ||
| add game_components_metagame entry_requirement ubuntu-latest-4 256 | ||
| add game_components_metagame entry_fee ubuntu-latest-4 256 | ||
| add game_components_metagame prize ubuntu-latest-4 256 | ||
| add game_components_metagame ticket_booth ubuntu-latest-4 256 | ||
| fi | ||
| if [ "$NEED_ECONOMY" = "true" ]; then | ||
| add game_components_economy tokenomics ubuntu-latest-4 256 | ||
| fi | ||
| if [ "$NEED_UTILITIES" = "true" ]; then | ||
| add game_components_utilities math ubuntu-latest-4 256 | ||
| add game_components_utilities distribution ubuntu-latest-4 256 | ||
| add game_components_utilities utils ubuntu-latest-4 256 | ||
| add game_components_utilities renderer ubuntu-latest-4 256 | ||
| fi | ||
| if [ "$NEED_PRESETS" = "true" ]; then | ||
| add game_components_presets presets ubuntu-latest-4 256 | ||
| fi | ||
| if [ "$NEED_EGS" = "true" ]; then add_egs; fi | ||
| if [ "$NEED_METAGAME" = "true" ]; then add_metagame; fi | ||
| if [ "$NEED_ECONOMY" = "true" ]; then add_economy; fi | ||
| if [ "$NEED_UTILITIES" = "true" ]; then add_utilities; fi | ||
| if [ "$NEED_PRESETS" = "true" ]; then add_presets; fi | ||
|
|
||
| MATRIX=$(echo "$INCLUDES" | jq -c '{include:.}') | ||
| echo "test_matrix=$MATRIX" >> "$GITHUB_OUTPUT" | ||
| echo "Matrix: $(echo "$INCLUDES" | jq 'length') modules" | ||
| echo "$MATRIX" | jq . | ||
| echo "Matrix: $(echo "$INCLUDES" | jq 'length') entries" | ||
|
|
||
| - name: Extract tool versions | ||
| run: | | ||
|
|
@@ -362,20 +342,11 @@ jobs: | |
| - name: Warm snforge plugin cache | ||
| run: snforge --version | ||
|
|
||
| - name: Verify workspace compiles (no warnings) | ||
| run: | | ||
| scarb build --workspace 2>&1 | tee /tmp/build.log | ||
| if grep -qE '^ --> .*\.cairo:[0-9]+:[0-9]+' /tmp/build.log; then | ||
| echo "::error::Build produced compiler warnings. Fix all warnings before merging." | ||
| grep -B1 -E '^ --> .*\.cairo:[0-9]+:[0-9]+' /tmp/build.log | ||
| exit 1 | ||
| fi | ||
|
|
||
| test: | ||
| name: test (${{ matrix.module }}) | ||
| name: test (${{ matrix.module }}${{ matrix.total_partitions > 1 && format(' {0}/{1}', matrix.partition, matrix.total_partitions) || '' }}) | ||
| needs: [changes, setup] | ||
| if: needs.changes.outputs.has_tests == 'true' | ||
| runs-on: ${{ matrix.runner }} | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
| strategy: | ||
| fail-fast: true | ||
|
|
@@ -439,12 +410,18 @@ jobs: | |
|
|
||
| - name: Run tests with coverage | ||
| run: | | ||
| if [ "${{ matrix.package }}" = "game_components_${{ matrix.module }}" ]; then | ||
| snforge test -p ${{ matrix.package }} --fuzzer-runs ${{ matrix.fuzzer_runs }} --coverage 2>&1 | tee /tmp/test.log | ||
| else | ||
| snforge test -p ${{ matrix.package }} "::${{ matrix.module }}::" --fuzzer-runs ${{ matrix.fuzzer_runs }} --coverage 2>&1 | tee /tmp/test.log | ||
| PARTITION_FLAG="" | ||
| if [ "${{ matrix.total_partitions }}" != "1" ]; then | ||
| PARTITION_FLAG="--partition ${{ matrix.partition }}/${{ matrix.total_partitions }}" | ||
| fi | ||
|
|
||
| TEST_FILTER="" | ||
| if [ "${{ matrix.package }}" != "game_components_${{ matrix.module }}" ]; then | ||
| TEST_FILTER="::${{ matrix.module }}::" | ||
| fi | ||
|
|
||
| snforge test -p ${{ matrix.package }} $TEST_FILTER --fuzzer-runs ${{ matrix.fuzzer_runs }} $PARTITION_FLAG --coverage 2>&1 | tee /tmp/test.log | ||
|
Comment on lines
411
to
+423
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test failures can be hidden by the Line 423 returns 🛠️ Minimal fix - name: Run tests with coverage
run: |
+ set -o pipefail
PARTITION_FLAG=""
if [ "${{ matrix.total_partitions }}" != "1" ]; then
PARTITION_FLAG="--partition ${{ matrix.partition }}/${{ matrix.total_partitions }}"
fi🧰 Tools🪛 actionlint (1.7.11)[error] 412-412: shellcheck reported issue in this script: SC2086:info:11:92: Double quote to prevent globbing and word splitting (shellcheck) 🤖 Prompt for AI Agents |
||
|
|
||
| - name: Check for compiler warnings | ||
| if: always() && steps.cache-tools.outcome != 'failure' | ||
| run: | | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| rust 1.89.0 | ||
| scarb 2.15.1 | ||
| starknet-foundry 0.55.0 | ||
| starknet-foundry 0.57.0 | ||
| voyager 2.2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test step can also pass on failing
snforgeruns.Line 237 pipes the test command into
tee, so withoutset -o pipefailthe workflow reportstee’s exit code instead ofsnforge test’s.🛠️ Minimal fix
- name: Run tests with coverage run: | + set -o pipefail PARTITION_FLAG="" if [ "${{ matrix.total_partitions }}" != "1" ]; then PARTITION_FLAG="--partition ${{ matrix.partition }}/${{ matrix.total_partitions }}" fi🧰 Tools
🪛 actionlint (1.7.11)
[error] 226-226: shellcheck reported issue in this script: SC2086:info:11:92: Double quote to prevent globbing and word splitting
(shellcheck)
🤖 Prompt for AI Agents