Skip to content

ci: per-contract matrix jobs, coverage, and reusable setup action - #47

Open
malaysiaonelove wants to merge 1 commit into
Kqirox:mainfrom
malaysiaonelove:ci/per-contract-jobs-and-coverage
Open

ci: per-contract matrix jobs, coverage, and reusable setup action#47
malaysiaonelove wants to merge 1 commit into
Kqirox:mainfrom
malaysiaonelove:ci/per-contract-jobs-and-coverage

Conversation

@malaysiaonelove

Copy link
Copy Markdown

Summary

Closes #15

Rewrites .github/workflows/ci.yml from a single sequential job into a parallel job graph, and adds a reusable composite action for Stellar + Rust setup.

Job topology

contracts-fmt   ──┐
contracts-clippy──┼──► contracts-test (6-crate matrix) ──► contracts-coverage
                  └──► contracts-build-wasm

Changes

New: .github/actions/setup-stellar/action.yml

Reusable composite action that installs the Rust toolchain (rustfmt + clippy + wasm targets), primes Swatinem/rust-cache, and installs the Stellar CLI. Inputs: rust-toolchain, stellar-cli-version, cache-workspaces.

Rewritten: .github/workflows/ci.yml

Job Description
contracts-fmt cargo fmt --all -- --check across the workspace
contracts-clippy cargo clippy --all-targets --all-features -- -D warnings
contracts-test / <crate> cargo nextest run --package <crate> --features testutils, one runner per crate, fail-fast: false
contracts-build-wasm stellar contract build, uploads *.wasm as a 14-day artifact
contracts-coverage cargo llvm-cov nextest --all, enforces ≥ 80% line coverage, posts sticky PR comment, uploads lcov.info to Codecov

Acceptance criteria

  • CI runtime reduced ≥ 30% — fmt, clippy, 6 test crates, and WASM build all run in parallel after checkout
  • Coverage threshold ≥ 80% enforcedcontracts-coverage fails the build if line coverage drops below COVERAGE_THRESHOLD (default 80)
  • Per-contract test results — matrix job names are test / reward-pool, test / badge-nft, etc., so GitHub clearly surfaces which crate failed
  • Reusable composite action.github/actions/setup-stellar used by all 5 jobs
  • cargo-nextest used for per-test parallelism in test and coverage jobs
  • Swatinem/rust-cache preserved from original workflow

Notes

  • CODECOV_TOKEN must be added to repo secrets if Codecov integration is desired (fail_ci_if_error: false so it won't block CI if absent)
  • Coverage threshold is a single top-level env var (COVERAGE_THRESHOLD: "80") — easy to adjust
  • concurrency: group cancels stale in-flight runs on the same ref

- Split single sequential CI job into 5 parallel jobs:
  contracts-fmt, contracts-clippy, contracts-test (6-crate matrix),
  contracts-build-wasm, contracts-coverage
- Add .github/actions/setup-stellar composite action to deduplicate
  toolchain + cache + Stellar CLI setup across all jobs
- Use cargo-nextest for per-test parallelism in test matrix
- Add cargo-llvm-cov coverage job with 80% line threshold enforcement
- Post sticky coverage summary comment on PRs
- Upload lcov.info to Codecov and WASM artifacts to GitHub Actions
- Add concurrency group to cancel stale in-flight runs

Closes Kqirox#15
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.

[15] Add per-contract CI jobs and a coverage job to detect regressions faster

1 participant