Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 36 additions & 95 deletions .github/workflows/main-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,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
Expand All @@ -101,9 +105,22 @@ jobs:
if: needs.changes.outputs.packages == 'true'
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
test_matrix: ${{ steps.build-matrix.outputs.test_matrix }}
steps:
- uses: actions/checkout@v6

- name: Build test matrix
id: build-matrix
run: |
source .github/workflows/module-catalog.sh
INCLUDES="[]"
add_all_modules

MATRIX=$(echo "$INCLUDES" | jq -c '{include:.}')
echo "test_matrix=$MATRIX" >> "$GITHUB_OUTPUT"
echo "Matrix: $(echo "$INCLUDES" | jq 'length') entries"

- name: Extract tool versions
run: |
echo "SCARB_VERSION=$(grep '^scarb ' .tool-versions | awk '{print $2}')" >> "$GITHUB_ENV"
Expand Down Expand Up @@ -140,96 +157,14 @@ 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: setup
runs-on: ${{ matrix.runner }}
runs-on: ubuntu-latest
timeout-minutes: 10
strategy:
fail-fast: true
matrix:
# NOTE: When adding/removing modules, also update:
# - codecov.yml: after_n_builds must equal module count
# - AGENTS.md: CI Configuration section
include:
# Embeddable Game Standard
- package: game_components_embeddable_game_standard
module: token
runner: ubuntu-latest-32
fuzzer_runs: 32
- package: game_components_embeddable_game_standard
module: minigame
runner: ubuntu-latest-8
fuzzer_runs: 32
- package: game_components_embeddable_game_standard
module: metagame
runner: ubuntu-latest-8
fuzzer_runs: 32
- package: game_components_embeddable_game_standard
module: registry
runner: ubuntu-latest-8
fuzzer_runs: 32
# Metagame
- package: game_components_metagame
module: leaderboard
runner: ubuntu-latest-4
fuzzer_runs: 256
- package: game_components_metagame
module: registration
runner: ubuntu-latest-4
fuzzer_runs: 256
- package: game_components_metagame
module: entry_requirement
runner: ubuntu-latest-4
fuzzer_runs: 256
- package: game_components_metagame
module: entry_fee
runner: ubuntu-latest-4
fuzzer_runs: 256
- package: game_components_metagame
module: prize
runner: ubuntu-latest-4
fuzzer_runs: 256
- package: game_components_metagame
module: ticket_booth
runner: ubuntu-latest-4
fuzzer_runs: 256
# Economy
- package: game_components_economy
module: tokenomics
runner: ubuntu-latest-4
fuzzer_runs: 256
# Utilities
- package: game_components_utilities
module: math
runner: ubuntu-latest-4
fuzzer_runs: 256
- package: game_components_utilities
module: distribution
runner: ubuntu-latest-4
fuzzer_runs: 256
- package: game_components_utilities
module: utils
runner: ubuntu-latest-4
fuzzer_runs: 256
- package: game_components_utilities
module: renderer
runner: ubuntu-latest-4
fuzzer_runs: 256
# Presets (standalone package, no module filter)
- package: game_components_presets
module: presets
runner: ubuntu-latest-4
fuzzer_runs: 256
matrix: ${{ fromJson(needs.setup.outputs.test_matrix) }}
steps:
- uses: actions/checkout@v6

Expand Down Expand Up @@ -289,12 +224,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 225 to +237
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

This test step can also pass on failing snforge runs.

Line 237 pipes the test command into tee, so without set -o pipefail the workflow reports tee’s exit code instead of snforge 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
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/main-ci.yml around lines 225 - 237, The test step
currently pipes "snforge test ... | tee /tmp/test.log" so the workflow can
return tee's exit code; fix this by enabling pipefail before the pipeline (add
"set -o pipefail" or equivalent at the top of the same shell block that runs the
PARTITION_FLAG/TEST_FILTER variable setup and the "snforge test ... | tee
/tmp/test.log" command) so that the step fails when "snforge test" fails.


- name: Check for compiler warnings
if: always() && steps.cache-tools.outcome != 'failure'
run: |
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/module-catalog.sh
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
}
81 changes: 29 additions & 52 deletions .github/workflows/pr-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Test failures can be hidden by the tee pipeline.

Line 423 returns tee’s status unless pipefail is enabled, so a failing snforge test partition can still leave the step green.

🛠️ 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
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/pr-ci.yml around lines 411 - 423, The CI step "Run tests
with coverage" currently pipes the snforge test invocation to tee which masks
the test exit status; enable shell pipefail for that run block so the pipeline
returns snforge's exit code (e.g., add set -o pipefail or set -euo pipefail at
the start of the run script) or alternatively capture the exit of the snforge
test command and explicitly exit with it after tee (use PIPESTATUS[0] to
propagate snforge's exit status) so the step fails when snforge test fails;
apply this change around the snforge test invocation that writes to
/tmp/test.log.


- name: Check for compiler warnings
if: always() && steps.cache-tools.outcome != 'failure'
run: |
Expand Down
2 changes: 1 addition & 1 deletion .tool-versions
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
Loading
Loading