Skip to content

Commit

Permalink
style: formatting (#184)
Browse files Browse the repository at this point in the history
Co-authored-by: Tin Chung <[email protected]>
  • Loading branch information
evilrobot-01 and chungquantin committed Sep 6, 2024
1 parent 7c69607 commit 7eb9981
Show file tree
Hide file tree
Showing 39 changed files with 953 additions and 854 deletions.
24 changes: 24 additions & 0 deletions .githooks/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Git Hooks

A pre-push hook which checks formatting of Rust files. Additional checks may be added in the future.

# Prerequisites

The following prerequisites are required:

## Rust Nightly

The nightly version of Rust provides additional formatting benefits over the stable version.

```shell
rustup toolchain install nightly --profile minimal --component rustfmt
```

# Installation

Use the following command in the root directory of the local repository to configure Git to use the hooks:

```shell
git config core.hooksPath .githooks
```

14 changes: 14 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

set -eu

# Check Rust formatting
if ! cargo +nightly fmt --all -- --check
then
echo "There are some code style issues."
# shellcheck disable=SC2006
echo "Run 'cargo +nightly fmt --all' first."
exit 1
fi

exit 0
20 changes: 18 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,36 @@ name: ci

on:
push:
branches: [ main ]
branches: [main]
pull_request:
types: [ opened, synchronize, reopened, ready_for_review ]
types: [opened, synchronize, reopened, ready_for_review]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: "./.github/actions/init"

- name: Check formatting
run: |
rustup toolchain install nightly --profile minimal --component rustfmt
cargo +nightly fmt --all -- --check
- name: Check manifests
run: |
cargo install taplo-cli --locked
taplo format --check
- name: Check features
run: |
cargo install zepter --locked
zepter lint propagate-feature --feature try-runtime --left-side-feature-missing=ignore --workspace --feature-enables-dep="try-runtime:frame-try-runtime" --locked
zepter lint propagate-feature --feature runtime-benchmarks --left-side-feature-missing=ignore --workspace --feature-enables-dep="runtime-benchmarks:frame-benchmarking" --locked
zepter lint propagate-feature --feature std --left-side-feature-missing=ignore --workspace --locked
zepter format features
check:
needs: lint
runs-on: ubuntu-latest
Expand All @@ -35,6 +50,7 @@ jobs:
permissions:
checks: write
env:
RUSTFLAGS: "-Wmissing_docs"
SKIP_WASM_BUILD: 1
steps:
- uses: actions/checkout@v4
Expand Down
32 changes: 16 additions & 16 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Basic
# Non-default formatting configuration options: use with `cargo +nightly fmt --all`
binop_separator = "Back"
chain_width = 80
combine_control_expr = false
comment_width = 100
condense_wildcard_suffixes = true
edition = "2021"
format_code_in_doc_comments = true
format_strings = true
group_imports = "StdExternalCrate"
hard_tabs = true
max_width = 100
use_small_heuristics = "Max"
# Imports
imports_granularity = "Crate"
reorder_imports = true
# Consistency
newline_style = "Unix"
# Misc
chain_width = 80
spaces_around_ranges = false
binop_separator = "Back"
reorder_impl_items = false
match_arm_leading_pipes = "Preserve"
match_arm_blocks = false
match_block_trailing_comma = true
trailing_comma = "Vertical"
newline_style = "Unix"
normalize_comments = true
reorder_impl_items = true
trailing_semicolon = false
unstable_features = true
use_field_init_shorthand = true
# Format comments
comment_width = 100
# Uses max_width or its default value (100) if not specified.
use_small_heuristics = "Max"
use_try_shorthand = true
wrap_comments = true
17 changes: 17 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# all options https://taplo.tamasfe.dev/configuration/formatter-options.html

exclude = [ "networks/**", "target/**" ]

# global rules
[formatting]
array_auto_collapse = false
array_auto_expand = true
compact_arrays = false # zepter compatibility
indent_string = " " # tab
inline_table_expand = false
reorder_arrays = true
reorder_keys = true

[[rule]]
include = [ "Cargo.toml" ]
keys = [ "workspace.dependencies" ]
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ resolver = "2"

[workspace.dependencies]
clap = { version = "4.4.18", features = [ "derive" ] }
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = [
codec = { package = "parity-scale-codec", version = "3.6.12", default-features = false, features = [
"derive",
] }
contract-build = "4.1.1"
Expand All @@ -38,14 +38,14 @@ futures = "0.3.28"
hex-literal = "0.4.1"
impl-trait-for-tuples = "0.2.2"
jsonrpsee = { version = "0.23.2", features = [ "server" ] }
log = { version = "0.4.20", default-features = false }
log = { version = "0.4.21", default-features = false }
rand = "0.8.5"
scale-info = { version = "2.10.0", default-features = false, features = [
scale-info = { version = "2.11.1", default-features = false, features = [
"derive",
] }
serde = "1.0.195"
serde_json = "1.0.111"
smallvec = "1.11.0"
serde = "1.0.197"
serde_json = "1.0.114"
smallvec = "1.11.2"
subxt = "0.34.0"
subxt-signer = "0.34.0"
tokio = { version = "1.36", features = [ "macros", "rt-multi-thread", "time" ] }
Expand Down
102 changes: 52 additions & 50 deletions integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
[package]
name = "integration-tests"
authors.workspace = true
edition.workspace = true
homepage.workspace = true
license.workspace = true
name = "integration-tests"
repository.workspace = true

[dev-dependencies]
codec.workspace = true
tracing-subscriber = { workspace = true, features = [
"env-filter",
"fmt",
"std",
"tracing-log",
"env-filter",
"fmt",
"std",
"tracing-log",
] }

# Substrate
frame-support.workspace = true
pallet-assets.workspace = true
pallet-balances.workspace = true
pallet-message-queue.workspace = true
sp-core.workspace = true
sp-authority-discovery.workspace = true
sp-consensus-aura.workspace = true
sp-consensus-babe.workspace = true
sp-consensus-beefy.workspace = true
sp-consensus-grandpa.workspace = true
sp-core.workspace = true
sp-runtime.workspace = true

# Polkadot
pallet-xcm.workspace = true
polkadot-primitives.workspace = true
polkadot-runtime-parachains.workspace = true
xcm.workspace = true
xcm-executor.workspace = true
polkadot-runtime-parachains.workspace = true
pallet-xcm.workspace = true

# Cumulus
asset-test-utils.workspace = true
Expand All @@ -46,56 +46,58 @@ paseo-runtime.workspace = true
paseo-runtime-constants.workspace = true

# Local
pop-runtime-devnet.workspace = true
pop-runtime-common.workspace = true
pop-runtime-devnet.workspace = true

[features]
default = ["std"]
default = [ "std" ]
std = [
"asset-hub-paseo-runtime/std",
"cumulus-primitives-core/std",
"frame-support/std",
"pallet-assets/std",
"pallet-balances/std",
"pallet-message-queue/std",
"pallet-xcm/std",
"paseo-runtime/std",
"paseo-runtime-constants/std",
"polkadot-primitives/std",
"polkadot-runtime-parachains/std",
"pop-runtime-devnet/std",
"sp-authority-discovery/std",
"sp-consensus-aura/std",
"sp-consensus-babe/std",
"sp-consensus-beefy/std",
"sp-consensus-grandpa/std",
"sp-core/std",
"sp-runtime/std",
"xcm-executor/std",
"xcm/std",
"asset-hub-paseo-runtime/std",
"cumulus-primitives-core/std",
"frame-support/std",
"pallet-assets/std",
"pallet-balances/std",
"pallet-message-queue/std",
"pallet-xcm/std",
"paseo-runtime-constants/std",
"paseo-runtime/std",
"polkadot-primitives/std",
"polkadot-runtime-parachains/std",
"pop-runtime-common/std",
"pop-runtime-devnet/std",
"sp-authority-discovery/std",
"sp-consensus-aura/std",
"sp-consensus-babe/std",
"sp-consensus-beefy/std",
"sp-consensus-grandpa/std",
"sp-core/std",
"sp-runtime/std",
"xcm-executor/std",
"xcm/std",
]

runtime-benchmarks = [
"asset-hub-paseo-runtime/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"paseo-runtime/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"pop-runtime-devnet/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
"asset-hub-paseo-runtime/runtime-benchmarks",
"cumulus-primitives-core/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-message-queue/runtime-benchmarks",
"paseo-runtime/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"pop-runtime-common/runtime-benchmarks",
"pop-runtime-devnet/runtime-benchmarks",
"sp-runtime/runtime-benchmarks",
"xcm-executor/runtime-benchmarks",
]

try-runtime = [
"asset-hub-paseo-runtime/try-runtime",
"frame-support/try-runtime",
"pallet-assets/try-runtime",
"pallet-balances/std",
"pallet-message-queue/try-runtime",
"paseo-runtime/try-runtime",
"pop-runtime-devnet/try-runtime",
"sp-runtime/try-runtime",
"asset-hub-paseo-runtime/try-runtime",
"frame-support/try-runtime",
"pallet-assets/try-runtime",
"pallet-balances/std",
"pallet-message-queue/try-runtime",
"paseo-runtime/try-runtime",
"pop-runtime-devnet/try-runtime",
"sp-runtime/try-runtime",
]
11 changes: 6 additions & 5 deletions integration-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
#![cfg(test)]

use crate::chains::{
asset_hub_paseo::{genesis::ED as ASSET_HUB_PASEO_ED, AssetHubPaseoParaPallet},
paseo::{genesis::ED as PASEO_ED, PaseoRelayPallet},
pop_network::PopNetworkParaPallet,
};
use asset_hub_paseo_runtime::xcm_config::XcmConfig as AssetHubPaseoXcmConfig;
use asset_test_utils::xcm_helpers;
use chains::{asset_hub_paseo::AssetHubPaseo, paseo::Paseo, pop_network::PopNetwork};
Expand All @@ -22,6 +17,12 @@ use pop_runtime_common::Balance;
use pop_runtime_devnet::config::xcm::XcmConfig as PopNetworkXcmConfig;
use xcm::prelude::*;

use crate::chains::{
asset_hub_paseo::{genesis::ED as ASSET_HUB_PASEO_ED, AssetHubPaseoParaPallet},
paseo::{genesis::ED as PASEO_ED, PaseoRelayPallet},
pop_network::PopNetworkParaPallet,
};

mod chains;

decl_test_networks! {
Expand Down
Loading

0 comments on commit 7eb9981

Please sign in to comment.