Skip to content

Commit

Permalink
ci: fix cargo test commands (#988)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianFranzen authored Jul 4, 2024
1 parent 7f0035f commit 3de8687
Show file tree
Hide file tree
Showing 11 changed files with 81 additions and 39 deletions.
23 changes: 17 additions & 6 deletions .github/actions/cargo-command/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -18,38 +18,49 @@ 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:
- name: Install rust toolchain
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' || '' }}
2 changes: 1 addition & 1 deletion .github/workflows/merge-pages-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr-build-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/pr-build-runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -86,6 +85,6 @@ jobs:
echo "metadata changes detected: committing updated metadata"
git config user.email "[email protected]"
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
29 changes: 12 additions & 17 deletions .github/workflows/pr-test-cargo.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Check cargo tests
name: Check testsuite
on:
pull_request:
paths:
Expand All @@ -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
37 changes: 37 additions & 0 deletions .github/workflows/pr-test-clippy.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion .github/workflows/pr-test-rustfmt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pallets/networks/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions pallets/shards/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ benchmarks! {
Pallet::<T>::commit(
RawOrigin::Signed(member.clone()).into(),
0,
vec![public_key.clone()],
vec![public_key],
[0; 65],
)?;
}
Expand All @@ -45,7 +45,7 @@ benchmarks! {
Pallet::<T>::commit(
RawOrigin::Signed(member.clone()).into(),
0,
vec![public_key.clone()],
vec![public_key],
[0; 65],
)?;
}
Expand Down
14 changes: 7 additions & 7 deletions pallets/tasks/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ benchmarks! {
let mut i = 0u8;
while u16::from(i) < <T as Config>::Elections::default_shard_size() {
let member = [i; 32];
let member_account: AccountId = member.clone().into();
let member_account: AccountId = member.into();
pallet_balances::Pallet::<T>::resolve_creating(
&member_account,
pallet_balances::Pallet::<T>::issue(<T as pallet_members::Config>::MinStake::get() * 100),
);
pallet_members::Pallet::<T>::register_member(
RawOrigin::Signed(member_account).into(),
ETHEREUM,
public_key(member.clone()),
public_key(member),
member,
<T as pallet_members::Config>::MinStake::get(),
)?;
Expand Down Expand Up @@ -172,7 +172,7 @@ benchmarks! {
pallet_members::Pallet::<T>::register_member(
RawOrigin::Signed(assigned_signer.clone()).into(),
ETHEREUM,
public_key(raw_signer.clone()),
public_key(raw_signer),
raw_signer,
<T as pallet_members::Config>::MinStake::get(),
)?;
Expand All @@ -191,15 +191,15 @@ benchmarks! {
let mut i = 0u8;
while u16::from(i) < <T as Config>::Elections::default_shard_size() {
let member = [i; 32];
let member_account: AccountId = member.clone().into();
let member_account: AccountId = member.into();
pallet_balances::Pallet::<T>::resolve_creating(
&member_account,
pallet_balances::Pallet::<T>::issue(<T as pallet_members::Config>::MinStake::get() * 100),
);
pallet_members::Pallet::<T>::register_member(
RawOrigin::Signed(member_account).into(),
ETHEREUM,
public_key(member.clone()),
public_key(member),
member,
<T as pallet_members::Config>::MinStake::get(),
)?;
Expand All @@ -213,7 +213,7 @@ benchmarks! {
ShardState::<T>::insert(0, ShardStatus::Online);
Pallet::<T>::shard_online(0, ETHEREUM);
let raw_caller = [0u8; 32];
let caller: AccountId = raw_caller.clone().into();
let caller: AccountId = raw_caller.into();
Pallet::<T>::create_task(RawOrigin::Signed(caller.clone()).into(), descriptor)?;
Pallet::<T>::register_gateway(RawOrigin::Root.into(), 0, [0u8; 20], 0)?;
let (pub_key, signature) = mock_submit_sig();
Expand Down Expand Up @@ -276,7 +276,7 @@ benchmarks! {
Pallet::<T>::shard_online(j, ETHEREUM);
Pallet::<T>::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 {}
Expand Down

0 comments on commit 3de8687

Please sign in to comment.