mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-18 05:30:33 -04:00
Merge pull request #527 from matrix-org/jplatte/wasm-ci
This commit is contained in:
119
.github/workflows/wasm.yml
vendored
119
.github/workflows/wasm.yml
vendored
@@ -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
|
||||
@@ -56,11 +44,13 @@ jobs:
|
||||
with:
|
||||
toolchain: stable
|
||||
target: wasm32-unknown-unknown
|
||||
components: clippy
|
||||
profile: minimal
|
||||
override: true
|
||||
|
||||
- name: Load cache
|
||||
uses: Swatinem/rust-cache@v1
|
||||
|
||||
# needed for libolm-sys compilation
|
||||
- name: Install emscripten
|
||||
uses: mymindstorm/setup-emsdk@v11
|
||||
@@ -70,100 +60,5 @@ jobs:
|
||||
- name: check
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: check
|
||||
args: --target wasm32-unknown-unknown ${{ matrix.cargo_args }}
|
||||
|
||||
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
|
||||
experimental: false
|
||||
- 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 }}
|
||||
command: run
|
||||
args: -p xtask -- ci wasm ${{ matrix.cmd || matrix.name }}
|
||||
|
||||
@@ -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<BackupKeys, CryptoStoreError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
@@ -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")?;
|
||||
|
||||
|
||||
@@ -1103,7 +1103,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,
|
||||
|
||||
@@ -137,7 +137,7 @@ mod store_helpers {
|
||||
) -> Result<Box<StateStore>> {
|
||||
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?,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,13 @@ enum CiCommand {
|
||||
#[clap(subcommand)]
|
||||
cmd: Option<FeatureSet>,
|
||||
},
|
||||
/// Run tests for the appservice crate
|
||||
TestAppservice,
|
||||
/// Run checks for the wasm target
|
||||
Wasm {
|
||||
#[clap(subcommand)]
|
||||
cmd: Option<WasmFeatureSet>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Subcommand, PartialEq, Eq, PartialOrd, Ord)]
|
||||
@@ -45,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()?)?;
|
||||
@@ -58,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()?;
|
||||
@@ -67,6 +85,7 @@ impl CiArgs {
|
||||
run_tests()?;
|
||||
run_feature_tests(None)?;
|
||||
run_appservice_tests()?;
|
||||
run_wasm_checks(None)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -147,6 +166,45 @@ fn run_appservice_tests() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_wasm_checks(cmd: Option<WasmFeatureSet>) -> 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 clippy --target wasm32-unknown-unknown")
|
||||
.args(arg_set.split_whitespace())
|
||||
.args(["--", "-D", "warnings"])
|
||||
.run()
|
||||
};
|
||||
|
||||
match cmd {
|
||||
Some(cmd) => {
|
||||
run(args[&cmd])?;
|
||||
}
|
||||
None => {
|
||||
for &arg_set in args.values() {
|
||||
run(arg_set)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn workspace_root() -> Result<PathBuf> {
|
||||
#[derive(Deserialize)]
|
||||
struct Metadata {
|
||||
|
||||
Reference in New Issue
Block a user