ci: Better job parallelism, cancel pipeline on failure and extra clippy checks (#1409)

* ci: Change CI order for better parallelism

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* ci: Cancel ongoing jobs

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* TO REVERT: Check early termination due to clipp/check

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* ci/clippy: Extend clippy checks for lightclient and web feature flags

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* ci: Use cancel-action@3

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* lightclient: Derive Default

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* subxt/rpc: Resolve redundant closure

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* tests: Fix clippy

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* lightclient: Fix clippy warnings

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* ci: Extend clippy rules

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* lightclient: Remove redundant clone

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* ci: Use subxt instead of subxt-lightclient

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* ci: Add wasm clippy step

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* ci: Simplify the clippy step into a single run command

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* ci: Pin version for cancel-action

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

* ci: Fix pinned version

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>

---------

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2024-01-31 11:53:33 +02:00
committed by GitHub
parent 7762da8650
commit c1073bc8d1
6 changed files with 107 additions and 50 deletions
+98 -37
View File
@@ -46,10 +46,44 @@ jobs:
command: fmt
args: --all -- --check
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
machete:
name: "Check unused dependencies"
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Install cargo-machete
run: cargo install cargo-machete
- name: Check unused dependencies
uses: actions-rs/cargo@v1.0.3
with:
command: machete
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
clippy:
name: Cargo clippy
runs-on: ubuntu-latest
needs: fmt
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
@@ -68,16 +102,51 @@ jobs:
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Run clippy
run: |
cargo clippy --all-targets --features unstable-light-client -- -D warnings
cargo clippy -p subxt-lightclient --no-default-features --features web -- -D warnings
cargo clippy -p subxt --no-default-features --features web -- -D warnings
cargo clippy -p subxt --no-default-features --features web,unstable-light-client -- -D warnings
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
wasm_clippy:
name: Cargo clippy (WASM)
runs-on: ubuntu-latest
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Run clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- -D warnings
args: -p subxt --no-default-features --features web,unstable-light-client,jsonrpsee --target wasm32-unknown-unknown -- -D warnings
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
check:
name: Cargo check
runs-on: ubuntu-latest
needs: [fmt, clippy]
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
@@ -133,10 +202,13 @@ jobs:
- name: Cargo check parachain-example
run: cargo check --manifest-path examples/parachain-example/Cargo.toml
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
wasm_check:
name: Cargo check (WASM)
runs-on: ubuntu-latest
needs: [fmt, clippy]
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
@@ -157,39 +229,13 @@ jobs:
run: |
cargo check --manifest-path examples/wasm-example/Cargo.toml --target wasm32-unknown-unknown
machete:
name: "Check unused dependencies"
runs-on: ubuntu-latest
needs: [check, wasm_check]
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Use substrate-node binary
uses: ./.github/workflows/actions/use-substrate
- name: Install Rust stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Rust Cache
uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84 # v2.7.3
- name: Install cargo-machete
run: cargo install cargo-machete
- name: Check unused dependencies
uses: actions-rs/cargo@v1.0.3
with:
command: machete
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
docs:
name: Check documentation and run doc tests
runs-on: ubuntu-latest
needs: [check, wasm_check]
needs: [fmt, machete]
steps:
- name: Checkout sources
uses: actions/checkout@v4
@@ -216,10 +262,13 @@ jobs:
command: test
args: --doc
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
tests:
name: "Test (Native)"
runs-on: ubuntu-latest-16-cores
needs: [machete, docs]
needs: [clippy, wasm_clippy, check, wasm_check, docs]
timeout-minutes: 30
steps:
- name: Checkout sources
@@ -247,10 +296,13 @@ jobs:
command: nextest
args: run --workspace
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
unstable_backend_tests:
name: "Test (Unstable Backend)"
runs-on: ubuntu-latest-16-cores
needs: [machete, docs]
needs: [clippy, wasm_clippy, check, wasm_check, docs]
timeout-minutes: 30
steps:
- name: Checkout sources
@@ -278,10 +330,13 @@ jobs:
command: nextest
args: run --workspace --features unstable-backend-client
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
light_client_tests:
name: "Test (Light Client)"
runs-on: ubuntu-latest
needs: [machete, docs]
needs: [clippy, wasm_clippy, check, wasm_check, docs]
timeout-minutes: 15
steps:
- name: Checkout sources
@@ -306,10 +361,13 @@ jobs:
command: test
args: --release --package integration-tests --features unstable-light-client
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
wasm_tests:
name: Test (WASM)
runs-on: ubuntu-latest
needs: [machete, docs]
needs: [clippy, wasm_clippy, check, wasm_check, docs]
timeout-minutes: 30
env:
# Set timeout for wasm tests to be much bigger than the default 20 secs.
@@ -358,3 +416,6 @@ jobs:
wasm-pack test --headless --firefox
wasm-pack test --headless --chrome
working-directory: signer/wasm-tests
- if: "failure()"
uses: "andymckay/cancel-action@b9280e3f8986d7a8e91c7462efc0fa318010c8b1" # v0.3
+2 -2
View File
@@ -124,14 +124,14 @@ impl PlatformRef for SubxtPlatform {
port,
} => {
let addr = SocketAddr::from((ip, port));
format!("ws://{}", addr.to_string())
format!("ws://{}", addr)
}
Address::WebSocketIp {
ip: IpAddr::V6(ip),
port,
} => {
let addr = SocketAddr::from((ip, port));
format!("ws://{}", addr.to_string())
format!("ws://{}", addr)
}
// The API user of the `PlatformRef` trait is never supposed to open connections of
+1 -1
View File
@@ -111,7 +111,7 @@ impl WasmSocket {
let mut inner = inner.lock().expect("Mutex is poised; qed");
let bytes = js_sys::Uint8Array::new(&buffer).to_vec();
inner.data.extend(bytes.into_iter());
inner.data.extend(bytes);
if let Some(waker) = inner.waker.take() {
waker.wake();
+4 -7
View File
@@ -6,11 +6,13 @@ use super::{rpc::LightClientRpc, LightClient, LightClientError};
use crate::backend::rpc::RpcClient;
use crate::client::RawLightClient;
use crate::macros::{cfg_jsonrpsee_native, cfg_jsonrpsee_web};
use crate::utils::validate_url_is_secure;
use crate::{config::Config, error::Error, OnlineClient};
use std::num::NonZeroU32;
use subxt_lightclient::{smoldot, AddedChain};
#[cfg(feature = "jsonrpsee")]
use crate::utils::validate_url_is_secure;
/// Builder for [`LightClient`].
#[derive(Clone, Debug)]
pub struct LightClientBuilder<T: Config> {
@@ -186,16 +188,11 @@ impl<T: Config> LightClientBuilder<T> {
}
/// Raw builder for [`RawLightClient`].
#[derive(Default)]
pub struct RawLightClientBuilder {
chains: Vec<AddedChain>,
}
impl Default for RawLightClientBuilder {
fn default() -> Self {
Self { chains: Vec::new() }
}
}
impl RawLightClientBuilder {
/// Create a new [`RawLightClientBuilder`].
pub fn new() -> RawLightClientBuilder {
+1 -2
View File
@@ -56,8 +56,7 @@ impl LightClientRpc {
pub fn new(
config: smoldot::AddChainConfig<'_, (), impl Iterator<Item = smoldot::ChainId>>,
) -> Result<LightClientRpc, Error> {
let rpc = subxt_lightclient::LightClientRpc::new(config)
.map_err(|err| LightClientError::Rpc(err))?;
let rpc = subxt_lightclient::LightClientRpc::new(config).map_err(LightClientError::Rpc)?;
Ok(LightClientRpc(rpc))
}
@@ -258,5 +258,5 @@ async fn build_light_client<T: Config>(proc: &SubstrateNode) -> Result<LightClie
.bootnodes([bootnode.as_str()])
.build_from_url(ws_url.as_str())
.await
.map_err(|e| format!("Failed to construct light client {}", e.to_string()))
.map_err(|e| format!("Failed to construct light client {}", e))
}