Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add cargo #6

Merged
merged 51 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 50 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
2e85e5a
feat: Add taplo CI
aidan46 May 8, 2024
a89271e
feat: Add taplo config file
aidan46 May 8, 2024
3dd4d06
feat: Add path to taplo CI
aidan46 May 8, 2024
7625986
ci: Update taplo CI
aidan46 May 8, 2024
e8d9823
ci: Move taplo.yaml into ci.yaml
May 8, 2024
4e27a18
ci: Change taplo rules
May 8, 2024
a7c35dc
ci: Add cargo version for debugging
May 8, 2024
0306e16
ci: Add taplo version for debugging
May 8, 2024
af2e853
ci: Add version for debugging
May 8, 2024
0d868f3
ci: Formatting
May 8, 2024
e6fda54
ci: Change workflow name
aidan46 May 9, 2024
c2ec968
ci: Remove path filtering
aidan46 May 10, 2024
878fc5d
ci: Add cargo fmt job
aidan46 May 10, 2024
f7823aa
ci: Add rustfmt for format rules
aidan46 May 10, 2024
73f634c
ci: Add clippy job
aidan46 May 10, 2024
fb95a52
ci: Add build job
aidan46 May 10, 2024
60ea24b
ci: Add test job
aidan46 May 10, 2024
5ba437d
ci: Add failure handling
aidan46 May 10, 2024
4b06884
ci: Add wasm target to relevant jobs
aidan46 May 13, 2024
e826882
ci: Add nightly toolchain to fmt job
aidan46 May 13, 2024
97b7fe5
ci: Add rusfmt component to format job
aidan46 May 13, 2024
a18daba
ci: Add protobuf compiler package to test job
aidan46 May 13, 2024
e255209
ci: Add protobuf compiler to build job
aidan46 May 13, 2024
d0fe799
ci: Add protobuf compiler to format job
aidan46 May 13, 2024
418e60c
ci: Add stable target to relevant jobs
aidan46 May 13, 2024
6c51b1f
ci: Add nightly toolchain
aidan46 May 13, 2024
af59493
ci: Pin rust toolchain to 1.77
aidan46 May 13, 2024
c3a5895
style: Format toml files
aidan46 May 13, 2024
86ba23b
style: Format `.rs` files
aidan46 May 13, 2024
96778e1
ci: Remove job run on PR
aidan46 May 13, 2024
a111251
Merge remote-tracking branch 'origin/feat/1/project-setup' into feat/…
aidan46 May 13, 2024
6fdf0b2
fix: Duplicate dependencies
aidan46 May 13, 2024
c89ff2b
style: Format rust files
aidan46 May 13, 2024
d355a78
ci: Move clippy build and test into 1 job
aidan46 May 13, 2024
5d3b9fb
ci: Add rust-src component
aidan46 May 13, 2024
c53aff2
ci: Single failure handling
aidan46 May 13, 2024
74461e2
fix: Double import after merge
aidan46 May 13, 2024
e312050
ci: Add `-q` flag to not convolute logs
aidan46 May 13, 2024
47107ef
ci: Cancel previous job on push
aidan46 May 13, 2024
9f07575
ci: Make CI run on comment
aidan46 May 13, 2024
fc7c004
ci: Add `--locked` flag to cargo jobs
aidan46 May 13, 2024
a8f4c60
ci: Run CI on label and push to dev/main
aidan46 May 14, 2024
da3474a
ci: Remove run on comment
aidan46 May 14, 2024
6c1a65b
ci: Add caching
aidan46 May 14, 2024
48b28e5
ci: Update cache action version
aidan46 May 14, 2024
5270d52
ci: Change cache job name
aidan46 May 14, 2024
c7b7df4
ci: Add hash of lock file to cache action
aidan46 May 14, 2024
9d604df
ci: Add caching of cargo bin
aidan46 May 14, 2024
edaa744
Merge branch 'develop' into feat/cargo-ci
serg-temchenko May 14, 2024
8d1536e
Merge remote-tracking branch 'origin/develop' into feat/cargo-ci
aidan46 May 15, 2024
cda2f9a
ci: Add no deps flag to clippy
aidan46 May 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 75 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
name: CI

on: [push, pull_request]
on:
pull_request:
types: [labeled]
push:
branches: [develop, main]

concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
toml:
Expand All @@ -20,4 +28,69 @@ jobs:
if: failure()
run: |
echo 'TOML is not formatted correctly'
echo 'Please run `taplo format`'
echo 'Please run taplo format'

format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
jmg-duarte marked this conversation as resolved.
Show resolved Hide resolved
with:
toolchain: nightly
components: rustfmt
- name: List version
run: |
cargo --version
cargo fmt --version
- name: Cargo format
run: cargo fmt --all -- --check
- name: Cargo fmt failure info
if: failure()
run: |
echo '.rs files are not formatted correctly'
echo 'Please run cargo fmt --all'

clippy_build_and_test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Cargo caching
uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('**/Cargo.toml') }}
- name: Install protobuf compiler
run: |
sudo apt-get update
sudo apt-get install protobuf-compiler
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.77.0
target: wasm32-unknown-unknown
components: clippy rust-src
- name: List version
run: |
cargo --version
cargo clippy --version
- name: Cargo clippy
run: cargo clippy --locked -q -- -D warnings
jmg-duarte marked this conversation as resolved.
Show resolved Hide resolved
- name: Build with try-runtime feature
run: RUSTFLAGS="-D warnings" cargo build --locked -q --features try-runtime
- name: Build node runtime
run: RUSTFLAGS="-D warnings" cargo build --locked -q -p polka-storage-runtime
- name: Build node with runtime-benchmark feature
run: RUSTFLAGS="-D warnings" cargo build --locked -q -p polka-storage-node --features runtime-benchmarks
- name: Build in release mode
run: RUSTFLAGS="-D warnings" cargo build --locked -q --release
- name: Run tests
run: RUSTFLAGS="-D warnings" cargo test --locked -q --workspace
- name: Failure handling
if: failure()
run: |
echo 'Job clippy_build_and_test failed.'
echo 'Please check the logs for more details'
3 changes: 3 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
edition = "2021"
group_imports = "StdExternalCrate"
imports_granularity = "Crate"
1 change: 0 additions & 1 deletion node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use std::sync::Arc;

