From 0721c7ddb2d12b2ad27877077f73fd7e9d900161 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 10 Mar 2022 10:30:56 +0100 Subject: [PATCH 1/5] Add missing ci subcommand description --- xtask/src/ci.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/xtask/src/ci.rs b/xtask/src/ci.rs index 4e8f9ef3e..564059d9c 100644 --- a/xtask/src/ci.rs +++ b/xtask/src/ci.rs @@ -29,6 +29,7 @@ enum CiCommand { #[clap(subcommand)] cmd: Option, }, + /// Run tests for the appservice crate TestAppservice, } From c01475701d63203e38402e702929c138bb34555b Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 10 Mar 2022 11:02:16 +0100 Subject: [PATCH 2/5] Move some wasm CI logic into xtask --- .github/workflows/wasm.yml | 23 ++++------------ xtask/src/ci.rs | 56 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 17 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 12cd83554..b0b056e5e 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -16,7 +16,7 @@ env: jobs: check-wasm: - name: Build test + name: Build test / ${{ matrix.name }} runs-on: ubuntu-latest if: github.event_name == 'push' || !github.event.pull_request.draft @@ -25,27 +25,15 @@ jobs: matrix: name: - matrix-qrcode - - matrix-sdk (no-default, wasm-flags) - matrix-sdk-base - matrix-sdk-common - matrix-sdk-crypto - - matrix-sdk / indexeddb_stores include: - - name: matrix-qrcode - cargo_args: --package matrix-qrcode - name: matrix-sdk (no-default, wasm-flags) - cargo_args: --no-default-features --features qrcode,encryption,indexeddb_stores,rustls-tls --package matrix-sdk --lib - - name: matrix-sdk-base - cargo_args: --package matrix-sdk-base - - name: matrix-sdk-common - cargo_args: --package matrix-sdk-common - - name: matrix-sdk-crypto - cargo_args: --package matrix-sdk-crypto - - # special check for specific features + cmd: matrix-sdk-no-default - name: matrix-sdk / indexeddb_stores - cargo_args: --package matrix-sdk --no-default-features --features indexeddb_stores,encryption,rustls-tls --lib + cmd: matrix-sdk-indexeddb-stores steps: - name: Checkout the repo @@ -61,6 +49,7 @@ jobs: - name: Load cache uses: Swatinem/rust-cache@v1 + # needed for libolm-sys compilation - name: Install emscripten uses: mymindstorm/setup-emsdk@v11 @@ -70,8 +59,8 @@ jobs: - name: check uses: actions-rs/cargo@v1 with: - command: check - args: --target wasm32-unknown-unknown ${{ matrix.cargo_args }} + command: run + args: -p xtask -- ci wasm ${{ matrix.cmd || matrix.name }} test-wasm: # building wasm is not enough, we've seen runtime errors before, diff --git a/xtask/src/ci.rs b/xtask/src/ci.rs index 564059d9c..3d4478f4c 100644 --- a/xtask/src/ci.rs +++ b/xtask/src/ci.rs @@ -31,6 +31,11 @@ enum CiCommand { }, /// Run tests for the appservice crate TestAppservice, + /// Run checks for the wasm target + Wasm { + #[clap(subcommand)] + cmd: Option, + }, } #[derive(Subcommand, PartialEq, Eq, PartialOrd, Ord)] @@ -46,6 +51,17 @@ enum FeatureSet { SsoLogin, } +#[derive(Subcommand, PartialEq, Eq, PartialOrd, Ord)] +#[allow(clippy::enum_variant_names)] +enum WasmFeatureSet { + MatrixQrcode, + MatrixSdkNoDefault, + MatrixSdkBase, + MatrixSdkCommon, + MatrixSdkCrypto, + MatrixSdkIndexeddbStores, +} + impl CiArgs { pub fn run(self) -> Result<()> { let _p = pushd(&workspace_root()?)?; @@ -59,6 +75,7 @@ impl CiArgs { CiCommand::Test => run_tests(), CiCommand::TestFeatures { cmd } => run_feature_tests(cmd), CiCommand::TestAppservice => run_appservice_tests(), + CiCommand::Wasm { cmd } => run_wasm_checks(cmd), }, None => { check_style()?; @@ -68,6 +85,7 @@ impl CiArgs { run_tests()?; run_feature_tests(None)?; run_appservice_tests()?; + run_wasm_checks(None)?; Ok(()) } @@ -148,6 +166,44 @@ fn run_appservice_tests() -> Result<()> { Ok(()) } +fn run_wasm_checks(cmd: Option) -> Result<()> { + let args = BTreeMap::from([ + (WasmFeatureSet::MatrixQrcode, "-p matrix-qrcode"), + ( + WasmFeatureSet::MatrixSdkNoDefault, + "-p matrix-sdk \ + --no-default-features \ + --features qrcode,encryption,indexeddb_stores,rustls-tls", + ), + (WasmFeatureSet::MatrixSdkBase, "-p matrix-sdk-base"), + (WasmFeatureSet::MatrixSdkCommon, "-p matrix-sdk-common"), + (WasmFeatureSet::MatrixSdkCrypto, "-p matrix-sdk-crypto"), + ( + WasmFeatureSet::MatrixSdkIndexeddbStores, + "-p matrix-sdk --no-default-features --features indexeddb_stores,encryption,rustls-tls", + ), + ]); + + let run = |arg_set: &str| { + cmd!("rustup run stable cargo check --target wasm32-unknown-unknown") + .args(arg_set.split_whitespace()) + .run() + }; + + match cmd { + Some(cmd) => { + run(args[&cmd])?; + } + None => { + for &arg_set in args.values() { + run(arg_set)?; + } + } + } + + Ok(()) +} + fn workspace_root() -> Result { #[derive(Deserialize)] struct Metadata { From ea2c9a29868a2df0b13806ced368ff41705ca4c2 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 10 Mar 2022 11:28:55 +0100 Subject: [PATCH 3/5] ci: Use clippy instead of check for wasm checks --- .github/workflows/wasm.yml | 1 + crates/matrix-sdk-indexeddb/src/cryptostore.rs | 3 ++- crates/matrix-sdk-indexeddb/src/state_store.rs | 2 +- crates/matrix-sdk/src/client.rs | 2 +- crates/matrix-sdk/src/config/client.rs | 2 +- xtask/src/ci.rs | 3 ++- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index b0b056e5e..e341eacff 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -44,6 +44,7 @@ jobs: with: toolchain: stable target: wasm32-unknown-unknown + components: clippy profile: minimal override: true diff --git a/crates/matrix-sdk-indexeddb/src/cryptostore.rs b/crates/matrix-sdk-indexeddb/src/cryptostore.rs index 9320047fe..85e4050b3 100644 --- a/crates/matrix-sdk-indexeddb/src/cryptostore.rs +++ b/crates/matrix-sdk-indexeddb/src/cryptostore.rs @@ -204,7 +204,7 @@ impl IndexeddbStore { let db: IdbDatabase = db_req.into_future().await?; - let tx: IdbTransaction = + let tx: IdbTransaction<'_> = db.transaction_on_one_with_mode("matrix-sdk-crypto", IdbTransactionMode::Readwrite)?; let ob = tx.object_store("matrix-sdk-crypto")?; @@ -918,6 +918,7 @@ impl CryptoStore for IndexeddbStore { self.users_for_key_query() } + #[allow(clippy::todo)] async fn load_backup_keys(&self) -> Result { todo!() } diff --git a/crates/matrix-sdk-indexeddb/src/state_store.rs b/crates/matrix-sdk-indexeddb/src/state_store.rs index 0184054de..9af422d95 100644 --- a/crates/matrix-sdk-indexeddb/src/state_store.rs +++ b/crates/matrix-sdk-indexeddb/src/state_store.rs @@ -217,7 +217,7 @@ impl IndexeddbStore { let db: IdbDatabase = db_req.into_future().await?; - let tx: IdbTransaction = + let tx: IdbTransaction<'_> = db.transaction_on_one_with_mode("matrix-sdk-state", IdbTransactionMode::Readwrite)?; let ob = tx.object_store("matrix-sdk-state")?; diff --git a/crates/matrix-sdk/src/client.rs b/crates/matrix-sdk/src/client.rs index 16ab9011d..496c24319 100644 --- a/crates/matrix-sdk/src/client.rs +++ b/crates/matrix-sdk/src/client.rs @@ -1104,7 +1104,7 @@ impl Client { /// [`get_sso_login_url`]: #method.get_sso_login_url /// [`restore_login`]: #method.restore_login #[instrument(skip(token))] - #[deny(clippy::future_not_send)] + #[cfg_attr(not(target_arch = "wasm32"), deny(clippy::future_not_send))] pub async fn login_with_token( &self, token: &str, diff --git a/crates/matrix-sdk/src/config/client.rs b/crates/matrix-sdk/src/config/client.rs index 752f3e881..8639c7953 100644 --- a/crates/matrix-sdk/src/config/client.rs +++ b/crates/matrix-sdk/src/config/client.rs @@ -137,7 +137,7 @@ mod store_helpers { ) -> Result> { Ok(Box::new(match passphrase { Some(pass) => StateStore::open_with_passphrase(name.to_owned(), pass).await?, - _ => StateStore::open_with_name(name.to_string()).await?, + _ => StateStore::open_with_name(name.to_owned()).await?, })) } } diff --git a/xtask/src/ci.rs b/xtask/src/ci.rs index 3d4478f4c..ce04b8c2c 100644 --- a/xtask/src/ci.rs +++ b/xtask/src/ci.rs @@ -185,8 +185,9 @@ fn run_wasm_checks(cmd: Option) -> Result<()> { ]); let run = |arg_set: &str| { - cmd!("rustup run stable cargo check --target wasm32-unknown-unknown") + cmd!("rustup run stable cargo clippy --target wasm32-unknown-unknown") .args(arg_set.split_whitespace()) + .args(["--", "-D", "warnings"]) .run() }; From 9154e93089f344fe66e1378029d2832111da67da Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 10 Mar 2022 11:41:01 +0100 Subject: [PATCH 4/5] Allow other tests to continue when indexeddb test fails --- .github/workflows/wasm.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index e341eacff..821f375c0 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -86,7 +86,8 @@ jobs: cargo_args: --no-default-features --features indexeddb_stores,rustls-tls,encryption --lib - name: "matrix-sdk-indexeddb" base_dir: matrix-sdk-indexeddb - experimental: false + # always failing since recently, reasons not known yet + experimental: true - name: "matrix-sdk-example-wasm_command_bot @Node14" experimental: false emcc_version: 2.0.27 From 30b3bd1c3d3bd910faf0e1fae091e5a124b6cde8 Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 10 Mar 2022 13:18:59 +0100 Subject: [PATCH 5/5] Delete complicated and partially broken wasm tests --- .github/workflows/wasm.yml | 96 -------------------------------------- 1 file changed, 96 deletions(-) diff --git a/.github/workflows/wasm.yml b/.github/workflows/wasm.yml index 821f375c0..e86aeddb6 100644 --- a/.github/workflows/wasm.yml +++ b/.github/workflows/wasm.yml @@ -62,99 +62,3 @@ jobs: with: command: run args: -p xtask -- ci wasm ${{ matrix.cmd || matrix.name }} - - test-wasm: - # building wasm is not enough, we've seen runtime errors before, - # hence the tests - name: ${{ matrix.name }} test - if: github.event_name == 'push' || !github.event.pull_request.draft - runs-on: ubuntu-latest - continue-on-error: ${{ matrix.experimental }} - - strategy: - matrix: - include: - - name: matrix-sdk - experimental: false - base_dir: matrix-sdk - cargo_args: --no-default-features --features indexeddb_stores,rustls-tls --lib - - name: matrix-sdk-encryption - experimental: false - emcc_version: 2.0.27 - node_version: '14' - base_dir: matrix-sdk - cargo_args: --no-default-features --features indexeddb_stores,rustls-tls,encryption --lib - - name: "matrix-sdk-indexeddb" - base_dir: matrix-sdk-indexeddb - # always failing since recently, reasons not known yet - experimental: true - - name: "matrix-sdk-example-wasm_command_bot @Node14" - experimental: false - emcc_version: 2.0.27 - node_version: '14' - # known to work - base_dir: matrix-sdk/examples/wasm_command_bot - cmd: | - npm install - npm test - wasm-pack test --firefox --headless - - name: matrix-sdk-example-wasm_command_bot - base_dir: matrix-sdk/examples/wasm_command_bot - # this might fail - experimental: true - cmd: | - npm install - npm test - wasm-pack test --firefox --headless - - steps: - - name: Checkout the repo - uses: actions/checkout@v2 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - target: wasm32-unknown-unknown - profile: minimal - override: true - - - name: Load cache - uses: Swatinem/rust-cache@v1 - - - name: Setup Node - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node_version || 'lts/*' }} - - - name: Install emscripten - uses: mymindstorm/setup-emsdk@v11 - with: - version: ${{ matrix.emcc_version || 'latest' }} - - - name: Install wasm-pack - run: cargo install wasm-pack - - - name: Verify versions - run: | - echo "> node --version" - node --version - echo "> npm --version" - npm --version - echo "> wasm-pack --version" - wasm-pack --version - echo "> emcc -v" - emcc -v - - - name: Default wasm-pack tests - if: '!matrix.cmd' - run: | - cd crates/${{ matrix.base_dir }} - wasm-pack test --node -- ${{ matrix.cargo_args }} - wasm-pack test --firefox --headless -- ${{ matrix.cargo_args }} - - - name: Testing with custom command - if: matrix.cmd - run: | - cd crates/${{ matrix.base_dir }} - ${{ matrix.cmd }}