-
Notifications
You must be signed in to change notification settings - Fork 249
Partitioning docs #4110
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
39
commits into
3548-partition-summary-message
Choose a base branch
from
3548-partitioning-docs
base: 3548-partition-summary-message
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.
+150
−2
Open
Partitioning docs #4110
Changes from 2 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
b5cb4b5
Add docs
franciszekjob 6188f3f
Merge branch '3548-partitioning-logic' of https://github.com/foundry-…
franciszekjob 8f96f8d
Merge branch '3548-partitioning-logic' of https://github.com/foundry-…
franciszekjob bf81040
Merge branch '3548-partition-summary-message' of https://github.com/f…
franciszekjob 80e81db
Merge branch '3548-partitioning-logic' into 3548-partitioning-docs
franciszekjob 45a50c4
Merge branch '3548-partitioning-logic' into 3548-partitioning-docs
franciszekjob 79743c6
Review
franciszekjob 08e58c8
Merge branch '3548-partitioning-docs' of https://github.com/foundry-r…
franciszekjob 9f7f9c3
Merge branch '3548-partition-summary-message' of https://github.com/f…
franciszekjob 57e7198
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob 77e4537
Merge branch '3548-partition-summary-message' of https://github.com/f…
franciszekjob 14f7d12
Fixes
franciszekjob 7e3d873
Merge branch '3548-partitioning-docs' of https://github.com/foundry-r…
franciszekjob 8e0f9ff
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob 99bb692
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob c46a236
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob 8720ca6
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob d56e743
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob 993f497
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob 5736386
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob 3c7e13d
Fix newline
franciszekjob d36bd69
Merge branch '3548-partitioning-docs' of https://github.com/foundry-r…
franciszekjob 48b9ed9
Merge branch '3548-partition-summary-message' of https://github.com/f…
franciszekjob fabc64f
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob 3bf334e
Update docs
franciszekjob 3b5fd8f
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob ed0cad9
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob dcde981
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob d8e9962
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob c2d290e
Merge branch '3548-partition-summary-message' of https://github.com/f…
franciszekjob e12f636
Add missing file
franciszekjob ff815dc
Merge branch '3548-partition-summary-message' of https://github.com/f…
franciszekjob d6bb562
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob f5136dd
Merge branch '3548-partition-summary-message' of https://github.com/f…
franciszekjob 46ebd9c
Merge branch '3548-partition-summary-message' of https://github.com/f…
franciszekjob 1f21296
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob 26bf1c7
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
franciszekjob 461910a
Merge branch '3548-partition-summary-message' of https://github.com/f…
franciszekjob ef99d39
Merge branch '3548-partition-summary-message' into 3548-partitioning-…
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| 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' | ||
franciszekjob marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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
franciszekjob marked this conversation as resolved.
Show resolved
Hide resolved
|
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,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: | ||
franciszekjob marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ```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). | ||
franciszekjob marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.