Skip to content
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

shard unit tests in CI for faster CI runs #5572

Merged
merged 3 commits into from
Oct 23, 2024
Merged

Conversation

mat-if
Copy link
Contributor

@mat-if mat-if commented Oct 22, 2024

Summary

Shards the main test suite across 3 shards, and slow tests across 2 shards, resulting in a CI runtime reduction from around 15 minutes to around 6.5-7 minutes: https://github.com/iron-fish/ironfish/actions/runs/11486776859

Testing Plan

Re-ran CI workflow multiple times across 2 branches

Documentation

Does this change require any updates to the Iron Fish Docs (ex. the RPC API
Reference
)? If yes, link a
related documentation pull request for the website.

[ ] Yes

Breaking Change

Is this a breaking change? If yes, add notes below on why this is breaking and label it with breaking-change-rpc or breaking-change-sdk.

[ ] Yes

@mat-if mat-if force-pushed the mat/shard-ci-tests branch 2 times, most recently from 8d00928 to 89fe063 Compare October 22, 2024 22:02
@mat-if mat-if force-pushed the mat/shard-ci-tests branch from 89fe063 to 64fa8cb Compare October 23, 2024 19:25
@mat-if mat-if changed the title split main unit tests across 2 processes to increase ci speed shard unit tests in CI for faster CI runs Oct 23, 2024
@mat-if mat-if marked this pull request as ready for review October 23, 2024 21:00
@mat-if mat-if requested a review from a team as a code owner October 23, 2024 21:00
@@ -63,7 +66,7 @@ jobs:
run: yarn --non-interactive --frozen-lockfile

- name: Run tests
run: yarn test:coverage --maxWorkers=2 --workerIdleMemoryLimit=2000MB
run: yarn test:coverage --maxWorkers=2 --workerIdleMemoryLimit=2000MB --shard=${{ matrix.shard }}/${{ strategy.job-total }}
Copy link
Contributor

Choose a reason for hiding this comment

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

LGTM, but it's not clear to me where strategy.job-total comes from, or how it is configured

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#strategy-context

This has some documentation about the strategy context. It's not ideal, because if we for some reason add another matrix, for example for NodeJS versions, we will need to come up with a different solution here. At that point, we may have to build a custom script to manage it because it's not clear to me that github actions has a way to get the length of a specific matrix array or anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, came up with a slightly less brittle solution - defining the matrix jobs as '1/3', '2/3', '3/3', etc. It doesn't feel great but it's less likely to randomly blow up in the future.

the strategy.job_total figure can easily change, which would cause pretty big
problems with our tests. if we manually define the entire shard piece instead
of trying to calculate it, this makes the job more robust to future changes.
@mat-if mat-if merged commit e43cb00 into staging Oct 23, 2024
12 checks passed
@mat-if mat-if deleted the mat/shard-ci-tests branch October 23, 2024 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants