diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml new file mode 100644 index 0000000..1d17cc7 --- /dev/null +++ b/.github/workflows/ci-tests.yml @@ -0,0 +1,70 @@ +name: "ci tests" + +on: + push: + branches: + - main + - plain-cumulus-template + paths-ignore: + - "**.md" + pull_request: + paths-ignore: + - "**.md" + workflow_dispatch: + inputs: + test-macos-and-windows: + description: "run macOS and Windows tests" + required: true + default: false + type: boolean + +env: + # Not needed in CI, should make things a bit faster + CARGO_INCREMENTAL: 0 + CARGO_TERM_COLOR: always + # Remove unnecessary WASM build artefacts + WASM_BUILD_CLEAN_TARGET: 1 + +jobs: + clippy-fmt-test: + strategy: + fail-fast: false + matrix: + os: + - ubuntu-22.04 + - macos-12 + - windows-2022 + run-all: + - ${{ inputs.test-macos-and-windows == true || github.ref == 'refs/heads/main' }} + exclude: # exclude macos-12 and windows-2022 when the condition is false + - run-all: false + os: macos-12 + - run-all: false + os: windows-2022 + + runs-on: ${{ matrix.os }} + steps: + - name: git checkout + uses: actions/checkout@v4 + + - name: Install Protoc + uses: arduino/setup-protoc@9b1ee5b22b0a3f1feb8c2ff99b32c89b3c3191e9 # v2.0.0 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: install rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + + - name: cargo fmt + run: cargo fmt --all -- --check + + - name: cargo test --release --locked + run: cargo test + + - name: cargo clippy --release --locked + run: cargo clippy --locked --all-targets -- -D warnings + + - name: Check Documentation + run: cargo doc --locked --all --no-deps + env: + RUSTDOCFLAGS: "-D rustdoc::broken-intra-doc-links -D rustdoc::private_intra_doc_links" diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ec72996..e9ce422 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -10,7 +10,10 @@ Before starting development, please [create an issue](https://github.com/OpenZep ### Coding style -`rustfmt.toml` +You can check out `[rustfmt.toml](https://github.com/OpenZeppelin/polkadot-runtime-template/blob/main/rustfmt.toml)`. + +Also, we suggest enabling `format-on-save` feature of your code editor. + ## Creating Pull Requests (PRs) diff --git a/Cargo.toml b/Cargo.toml index 138eaa2..6c7a529 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,3 +6,9 @@ resolver = "2" [profile.release] panic = "unwind" + + +[workspace.lints.clippy] +type_complexity = "allow" +too_many_arguments = "allow" +large_enum_variant = "allow" diff --git a/node/Cargo.toml b/node/Cargo.toml index 24d5ff8..a54d1d4 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -91,3 +91,7 @@ try-runtime = [ "polkadot-cli/try-runtime", "sp-runtime/try-runtime", ] + + +[lints] +workspace = true diff --git a/node/src/command.rs b/node/src/command.rs index 07c2e3d..17fc527 100644 --- a/node/src/command.rs +++ b/node/src/command.rs @@ -193,12 +193,11 @@ pub fn run() -> Result<()> { }), #[cfg(not(feature = "runtime-benchmarks"))] BenchmarkCmd::Storage(_) => - return Err(sc_cli::Error::Input( + Err(sc_cli::Error::Input( "Compile with --features=runtime-benchmarks \ to enable storage benchmarks." .into(), - ) - .into()), + )), #[cfg(feature = "runtime-benchmarks")] BenchmarkCmd::Storage(cmd) => runner.sync_run(|config| { let partials = new_partial(&config)?; diff --git a/runtime/src/lib.rs b/runtime/src/lib.rs index 37611d9..58422a9 100644 --- a/runtime/src/lib.rs +++ b/runtime/src/lib.rs @@ -385,8 +385,9 @@ impl InstanceFilter for ProxyType { RuntimeCall::Proxy(pallet_proxy::Call::reject_announcement { .. }) | RuntimeCall::Multisig { .. } ), - ProxyType::Collator => - matches!(c, RuntimeCall::CollatorSelection { .. } | RuntimeCall::Multisig { .. }), + ProxyType::Collator => { + matches!(c, RuntimeCall::CollatorSelection { .. } | RuntimeCall::Multisig { .. }) + } } } } diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..8f155ee --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,4 @@ +[toolchain] +channel = "nightly-2023-09-21" +targets = ["wasm32-unknown-unknown"] +components = ["rustfmt", "clippy"] diff --git a/rustfmt.toml b/rustfmt.toml index 8c87ec0..e221b81 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,4 +1,4 @@ -format_code_in_doc_comments = true + format_macro_bodies = true format_macro_matchers = true format_strings = true @@ -8,4 +8,11 @@ reorder_impl_items = true group_imports = "StdExternalCrate" use_field_init_shorthand = true use_small_heuristics = "Max" -wrap_comments = true + +# most of these are unstable, so we enable them +unstable_features = true + + +# wanted to enable below, but they are removing the documentation comments if there is an empty line in between +# wrap_comments = true +# format_code_in_doc_comments = true