use polka_storage_runtime::{opaque::Block, AccountId, Balance, Nonce};

pub use sc_rpc::DenyUnsafe;
use sc_transaction_pool_api::TransactionPool;
use sp_api::ProvideRuntimeApi;
Expand Down
12 changes: 5 additions & 7 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@
use std::{sync::Arc, time::Duration};

use cumulus_client_cli::CollatorOptions;
// Local Runtime Types
use polka_storage_runtime::{
apis::RuntimeApi,
opaque::{Block, Hash},
};

// Cumulus Imports
use cumulus_client_collator::service::CollatorService;
use cumulus_client_consensus_common::ParachainBlockImport as TParachainBlockImport;
Expand All @@ -21,9 +15,13 @@ use cumulus_client_service::{
};
use cumulus_primitives_core::{relay_chain::CollatorPair, ParaId};
use cumulus_relay_chain_interface::{OverseerHandle, RelayChainInterface};

// Substrate Imports
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
// Local Runtime Types
use polka_storage_runtime::{
apis::RuntimeApi,
opaque::{Block, Hash},
};
use sc_client_api::Backend;
use sc_consensus::ImportQueue;
use sc_executor::{HeapAllocStrategy, WasmExecutor, DEFAULT_HEAP_ALLOC_STRATEGY};
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/configs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_runtime::Perbill;
use sp_version::RuntimeVersion;
use xcm::latest::prelude::BodyId;
use xcm_config::{RelayLocation, XcmOriginToTransactDispatchOrigin};

// Local module imports
use super::{
Expand All @@ -60,7 +61,6 @@ use super::{
MAXIMUM_BLOCK_WEIGHT, MICROUNIT, NORMAL_DISPATCH_RATIO, RELAY_CHAIN_SLOT_DURATION_MILLIS,
SLOT_DURATION, UNINCLUDED_SEGMENT_CAPACITY, VERSION,
};
use xcm_config::{RelayLocation, XcmOriginToTransactDispatchOrigin};

parameter_types! {
pub const Version: RuntimeVersion = VERSION;
Expand Down
9 changes: 5 additions & 4 deletions runtime/src/configs/xcm_config.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
use crate::{
AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
};
use frame_support::{
parameter_types,
traits::{ConstU32, Contains, Everything, Nothing},
Expand All @@ -22,6 +18,11 @@ use xcm_builder::{
};
use xcm_executor::XcmExecutor;

use crate::{
AccountId, AllPalletsWithSystem, Balances, ParachainInfo, ParachainSystem, PolkadotXcm,
Runtime, RuntimeCall, RuntimeEvent, RuntimeOrigin, WeightToFee, XcmpQueue,
};

parameter_types! {
pub const RelayLocation: Location = Location::parent();
pub const RelayNetwork: Option<NetworkId> = None;
Expand Down
30 changes: 13 additions & 17 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,27 @@ pub mod apis;
mod configs;
mod weights;

use smallvec::smallvec;
use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{BlakeTwo256, IdentifyAccount, Verify},
MultiSignature,
};

use sp_std::prelude::*;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;

use frame_support::{
construct_runtime,
weights::{
constants::WEIGHT_REF_TIME_PER_SECOND, Weight, WeightToFeeCoefficient,
WeightToFeeCoefficients, WeightToFeePolynomial,
},
};
use smallvec::smallvec;
pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;
pub use sp_runtime::{MultiAddress, Perbill, Permill};

#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;

use sp_runtime::{
create_runtime_str, generic, impl_opaque_keys,
traits::{BlakeTwo256, IdentifyAccount, Verify},
MultiSignature,
};
pub use sp_runtime::{MultiAddress, Perbill, Permill};
use sp_std::prelude::*;
#[cfg(feature = "std")]
use sp_version::NativeVersion;
use sp_version::RuntimeVersion;
use weights::ExtrinsicBaseWeight;

/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.
Expand Down Expand Up @@ -129,13 +125,13 @@ impl WeightToFeePolynomial for WeightToFee {
/// of data like extrinsics, allowing for them to continue syncing the network through upgrades
/// to even the core data structures.
pub mod opaque {
use super::*;
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
use sp_runtime::{
generic,
traits::{BlakeTwo256, Hash as HashT},
};

pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
use super::*;
/// Opaque block header type.
pub type Header = generic::Header<BlockNumber, BlakeTwo256>;
/// Opaque block type.
Expand Down
3 changes: 2 additions & 1 deletion runtime/src/weights/paritydb_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ pub mod constants {

#[cfg(test)]
mod test_db_weights {
use super::constants::ParityDbWeight as W;
use frame_support::weights::constants;

use super::constants::ParityDbWeight as W;

/// Checks that all weights exist and have sane values.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
Expand Down
3 changes: 2 additions & 1 deletion runtime/src/weights/rocksdb_weights.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ pub mod constants {

#[cfg(test)]
mod test_db_weights {
use super::constants::RocksDbWeight as W;
use frame_support::weights::constants;

use super::constants::RocksDbWeight as W;

/// Checks that all weights exist and have sane values.
// NOTE: If this test fails but you are sure that the generated values are fine,
// you can delete it.
Expand Down