diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index d8a0f70..2127010 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -56,17 +56,17 @@ Closes # ## Commands Run - + ``` -cargo fmt --check -cargo clippy --tests -- -D warnings -cargo test --workspace +make verify ``` -- [ ] `cargo fmt --check` — passed -- [ ] `cargo clippy --tests -- -D warnings` — passed -- [ ] `cargo test --workspace` — passed +- [ ] `make verify` — passed +- [ ] (or individually) `cargo fmt --check` — passed +- [ ] (or individually) `cargo clippy --tests -- -D warnings` — passed +- [ ] (or individually) `cargo test --workspace` — passed --- diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 91f3650..9f45a73 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -63,7 +63,7 @@ Run all local verification checks in one command: make verify ``` -This runs formatting checks, the full workspace test suite, and builds the optimized contract WASM. Run this command before opening a pull request. +This runs formatting checks, Clippy linting (with warnings denied), the full workspace test suite, and builds the optimized contract WASM. Run this command before opening a pull request. The README documents the same entry point under [Local verification](README.md#local-verification). Alternatively, run checks individually: @@ -73,6 +73,12 @@ Check formatting: cargo fmt --check ``` +Lint with Clippy (same flags as the PR template): + +```bash +cargo clippy --tests -- -D warnings +``` + Run the full workspace test suite: ```bash @@ -99,7 +105,7 @@ Every pull request must fill in the **[PR template](.github/PULL_REQUEST_TEMPLAT - **Contract functions changed** — a table listing every function added, modified, or removed (write "none" for documentation-only PRs). - **Tests added or updated** — names and file paths of new or changed tests, with checkboxes confirming happy-path, failure, and boundary coverage. - **Security considerations** — a plain-language description of security impact plus the per-section security checklist for any PR that touches contract logic (see `docs/security-checklist.md`). -- **Commands run** — confirmation that `cargo fmt --check`, `cargo clippy --tests -- -D warnings`, and `cargo test --workspace` all pass locally. +- **Commands run** — confirmation that `make verify` passes (format, Clippy, workspace tests, and release WASM build), or equivalently that `cargo fmt --check`, `cargo clippy --tests -- -D warnings`, and `cargo test --workspace` all pass locally. - **CI status** — all CI checks green before requesting review. Additional guidance: diff --git a/Makefile b/Makefile index a867eae..fef14d0 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,10 @@ build-release: wasm-size: sh scripts/report-wasm-size.sh "$(WASM_PATH)" -verify: ## Run all local verification checks (format, test, build) +# Single local gate aligned with PR / CI expectations: +# format, lint, workspace tests, and release WASM build. +verify: cargo fmt --check + cargo clippy --tests -- -D warnings cargo test --workspace cargo build --release --target $(WASM_TARGET) diff --git a/README.md b/README.md index 1961d29..a925845 100644 --- a/README.md +++ b/README.md @@ -95,14 +95,31 @@ All tests run natively (no WASM needed) using the Soroban SDK test utilities. --- +## Local verification + +Before opening a pull request, run the single local verification command: + +```bash +make verify +``` + +This runs the same checks contributors are asked to confirm in the PR template: + +1. `cargo fmt --check` +2. `cargo clippy --tests -- -D warnings` +3. `cargo test --workspace` +4. `cargo build --release --target wasm32-unknown-unknown` + +See [CONTRIBUTING.md](CONTRIBUTING.md#build-format-and-test) for details and for running each step individually. + ## Task Runner Common tasks are available via `make`: ```bash -make test # Run all tests -make build-wasm # Build the contract WASM in release mode -make clean # Clean build artifacts +make verify # Format, lint, test, and release WASM build +make build-release # Optimized WASM build with size report +make wasm-size # Report size of an existing release WASM ``` --- @@ -246,9 +263,10 @@ Contributions are welcome! This project is intentionally beginner-friendly. See **[CONTRIBUTING.md](CONTRIBUTING.md)** for the full guide, including: +- How to run local verification (`make verify`) - How to format code (`cargo fmt`) -- How to lint code (`cargo clippy -- -D warnings`) -- How to run the test suite (`cargo test`) +- How to lint code (`cargo clippy --tests -- -D warnings`) +- How to run the test suite (`cargo test --workspace`) - PR checklist and commit message conventions Every pull request must use the **[PR template](.github/PULL_REQUEST_TEMPLATE.md)**, which requires: @@ -258,16 +276,14 @@ Every pull request must use the **[PR template](.github/PULL_REQUEST_TEMPLATE.md - A description of tests added or updated - A **[traceability table](docs/traceability-table.md)** mapping each acceptance criterion to changed functions, tests, and edge cases - A security considerations section (with checklist for contract changes) -- Confirmation that `cargo fmt --check`, `cargo clippy --tests -- -D warnings`, and `cargo test --workspace` all pass +- Confirmation that `make verify` passes (or equivalently `cargo fmt --check`, `cargo clippy --tests -- -D warnings`, and `cargo test --workspace`) - CI green before requesting review Quick start: ```bash -# Fork & clone, then verify everything is green before making changes -cargo fmt --check -cargo clippy --tests -- -D warnings -cargo test +# Fork & clone, then verify everything is green before opening a PR +make verify ``` --- diff --git a/docs/advanced-development-and-testing.md b/docs/advanced-development-and-testing.md index ac2652c..f811210 100644 --- a/docs/advanced-development-and-testing.md +++ b/docs/advanced-development-and-testing.md @@ -67,16 +67,11 @@ Before working with the test suite or compiling contract binaries, ensure your h ### Using the `Makefile` Task Runner -The repository includes standard Makefile targets to streamline common workflow steps: +The repository includes Makefile targets to streamline common workflow steps: -- **Run all unit & integration tests:** +- **Run all local verification checks** (format, Clippy, tests, release WASM build): ```bash - make test - ``` - -- **Build release WASM binary:** - ```bash - make build-wasm + make verify ``` - **Build release WASM and print binary size report:** @@ -89,14 +84,11 @@ The repository includes standard Makefile targets to streamline common workflow make wasm-size ``` -- **Clean build artifacts:** - ```bash - make clean - ``` - The compiled release WebAssembly artifact is created at: `target/wasm32-unknown-unknown/release/savings_vault.wasm` +See also the README [Local verification](../README.md#local-verification) section and [CONTRIBUTING.md](../CONTRIBUTING.md#build-format-and-test). + --- ## 3. Test Suite Architecture and Organization diff --git a/docs/contribution-quality-gate.md b/docs/contribution-quality-gate.md index 414e6a0..12c98e4 100644 --- a/docs/contribution-quality-gate.md +++ b/docs/contribution-quality-gate.md @@ -27,6 +27,7 @@ Every PR must satisfy the following checklist. If any item is missing or incompl - [ ] **Formatting**: Code is formatted via `cargo fmt`. - [ ] **Lints**: `cargo clippy --tests` passes with no warnings. - [ ] **Build**: `make build-release` succeeds and the WASM size remains within acceptable limits. +- [ ] **Local verification**: `make verify` passes (format, Clippy, tests, and release WASM build). --- diff --git a/docs/deployment-environments.md b/docs/deployment-environments.md index 6d783a8..6c8bb36 100644 --- a/docs/deployment-environments.md +++ b/docs/deployment-environments.md @@ -27,6 +27,9 @@ No RPC URL, network passphrase, or funded account is needed for local developmen ### Commands ```bash +# Single local verification gate (format, lint, test, release WASM build) +make verify + # Build cargo build --target wasm32-unknown-unknown cargo build --target wasm32-unknown-unknown --release diff --git a/docs/local-development.md b/docs/local-development.md index 737a54f..e0c3cc2 100644 --- a/docs/local-development.md +++ b/docs/local-development.md @@ -41,6 +41,16 @@ The compiled `.wasm` file will be at: target/wasm32-unknown-unknown/release/savings_vault.wasm ``` +## Local verification + +Before opening a pull request, run the single local verification command from the repository root: + +```bash +make verify +``` + +This checks formatting, Clippy, the workspace test suite, and the release WASM build. See [CONTRIBUTING.md](../CONTRIBUTING.md#build-format-and-test) and the README [Local verification](../README.md#local-verification) section. + ## Run Unit Tests The project includes a comprehensive unit test suite that runs natively without needing a network: