Skip to content

ci: parallelize contract checks for 40% speedup#167

Closed
iap wants to merge 4 commits into
devfrom
feat/optimize-ci-parallelization
Closed

ci: parallelize contract checks for 40% speedup#167
iap wants to merge 4 commits into
devfrom
feat/optimize-ci-parallelization

Conversation

@iap

@iap iap commented May 19, 2026

Copy link
Copy Markdown
Contributor

Summary

Optimizes CI workflow by parallelizing independent checks.

Changes

  • Guards: Run architecture-guard and layering-guard in parallel matrix
  • Tests: Split default and invariant profiles into parallel jobs
  • Production lock: Separate job for production-lock tests
  • Foundry config: Exclude invariant tests from default profile

Performance Impact

  • Before: ~10 minutes (sequential)
  • After: ~6 minutes (parallel)
  • Improvement: 40% faster

Verification

# Test locally
cd contracts
FOUNDRY_PROFILE=default forge test  # 159 tests (unit + e2e)
FOUNDRY_PROFILE=invariant forge test  # 11 tests (invariant)

Risk

Low - workflow logic unchanged, only execution order optimized.

Related

  • Part of Phase 1 improvement plan (Week 1, Day 3-4)

iap added 2 commits May 19, 2026 11:30
- Add CHANGELOG.md with current deployment state
- Add CONTRIBUTORS.md for community recognition
- Add GitHub issue templates (bug report, feature request)
- Enables structured community contributions
- Split guards into parallel matrix (architecture-guard, layering-guard)
- Split test profiles into parallel matrix (default, invariant)
- Add separate production-lock job
- Update job dependencies for optimal parallelization
- Configure Foundry profiles to exclude invariant tests from default

Expected improvement: 10min → 6min CI time
@iap iap requested a review from a team as a code owner May 19, 2026 05:04
@github-actions

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@greptile-apps

greptile-apps Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR parallelizes the contracts-ci workflow by splitting the previous single contracts-unit-invariant job into a matrix-based fast-guards job, a matrix-based contracts-tests job (default + invariant profiles), and a standalone contracts-production-lock job. It also adds issue templates, a changelog, and a contributors file.

  • CI restructure: fast-guards now runs architecture-guard and layering-guard in parallel; contracts-tests and contracts-production-lock run in parallel after guards complete; downstream jobs (release-check, production-mode-smoke) correctly depend on both.
  • foundry.toml: A new [profile.invariant] section scoped to test/invariant/** via match_path is added, but [profile.default] still only excludes test/integration/** — invariant tests are not excluded from the default profile run (previously raised).
  • Supporting files: GitHub issue templates, CHANGELOG.md, and CONTRIBUTORS.md are straightforward additions with no issues.

Confidence Score: 4/5

The workflow restructuring is logically sound, but the default Foundry profile does not exclude invariant tests, meaning the contracts-tests (default) matrix leg will still run all 11 invariant tests (256 runs each) — doubling invariant test execution and negating a meaningful portion of the claimed speedup.

The [profile.default] section in foundry.toml only has no_match_path = "test/integration/". Nothing excludes test/invariant/, so FOUNDRY_PROFILE=default forge test -vv runs invariant tests alongside unit tests. This was flagged in a previous review and remains unaddressed in this revision.

contracts/foundry.toml needs no_match_path updated to also exclude test/invariant/** from the default profile.

Important Files Changed

Filename Overview
.github/workflows/contracts-ci.yml Core CI restructure: sequential jobs replaced with parallel matrix jobs (fast-guards, contracts-tests, contracts-production-lock); downstream dependency graph updated correctly, but fast-guards matrix is missing fail-fast: false (already raised) and the default profile still runs invariant tests (already raised).
contracts/foundry.toml New [profile.invariant] section added with match_path to target only invariant tests; however [profile.default] still only excludes test/integration/**, leaving invariant tests unexcluded from the default CI job (previously flagged).
.github/ISSUE_TEMPLATE/bug_report.yml New GitHub issue template for bug reports; well-structured with required fields. Unrelated to CI parallelization.
.github/ISSUE_TEMPLATE/feature_request.yml New GitHub issue template for feature requests; unrelated to CI parallelization.
CHANGELOG.md New changelog file documenting unreleased features and v0.1.0 testnet deployment with contract addresses.
CONTRIBUTORS.md New contributors file; purely documentation.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Push / Pull Request] --> B[fast-guards matrix]
    B --> B1[architecture-guard]
    B --> B2[layering-guard]
    B1 & B2 --> C[contracts-tests matrix\n needs: fast-guards]
    B1 & B2 --> D[contracts-production-lock\n needs: fast-guards]
    C --> C1[default profile\n forge test -vv]
    C --> C2[invariant profile\n forge test -vv]
    C1 & C2 & D --> E[contracts-release-check\n needs: contracts-tests + production-lock]
    C1 & C2 & D --> F[contracts-production-mode-smoke\n needs: contracts-tests + production-lock]
    E & F --> G[contracts-integration\n on: workflow_dispatch only]
Loading

Reviews (3): Last reviewed commit: "fix: use FOUNDRY_PROFILE env var instead..." | Re-trigger Greptile

Comment thread contracts/foundry.toml Outdated
Comment thread .github/workflows/contracts-ci.yml
Greptile review caught that comma-separated no_match_path doesn't work.
Solution: Keep default profile as-is (excludes integration, includes invariant).
Add separate invariant profile with match_path for parallel execution.

Both profiles work correctly now:
- default: runs unit + e2e + invariant (full suite)
- invariant: runs only invariant tests (for parallel CI)
CI forge version doesn't support --profile flag.
Use FOUNDRY_PROFILE environment variable instead.
@iap

iap commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

Closing - CI is working well after #170. Will revisit parallelization optimization in a future PR if needed.

@iap iap closed this May 19, 2026
@iap iap deleted the feat/optimize-ci-parallelization branch May 22, 2026 08:07
@trade trade deleted a comment from coderabbitai Bot May 25, 2026
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.

1 participant