diff --git a/.github/actions/cargo-command/action.yaml b/.github/actions/cargo-command/action.yaml index c6ed7287c..4b6db0faa 100644 --- a/.github/actions/cargo-command/action.yaml +++ b/.github/actions/cargo-command/action.yaml @@ -6,7 +6,7 @@ inputs: required: false default: 'build' package: - description: 'Limit execution to a specific package' + description: 'Limit execution to a specific package, assumes workspace if unset' required: false profile: description: 'Profile under which to run cargo command' @@ -18,6 +18,14 @@ inputs: args: description: 'Additional argument to pass to cargo invocation' required: false + cache: + description: 'Whether to enable registry, index and compile output caching' + required: false + default: true + annotate: + description: 'Whether to provide errors as GitHub annotations' + required: false + default: true runs: using: "composite" steps: @@ -25,31 +33,34 @@ runs: shell: bash run: rustup show - name: Install cargo-cache + if: ${{ inputs.annotate }} shell: bash run: cargo install cargo-action-fmt - name: Cache cargo registry and index + if: ${{ inputs.cache }} uses: actions/cache@v4 with: path: | ~/.cargo/registry/index/ ~/.cargo/registry/cache/ ~/.cargo/git/db/ - key: cargo-cache-${{ inputs.package || 'workspace' }}-${{ inputs.features || 'default' }}-${{ hashFiles('Cargo.lock') }} + key: cargo-cache-${{ inputs.package || 'workspace' }}-${{ join(inputs.features,'_') || 'default' }}-${{ hashFiles('Cargo.lock') }} restore-keys: | - cargo-cache-${{ inputs.package || 'workspace' }}-${{ inputs.features || 'default' }}- + cargo-cache-${{ inputs.package || 'workspace' }}-${{ join(inputs.features,'_') || 'default' }}- cargo-cache-${{ inputs.package || 'workspace' }}-default- cargo-cache-workspace- - name: Cache cargo target folder + if: ${{ inputs.cache }} uses: actions/cache@v4 with: path: target - key: cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-${{ inputs.features || 'default' }}-${{ hashFiles('Cargo.lock') }} + key: cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-${{ join(inputs.features,'_') || 'default' }}-${{ hashFiles('Cargo.lock') }} restore-keys: | - cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-${{ inputs.features || 'default' }}- + cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-${{ join(inputs.features,'_') || 'default' }}- cargo-${{ inputs.command }}-${{ inputs.profile }}-${{ inputs.package || 'workspace' }}-default- cargo-${{ inputs.command }}-${{ inputs.profile }}-workspace- - name: Run cargo ${{ inputs.command }} env: CARGO_TERM_COLOR: always shell: bash - run: cargo ${{ inputs.command }} ${{ inputs.package != '' && '--package' || '' }} ${{ inputs.package }} --profile '${{ inputs.profile }}' --features '${{ inputs.features }}' --message-format json ${{ inputs.args }} | cargo-action-fmt + run: cargo ${{ inputs.command }} ${{ inputs.package && '--package' || '--workspace' }} ${{ inputs.package }} --profile '${{ inputs.profile }}' --features '${{ join(inputs.features,',') }}' ${{ inputs.annotate && '--message-format json' || '' }} ${{ inputs.args }} ${{ inputs.annotate && '| cargo-action-fmt' || '' }} diff --git a/.github/workflows/merge-pages-docs.yaml b/.github/workflows/merge-pages-docs.yaml index 9c3f9ee2e..0c4b8246e 100644 --- a/.github/workflows/merge-pages-docs.yaml +++ b/.github/workflows/merge-pages-docs.yaml @@ -36,7 +36,7 @@ jobs: uses: ./.github/actions/cargo-command with: command: doc - args: --workspace --no-deps --document-private-items + args: --no-deps --document-private-items - name: Assemble structure env: DOCS_HIDEOUT: an8ohgahmoot6ro8ieReib9micau0Oow diff --git a/.github/workflows/pr-build-docs.yaml b/.github/workflows/pr-build-docs.yaml index f96d8a218..f1707dc24 100644 --- a/.github/workflows/pr-build-docs.yaml +++ b/.github/workflows/pr-build-docs.yaml @@ -30,7 +30,7 @@ jobs: uses: ./.github/actions/cargo-command with: command: doc - args: --workspace --no-deps --document-private-items + args: --no-deps --document-private-items - name: Upload docs uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/pr-build-runtime.yaml b/.github/workflows/pr-build-runtime.yaml index 92b259ef2..93ba4b8e0 100644 --- a/.github/workflows/pr-build-runtime.yaml +++ b/.github/workflows/pr-build-runtime.yaml @@ -35,7 +35,6 @@ jobs: uses: ./.github/actions/cargo-command with: package: ${{ matrix.package }} - profile: release features: ${{ matrix.features }} - name: Upload timechain runtime uses: actions/upload-artifact@v4 @@ -86,6 +85,6 @@ jobs: echo "metadata changes detected: committing updated metadata" git config user.email "github@analog.one" git config user.name "Metadata Update Bot" - git commit -am "tc-subxt: Automated metadata update" + git commit -am "tc-subxt: Automatic metadata update" git push fi diff --git a/.github/workflows/pr-test-cargo.yaml b/.github/workflows/pr-test-cargo.yaml index 6e6bce5f2..706b9f6ed 100644 --- a/.github/workflows/pr-test-cargo.yaml +++ b/.github/workflows/pr-test-cargo.yaml @@ -1,4 +1,4 @@ -name: Check cargo tests +name: Check testsuite on: pull_request: paths: @@ -24,26 +24,21 @@ concurrency: jobs: test-cargo: runs-on: [self-hosted, general] - strategy: - fail-fast: false - matrix: - include: - - command: clippy - args: --all-targets --workspace --examples --tests -- --no-deps -D warnings - - command: test - args: --workspace --locked - - command: check - features: runtime-benchmarks - - command: check - features: try-runtime steps: - name: Checkout sources uses: actions/checkout@v4 with: submodules: recursive - - name: Run cargo command + - name: Build testsuite uses: ./.github/actions/cargo-command with: - command: ${{ matrix.command }} - features: ${{ matrix.features }} - args: ${{ matrix.args }} + command: test + features: [runtime-benchmarks, try-runtime] + args: --no-run + - name: Run testsuite + uses: ./.github/actions/cargo-command + with: + command: test + features: [runtime-benchmarks, try-runtime] + cache: false + annotate: false diff --git a/.github/workflows/pr-test-clippy.yaml b/.github/workflows/pr-test-clippy.yaml new file mode 100644 index 000000000..a7339aea7 --- /dev/null +++ b/.github/workflows/pr-test-clippy.yaml @@ -0,0 +1,37 @@ +name: Check code linter +on: + pull_request: + paths: + - '.github/actions/cargo-command/**' + - '.github/workflows/pr-test-clippy.yaml' + - 'chronicle/**' + - 'config/subxt/**' + - 'docs/**' + - 'node/**' + - 'pallets/**' + - 'primitives/**' + - 'runtime/**' + - 'tc-subxt/**' + - 'tester/**' + - 'tss/**' + - 'utils/**' + - 'Cargo.toml' + - 'Cargo.lock' + - 'rust-toolchain.toml' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + test-clippy: + runs-on: [self-hosted, general] + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + submodules: recursive + - name: Run clippy linter + uses: ./.github/actions/cargo-command + with: + command: clippy + features: [runtime-benchmarks, try-runtime] + args: --all-targets -- -D warnings diff --git a/.github/workflows/pr-test-rustfmt.yaml b/.github/workflows/pr-test-rustfmt.yaml index 34ed6f77f..833c07436 100644 --- a/.github/workflows/pr-test-rustfmt.yaml +++ b/.github/workflows/pr-test-rustfmt.yaml @@ -28,4 +28,4 @@ jobs: - name: Install rust toolchain run: rustup show - name: Run cargo fmt - run: cargo fmt --all -- --check + run: cargo fmt --all --check diff --git a/docs/src/lib.rs b/docs/src/lib.rs index 7546546d8..7a3f8480d 100644 --- a/docs/src/lib.rs +++ b/docs/src/lib.rs @@ -6,7 +6,7 @@ //! ## The Timechain Protocol //! //! The Analog Timechain is a substrate based solochain. It utilizes -//! Babe and Grandpa to power its [`timechain_node`] and [`timechain_runtime`]. +//! Babe and Grandpa to power its `timechain_node` and [`timechain_runtime`]. //! //! On top of that it runs the Timechain protocol to attest and relay data //! between various chains. This protocol is executed by shards of [`chronicle`] nodes. diff --git a/pallets/networks/src/benchmarking.rs b/pallets/networks/src/benchmarking.rs index d27978607..7fd8a7603 100644 --- a/pallets/networks/src/benchmarking.rs +++ b/pallets/networks/src/benchmarking.rs @@ -19,7 +19,7 @@ benchmarks! { for _ in 0..b { network.push('b'); } - }: _(RawOrigin::Root, name.into(), network.into()) + }: _(RawOrigin::Root, name, network) verify {} impl_benchmark_test_suite!(Pallet, crate::mock::new_test_ext(), crate::mock::Test); diff --git a/pallets/shards/src/benchmarking.rs b/pallets/shards/src/benchmarking.rs index 8a753a404..99e3dee49 100644 --- a/pallets/shards/src/benchmarking.rs +++ b/pallets/shards/src/benchmarking.rs @@ -27,7 +27,7 @@ benchmarks! { Pallet::::commit( RawOrigin::Signed(member.clone()).into(), 0, - vec![public_key.clone()], + vec![public_key], [0; 65], )?; } @@ -45,7 +45,7 @@ benchmarks! { Pallet::::commit( RawOrigin::Signed(member.clone()).into(), 0, - vec![public_key.clone()], + vec![public_key], [0; 65], )?; } diff --git a/pallets/tasks/src/benchmarking.rs b/pallets/tasks/src/benchmarking.rs index a2348dcc5..5a567cacb 100644 --- a/pallets/tasks/src/benchmarking.rs +++ b/pallets/tasks/src/benchmarking.rs @@ -136,7 +136,7 @@ benchmarks! { let mut i = 0u8; while u16::from(i) < ::Elections::default_shard_size() { let member = [i; 32]; - let member_account: AccountId = member.clone().into(); + let member_account: AccountId = member.into(); pallet_balances::Pallet::::resolve_creating( &member_account, pallet_balances::Pallet::::issue(::MinStake::get() * 100), @@ -144,7 +144,7 @@ benchmarks! { pallet_members::Pallet::::register_member( RawOrigin::Signed(member_account).into(), ETHEREUM, - public_key(member.clone()), + public_key(member), member, ::MinStake::get(), )?; @@ -172,7 +172,7 @@ benchmarks! { pallet_members::Pallet::::register_member( RawOrigin::Signed(assigned_signer.clone()).into(), ETHEREUM, - public_key(raw_signer.clone()), + public_key(raw_signer), raw_signer, ::MinStake::get(), )?; @@ -191,7 +191,7 @@ benchmarks! { let mut i = 0u8; while u16::from(i) < ::Elections::default_shard_size() { let member = [i; 32]; - let member_account: AccountId = member.clone().into(); + let member_account: AccountId = member.into(); pallet_balances::Pallet::::resolve_creating( &member_account, pallet_balances::Pallet::::issue(::MinStake::get() * 100), @@ -199,7 +199,7 @@ benchmarks! { pallet_members::Pallet::::register_member( RawOrigin::Signed(member_account).into(), ETHEREUM, - public_key(member.clone()), + public_key(member), member, ::MinStake::get(), )?; @@ -213,7 +213,7 @@ benchmarks! { ShardState::::insert(0, ShardStatus::Online); Pallet::::shard_online(0, ETHEREUM); let raw_caller = [0u8; 32]; - let caller: AccountId = raw_caller.clone().into(); + let caller: AccountId = raw_caller.into(); Pallet::::create_task(RawOrigin::Signed(caller.clone()).into(), descriptor)?; Pallet::::register_gateway(RawOrigin::Root.into(), 0, [0u8; 20], 0)?; let (pub_key, signature) = mock_submit_sig(); @@ -276,7 +276,7 @@ benchmarks! { Pallet::::shard_online(j, ETHEREUM); Pallet::::register_gateway(RawOrigin::Root.into(), j, [0u8; 20], 20)?; } - }: _(RawOrigin::Root, b.into()) verify {} + }: _(RawOrigin::Root, b) verify {} set_batch_size { }: _(RawOrigin::Root, ETHEREUM, 100, 25) verify {}