refactor: parallelise ATS integration tests and shard CI coverage#1308
Open
MiguelLZPF wants to merge 2 commits into
Open
refactor: parallelise ATS integration tests and shard CI coverage#1308MiguelLZPF wants to merge 2 commits into
MiguelLZPF wants to merge 2 commits into
Conversation
b209bfd to
892df51
Compare
a0f2db0 to
2b9b244
Compare
…unit suite The atsRegistry.generated unit suite seeds zero-address orchestrator library placeholders into a shared module singleton to construct facet factories in isolation, but never cleared them. Running the scripts suite on its own then leaked those zeros into later token deployments, linking scheduledTasksOps to address(0) and reverting initializeERC20. Add resetOrchestratorLibraryAddresses() and clear only the seeded state in an after hook. Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
2b9b244 to
295e804
Compare
Shard the mega-asset integration suite for parallel mocha workers (shared suiteDiscovery + atsShardRunner; ats.test.ts delegates, shards/ats.shard.1..8 are the local parallel entries) and split solidity-coverage across a weight-balanced 4-way CI matrix that merges per-shard lcov into a single Codecov upload via an in-repo merger preserving function coverage. Add local parallel coverage via ephemeral git worktrees (test:coverage:parallel) and skip the redundant test-phase recompile under coverage. Guard the split with a disjoint+complete partition assertion plus unit tests, and a CI verify-test-count job that reconciles the sharded test count against a sequential pass so no suite can be silently dropped. Raise the coverage gas limit (gasLimitOverride 30M->100M) and route the orchestrator-library deploys through it so v8.0.0's heavier instrumented deploy fits under solidity-coverage. Cache CI deps and make the workflow contracts-only. Documented in scripts/tools/coverage-shard/README.md. Signed-off-by: Miguel_LZPF <miguel.carpena@io.builders>
bceeab6 to
0c3ff70
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Behaviour-preserving test-infrastructure and CI changes on the ATS contracts. SDK and web are deprecated, so the workflow is contracts-only (PR trigger narrowed to
packages/ats/contracts/**). Rebased ontodevelopv8.0.0; two commits (the test-isolation fix, and the coverage-sharding system).Parallel integration tests. The mega-asset integration suite is sharded across parallel mocha workers via a shared
suiteDiscoverymodule +atsShardRunner:ats.test.tsdelegates to the runner andats.shard.{1..8}.test.tsare the local parallel entries, each deploying the mega-asset once (its own EVM/snapshot per worker — mocha parallelises by file). The customrevertedWithCustomErrorchai-matchers patch re-initialises per worker (mocha--paralleldoes not apply the require-based globalSetup to workers).Sharded CI coverage — balanced, one deploy + one compile per shard. solidity-coverage runs across a 4-way matrix that doubles as the contracts-integration gate.
ats.test.tsreadsATS_MEGA_SHARD_INDEX/TOTAL, so each shard deploys the mega-asset once for its slice. Suites are assigned by greedy longest-processing-time bin-packing keyed on each suite'sit()count (a near-exact proxy for test count), so the per-shard load is balanced instead of the old file-count round-robin (305–708). The redundant test-phase recompile thathardhat coveragewould do is skipped during coverage runs (TASK_TEST→noCompile, gated on solidity-coverage's own__SOLIDITY_COVERAGE_RUNNINGflag), cutting one full ~60s instrumented compile per shard.Single merged coverage report. Shards upload their lcov as artifacts; a
merge-coveragejob combines them into one report uploaded once to Codecov — matching a local single run instead of per-shard pieces. The merge uses a small in-repo lcov merger (mergeLcov.ts): the off-the-shelflcov-result-mergersilently drops function coverage, and the systemlcovCLI needs a flag soup, emits thousands of warnings on solidity-coverage output, and rewrites the file in a newer format with unverified Codecov support — so the in-repo merger is the maintainable, exact choice. It is rewritten for clarity, unit-tested, and documented.Local parallel coverage.
npm run test:coverage:parallelis the local twin of the CI matrix: one ephemeral git worktree per shard (required — a coverage run rewrites generated source in place, so concurrent shards in one checkout would corrupt each other),node_modulessymlinked, merged via the same in-repo merger.Trust guards — proof the split drops no test.
assignBalancedShardsasserts a disjoint + complete partition at runtime (every suite in exactly one shard), backed by unit tests (shardPartition.test.ts, incl. the realplanShardpartition). A CIverify-test-countjob runs the integration suite in one sequential pass and themerge-coveragejob reconciles the sum of the shards' passing counts against that sequential count, failing on mismatch — so a silently dropped or double-run suite turns the build red.v8.0.0 coverage gas fix. After the rebase, the heavier instrumented orchestrator-library deploy (
TokenCoreOpset al.) outgrew the fixedGAS_LIMIT.high(10M) those deploys used under coverage. They now route throughgasLimitOverride, so a coverage run uses a higher limit (30M → 100M, well under the 300M coverageblockGasLimit) while Hedera/hiero-solo stays atGAS_LIMIT.high(10M), under the 15M per-tx cap — the Solo deployment job (real Hedera gas) confirms it.Scripts gate fix + shared install. Fixed a pre-existing test-isolation leak where
atsRegistry.generated.test.tsseeded zero-address orchestrator libraries into a shared module singleton and never cleared them, breaking the scripts suite standalone (resetOrchestratorLibraryAddresses()cleared in anafterhook). CI install is shared via anactions/cacheofnode_moduleskeyed onpackage-lock.json, installing withnpm ci --ignore-scriptson a miss.The whole pipeline is documented in
scripts/tools/coverage-shard/README.md.flowchart TD MA["mega-asset suites<br/>(one shared deploy)"] ST["standalone infra suites"] MA -->|"balanced slice"| S0 & S1 & S2 & S3 ST -->|"balanced (it-count LPT)"| S0 & S1 & S2 & S3 S0["coverage shard 0 → lcov"] --> MG S1["coverage shard 1 → lcov"] --> MG S2["coverage shard 2 → lcov"] --> MG S3["coverage shard 3 → lcov"] --> MG MG["merge-coverage<br/>(in-repo merger, preserves functions)"] --> CV[("Codecov<br/>single report")] VC["verify-test-count<br/>(sequential oracle)"] -.->|"Σ shards == sequential?"| MGType of change
Testing
All green on CI run
28080825464(token-studio-linux-large); the post-fold run re-validates the same tree.CI:
Separately, the Deploy to Hiero Solo Network job (real Hedera gas) passes — confirming the 10M Hedera deploy path is unaffected by the coverage gas bump.
→ For reference, serial CI coverage measured ~14m9s before sharding (via a temporary baseline job, since removed) — sharded ≈ 7m21s wall, ~2× faster.
Local (warm working tree, illustrative — absolute counts shift slightly with v8.0.0 + the added unit tests):
test(serial — all integration + scripts)test:parallel:ats(mega core,--parallel)test:coverage(single run, full)test:coverage:parallel(4 worktrees)test:coverage:shard×4→ Local coverage: serial ~11m vs sharded parallel wall ~5m.
Coverage equality — single run vs the 4-shard merged lcov (what Codecov ingests), re-confirmed on the rebased branch (461 source files):
Lines and functions are identical; branches differ by one (a cross-suite branch only the single shared deploy reaches).
Test Results
All green; merged sharded coverage equals a single run; the
verify-test-countjob confirms the sharded test count equals a sequential pass.Node version:
Checklist