Skip to content

Commit

Permalink
Add feature sets CI (#1254)
Browse files Browse the repository at this point in the history
* Add a few common feature sets

* Add another

* add new workflow

* add libudev

* better message

* fix gating

* fix wasm

* Revert breaking feature changes

* missed reverts

* Nit

---------

Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
DaughterOfMars and thibault-martinez authored Sep 22, 2023
1 parent 121a22c commit 3347676
Show file tree
Hide file tree
Showing 18 changed files with 260 additions and 170 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/bindings-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Nodejs bindings checks

on:
push:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".github/actions/**"
- "**.rs" # Include all rust files
Expand All @@ -15,7 +15,7 @@ on:
- "bindings/nodejs/**"
- ".github/workflows/bindings-nodejs.yml"
pull_request:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".github/actions/**"
- "**.rs" # Include all rust files
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/bindings-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Python bindings checks

on:
push:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".github/actions/**"
- "**.rs" # Include all rust files
Expand All @@ -15,7 +15,7 @@ on:
- "bindings/python/**"
- ".github/workflows/bindings-python.yml"
pull_request:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".github/actions/**"
- "**.rs" # Include all rust files
Expand Down Expand Up @@ -120,4 +120,3 @@ jobs:
- name: Run tests
working-directory: bindings/python
run: tox

4 changes: 2 additions & 2 deletions .github/workflows/bindings-wallet-nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Nodejs bindings checks (wallet)

on:
push:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".github/actions/**"
- "**.rs" # Include all rust files
Expand All @@ -16,7 +16,7 @@ on:
- ".github/workflows/bindings-wallet-nodejs.yml"
- ".patches/*"
pull_request:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".github/actions/**"
- "**.rs" # Include all rust files
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/bindings-wasm.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Wasm bindings checks
on:
push:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".github/actions/**"
- "**.rs" # Include all rust files
Expand All @@ -15,7 +15,7 @@ on:
- "bindings/nodejs/**"
- ".github/workflows/bindings-wasm.yml"
pull_request:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".github/actions/**"
- "**.rs" # Include all rust files
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Run Tests

on:
push:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".cargo/config.toml"
- ".github/workflows/build-and-test.yml"
Expand All @@ -12,7 +12,7 @@ on:
- "**Cargo.lock" # Include all Cargo.lock files
- "!**/bindings/**" # Exclude all bindings
pull_request:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".cargo/config.toml"
- ".github/workflows/build-and-test.yml"
Expand Down
66 changes: 66 additions & 0 deletions .github/workflows/common-features.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Common Feature Sets
on:
push:
branches: [develop, production, "1.1"]
paths:
- ".cargo/config.toml"
- ".github/workflows/common-features.yml"
- ".github/actions/**"
- "**.rs" # Include all rust files
- "**Cargo.toml" # Include all Cargo.toml files
- "**Cargo.lock" # Include all Cargo.lock files
- "!**/bindings/**" # Exclude all bindings
pull_request:
branches: [develop, production, "1.1"]
paths:
- ".cargo/config.toml"
- ".github/workflows/common-features.yml"
- ".github/actions/**"
- "**.rs" # Include all rust files
- "**Cargo.toml" # Include all Cargo.toml files
- "**Cargo.lock" # Include all Cargo.lock files
- "!**/bindings/**" # Exclude all bindings

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_INCREMENTAL: 0

jobs:
common-sets:
name: Check common feature sets
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
set:
- pow
- irc_27
- irc_30
- client,private_key_secret_manager
- client,mqtt
- client,participation
- wallet,storage
- wallet,stronghold
- wallet,rocksdb
- wallet,participation
- wallet,events
- wallet,events,ledger_nano

steps:
- name: Checkout the Source Code
uses: actions/checkout@v3

- name: Set up Rust
uses: ./.github/actions/setup-rust

# Required for ledger-nano
- name: Install required packages (Ubuntu)
run: |
sudo apt-get update
sudo apt-get install libudev-dev libusb-1.0-0-dev
- name: Check features [ ${{ matrix.set }} ]
run: cargo check --no-default-features -p iota-sdk -F ${{ matrix.set }}
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Test coverage

on:
push:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".cargo/config.toml"
- ".github/workflows/coverage.yml"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Linting
on:
push:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".cargo/config.toml"
- ".github/workflows/lint.yml"
Expand All @@ -11,7 +11,7 @@ on:
- "**Cargo.lock" # Include all Cargo.lock files
- "!**/bindings/**" # Exclude all bindings
pull_request:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".cargo/config.toml"
- ".github/workflows/lint.yml"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/private-tangle-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and run specific tests on a private tangle

on:
push:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".cargo/config.toml"
- ".github/workflows/private-tangle-tests.yml"
Expand All @@ -14,7 +14,7 @@ on:
- "**Cargo.lock"
- "!cli/**" # Exclude CLI
pull_request:
branches: [develop, production, 1.1]
branches: [develop, production, "1.1"]
paths:
- ".cargo/config.toml"
- ".github/workflows/private-tangle-tests.yml"
Expand Down
4 changes: 2 additions & 2 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ events = []
irc_27 = ["url", "serde"]
irc_30 = ["url", "serde"]
ledger_nano = ["iota-ledger-nano"]
mqtt = ["std", "regex", "rumqttc", "dep:once_cell"]
mqtt = ["std", "tls", "regex", "rumqttc", "dep:once_cell"]
participation = ["storage"]
pow = ["std", "num_cpus", "iota-crypto/curl-p"]
rand = ["dep:rand"]
rocksdb = ["dep:rocksdb", "storage"]
rocksdb = ["storage", "dep:rocksdb"]
serde = [
"serde_repr",
"hashbrown/serde",
Expand Down
6 changes: 6 additions & 0 deletions sdk/src/client/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,10 @@ impl ClientInner {
};
Ok(())
}

/// Resize the client's request pool
#[cfg(not(target_family = "wasm"))]
pub async fn resize_request_pool(&self, new_size: usize) {
self.request_pool.resize(new_size).await;
}
}
4 changes: 2 additions & 2 deletions sdk/src/wallet/core/operations/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#[cfg(feature = "storage")]
mod storage_stub {

use async_trait::async_trait;

use crate::{
Expand All @@ -13,7 +12,8 @@ mod storage_stub {
},
wallet::{
core::builder::dto::WalletBuilderDto,
storage::constants::{CHRYSALIS_STORAGE_KEY, SECRET_MANAGER_KEY, WALLET_INDEXATION_KEY},
migration::chrysalis::CHRYSALIS_STORAGE_KEY,
storage::constants::{SECRET_MANAGER_KEY, WALLET_INDEXATION_KEY},
Wallet, WalletBuilder,
},
};
Expand Down
18 changes: 13 additions & 5 deletions sdk/src/wallet/core/operations/stronghold_backup/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ use futures::{future::try_join_all, FutureExt};

use self::stronghold_snapshot::read_data_from_stronghold_snapshot;
#[cfg(feature = "storage")]
use crate::wallet::WalletBuilder;
use crate::{
client::storage::StorageAdapter,
wallet::{migration::chrysalis::CHRYSALIS_STORAGE_KEY, WalletBuilder},
};
use crate::{
client::{
secret::{stronghold::StrongholdSecretManager, SecretManager, SecretManagerConfig, SecretManagerDto},
storage::StorageAdapter,
utils::Password,
},
types::block::address::Hrp,
wallet::{storage::constants::CHRYSALIS_STORAGE_KEY, Account, Wallet},
wallet::{Account, Wallet},
};

impl Wallet {
Expand Down Expand Up @@ -103,7 +105,10 @@ impl Wallet {
.password(stronghold_password.clone())
.build(backup_path.clone())?;

let (read_client_options, read_coin_type, read_secret_manager, read_accounts, chrysalis_data) =
#[cfg_attr(not(feature = "storage"), allow(unused))]
let chrysalis_data = stronghold_snapshot::migrate_snapshot_from_chrysalis_to_stardust(&new_stronghold).await?;

let (read_client_options, read_coin_type, read_secret_manager, read_accounts) =
read_data_from_stronghold_snapshot::<SecretManager>(&new_stronghold).await?;

// If the coin type is not matching the current one, then the addresses in the accounts will also not be
Expand Down Expand Up @@ -280,7 +285,10 @@ impl Wallet<StrongholdSecretManager> {
.password(stronghold_password.clone())
.build(backup_path.clone())?;

let (read_client_options, read_coin_type, read_secret_manager, read_accounts, chrysalis_data) =
#[cfg_attr(not(feature = "storage"), allow(unused))]
let chrysalis_data = stronghold_snapshot::migrate_snapshot_from_chrysalis_to_stardust(&new_stronghold).await?;

let (read_client_options, read_coin_type, read_secret_manager, read_accounts) =
read_data_from_stronghold_snapshot::<StrongholdSecretManager>(&new_stronghold).await?;

// If the coin type is not matching the current one, then the addresses in the accounts will also not be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use crate::{
wallet::{
account::{AccountDetails, AccountDetailsDto},
migration::{
chrysalis::{migrate_from_chrysalis_data, to_chrysalis_key},
chrysalis::{migrate_from_chrysalis_data, to_chrysalis_key, CHRYSALIS_STORAGE_KEY},
latest_backup_migration_version, migrate, MigrationData, MIGRATION_VERSION_KEY,
},
storage::constants::{CHRYSALIS_STORAGE_KEY, WALLET_INDEXATION_KEY},
ClientOptions, Error as WalletError, Wallet,
},
};

pub(crate) const WALLET_INDEXATION_KEY: &str = "iota-wallet-account-manager";
pub(crate) const CLIENT_OPTIONS_KEY: &str = "client_options";
pub(crate) const COIN_TYPE_KEY: &str = "coin_type";
pub(crate) const SECRET_MANAGER_KEY: &str = "secret_manager";
Expand Down Expand Up @@ -62,10 +62,7 @@ pub(crate) async fn read_data_from_stronghold_snapshot<S: 'static + SecretManage
Option<u32>,
Option<S::Config>,
Option<Vec<AccountDetails>>,
Option<HashMap<String, String>>,
)> {
let chrysalis_data = migrate_snapshot_from_chrysalis_to_stardust(stronghold).await?;

migrate(stronghold).await?;

// Get client_options
Expand All @@ -77,7 +74,7 @@ pub(crate) async fn read_data_from_stronghold_snapshot<S: 'static + SecretManage
let coin_type = u32::from_le_bytes(
coin_type_bytes
.try_into()
.map_err(|_| crate::wallet::Error::Backup("invalid coin_type"))?,
.map_err(|_| WalletError::Backup("invalid coin_type"))?,
);
log::debug!("[restore_backup] restored coin_type: {coin_type}");
Some(coin_type)
Expand All @@ -99,19 +96,14 @@ pub(crate) async fn read_data_from_stronghold_snapshot<S: 'static + SecretManage
})
.transpose()?;

Ok((
client_options,
coin_type,
restored_secret_manager,
restored_accounts,
chrysalis_data,
))
Ok((client_options, coin_type, restored_secret_manager, restored_accounts))
}

async fn migrate_snapshot_from_chrysalis_to_stardust(
pub(crate) async fn migrate_snapshot_from_chrysalis_to_stardust(
stronghold_adapter: &StrongholdAdapter,
) -> crate::wallet::Result<Option<HashMap<String, String>>> {
log::debug!("migrate_snapshot_from_chrysalis_to_stardust");

let stronghold = stronghold_adapter.inner().await;
let stronghold_client = match stronghold.load_client(b"iota-wallet-records") {
Ok(client) => client,
Expand Down
Loading

0 comments on commit 3347676

Please sign in to comment.