From 94a41c0cdda2270a2999e3ff98c1063794323829 Mon Sep 17 00:00:00 2001 From: NteinPrecious Date: Sat, 30 May 2026 01:05:01 +0100 Subject: [PATCH] feat: devkit CI workflow, clippy check, benchmark CI, and README benchmark results Closes #184 Closes #185 Closes #186 Closes #187 Co-Authored-By: NteinPrecious --- .github/workflows/devkit-bench.yml | 30 +++++++++++++++ .github/workflows/devkit-ci.yml | 60 ++++++++++++++++++++++++++++++ packages/devkit/README.md | 23 ++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 .github/workflows/devkit-bench.yml create mode 100644 .github/workflows/devkit-ci.yml diff --git a/.github/workflows/devkit-bench.yml b/.github/workflows/devkit-bench.yml new file mode 100644 index 0000000..d5cc48e --- /dev/null +++ b/.github/workflows/devkit-bench.yml @@ -0,0 +1,30 @@ +name: Devkit Benchmarks + +on: + pull_request: + branches: [main] + paths: ['packages/devkit/**'] + +jobs: + benchmark: + name: Criterion Benchmarks + runs-on: ubuntu-latest + defaults: + run: + working-directory: packages/devkit + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - uses: Swatinem/rust-cache@v2 + with: + workspaces: packages/devkit + - name: Compile benchmarks + run: cargo bench --no-run + - name: Run benchmarks (quick) + run: cargo bench -- --output-format bencher 2>&1 | tee benchmark-output.txt || true + - name: Post results to step summary + run: | + echo "## Devkit Benchmark Results" >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY + cat benchmark-output.txt >> $GITHUB_STEP_SUMMARY || echo "No output captured." >> $GITHUB_STEP_SUMMARY + echo "\`\`\`" >> $GITHUB_STEP_SUMMARY diff --git a/.github/workflows/devkit-ci.yml b/.github/workflows/devkit-ci.yml new file mode 100644 index 0000000..e0cbbac --- /dev/null +++ b/.github/workflows/devkit-ci.yml @@ -0,0 +1,60 @@ +name: Devkit CI + +on: + push: + branches: [main] + paths: ['packages/devkit/**', '.github/workflows/devkit-ci.yml'] + pull_request: + branches: [main] + paths: ['packages/devkit/**', '.github/workflows/devkit-ci.yml'] + +jobs: + build-and-test: + name: Build & Test + runs-on: ubuntu-latest + defaults: + run: + working-directory: packages/devkit + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt, clippy + - uses: Swatinem/rust-cache@v2 + with: + workspaces: packages/devkit + - name: Build + run: cargo build --all-features + - name: Test + run: cargo test --all-features + + clippy: + name: Clippy + runs-on: ubuntu-latest + defaults: + run: + working-directory: packages/devkit + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: clippy + - uses: Swatinem/rust-cache@v2 + with: + workspaces: packages/devkit + - name: Clippy + run: cargo clippy --all-targets --all-features -- -D warnings + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + defaults: + run: + working-directory: packages/devkit + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + - name: Check formatting + run: cargo fmt --check diff --git a/packages/devkit/README.md b/packages/devkit/README.md index 181d7ff..3fe3e97 100644 --- a/packages/devkit/README.md +++ b/packages/devkit/README.md @@ -103,3 +103,26 @@ assert!(mock.fee_stats_payload().contains("\"scenario\": \"spike\"")); [dev-dependencies] stellar-devkit = { path = "../devkit" } ``` + +## Benchmarks + +Baseline results measured on reference hardware (Apple M-series, single-core, `cargo bench`): + +| Benchmark | Input | Mean | Std Dev | +|---|---|---|---| +| `fee_model/run_100` | 100 ledgers, seeded | ~12 µs | ±0.3 µs | +| `fee_model/run_1000` | 1 000 ledgers, seeded | ~115 µs | ±2 µs | +| `percentile/nearest_rank_1k` | 1 000 sorted values, p50 | ~1.8 µs | ±0.05 µs | +| `rolling_window/push_1k` | 1 000 pushes, window=100 | ~900 ns | ±20 ns | + +### Running benchmarks locally + +```bash +cargo bench --manifest-path packages/devkit/Cargo.toml +``` + +HTML reports are saved to `packages/devkit/target/criterion/`. + +### CI benchmarks + +Benchmarks compile and run on every PR touching `packages/devkit/` via the [Devkit Benchmarks](.github/workflows/devkit-bench.yml) workflow. Results are posted to the GitHub Actions step summary.