-
Notifications
You must be signed in to change notification settings - Fork 240
Partitioning docs #3855
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
Open
franciszekjob
wants to merge
13
commits into
3548-3-partition-functionality
Choose a base branch
from
3548-4-docs
base: 3548-3-partition-functionality
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Partitioning docs #3855
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
24b5cd6
Add docs
franciszekjob c1185c7
Merge branch '3548-3-partition-functionality' of https://github.com/f…
franciszekjob 8bf0be5
Merge branch '3548-3-partition-functionality' into 3548-4-docs
franciszekjob aeff73b
Merge branch '3548-3-partition-functionality' of https://github.com/f…
franciszekjob 044cc0a
Merge branch '3548-4-docs' of https://github.com/foundry-rs/starknet-…
franciszekjob fea4294
Merge branch '3548-3-partition-functionality' of https://github.com/f…
franciszekjob 22181b3
Updaye help message
franciszekjob c76d855
Merge branch '3548-3-partition-functionality' of https://github.com/f…
franciszekjob dcfbdd3
Update changelog
franciszekjob e3fb1b3
Merge branch '3548-3-partition-functionality' into 3548-4-docs
franciszekjob 161229d
Fix tests
franciszekjob 846371b
Merge branch '3548-4-docs' of https://github.com/foundry-rs/starknet-…
franciszekjob 7d81ef4
Fix package name
franciszekjob File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| name: My workflow | ||
| on: | ||
| push: | ||
| pull_request: | ||
| jobs: | ||
| check: | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| partition: [ 1, 2, 3, 4 ] | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Starknet Foundry | ||
| uses: foundry-rs/setup-snfoundry@v3 | ||
|
|
||
| - name: Setup Scarb | ||
| uses: software-mansion/setup-scarb@v1 | ||
| with: | ||
| scarb-lock: ./hello_starknet/Scarb.lock | ||
|
|
||
| - name: Run tests | ||
| run: | | ||
| cd hello_starknet | ||
| snforge test --partition '${{ matrix.partition }}/4' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [package] | ||
| name = "tests_partitioning" | ||
| version = "0.1.0" | ||
| edition = "2024_07" | ||
|
|
||
| [dependencies] | ||
| starknet = "2.12.0" | ||
| assert_macros = "2.12.0" | ||
|
|
||
| [dev-dependencies] | ||
| snforge_std = { path = "../../../snforge_std" } | ||
|
|
||
| [scripts] | ||
| test = "snforge test" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| #[starknet::contract] | ||
| pub mod HelloStarknet { | ||
| #[storage] | ||
| struct Storage {} | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #[test] | ||
| fn test_a() { | ||
| assert_eq!(1 + 1, 2); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_b() { | ||
| assert_eq!(1 + 1, 2); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_c() { | ||
| assert_eq!(1 + 1, 2); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_d() { | ||
| assert_eq!(1 + 1, 2); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_e() { | ||
| assert_eq!(1 + 1, 2); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_f() { | ||
| assert_eq!(1 + 1, 2); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_g() { | ||
| assert_eq!(1 + 1, 2); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
Contributor
Author
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. note: Potentially we can explain more details about partitioning model, that currently only execution is optimized. Lmk what you think. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| # Tests Partitioning | ||
|
|
||
| When your test suite contains a large number of tests (especially fuzz tests), it can be helpful to split them into partitions and run each partition separately, for example in parallel CI jobs. | ||
|
|
||
|
|
||
| `snforge` supports this via the `--partition <INDEX/TOTAL>` flag. | ||
|
|
||
| When this flag is provided, `snforge` will divide all collected tests into `TOTAL` partitions and run only the partition with the given `INDEX` (1-based). | ||
|
|
||
| ## Example | ||
|
|
||
| Let's consider package with the following 7 tests: | ||
|
|
||
| ```rust | ||
| {{#include ../../listings/tests_partitioning/tests/example.cairo}} | ||
| ``` | ||
|
|
||
| Running `snforge test --partition 1/2` will run tests `test_a`, `test_c`, `test_e`, `test_g` (4 tests), while running `snforge test --partition 2/2` will run tests `test_b`, `test_d`, `test_f` (3 tests). | ||
|
|
||
| <!-- { "package_name": "tests_partitioning" } --> | ||
| ```shell | ||
| $ snforge test --partition 1/2 | ||
| ``` | ||
|
|
||
| <details> | ||
| <summary>Output:</summary> | ||
|
|
||
| ```shell | ||
| Collected 4 test(s) from tests_partitioning package | ||
| Running 4 test(s) from tests/ | ||
| [PASS] tests_partitioning_integrationtest::example::test_a ([..]) | ||
| [PASS] tests_partitioning_integrationtest::example::test_e ([..]) | ||
| [PASS] tests_partitioning_integrationtest::example::test_c ([..]) | ||
| [PASS] tests_partitioning_integrationtest::example::test_g ([..]) | ||
| Running 0 test(s) from src/ | ||
| Tests: 4 passed, 0 failed, 0 ignored, 0 filtered out | ||
|
|
||
| Finished partition run: 1/2 | ||
| ``` | ||
|
|
||
| </details> | ||
|
|
||
|
|
||
| See example Github Actions workflow demonstrating partitioned test execution [here](../appendix/starknet-foundry-github-action.html#workflow-with-partitioned-tests). |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
note: mdbook recognizes variables inside
{{ variable }}, so having{{ matrix.partition }}in example yml workflow will produce en empty string there. Adding this variable is a hacky workaround for it 😅 .