From ac3416973911ec292431f33ee6a7fee17c9a59d9 Mon Sep 17 00:00:00 2001 From: TimeEngineer Date: Thu, 19 Jan 2023 19:12:37 +0100 Subject: [PATCH 1/8] Fix CI packaging --- oxidation/libparsec/crates/core/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/oxidation/libparsec/crates/core/Cargo.toml b/oxidation/libparsec/crates/core/Cargo.toml index 2a3cee9fece..26ee4ccd587 100644 --- a/oxidation/libparsec/crates/core/Cargo.toml +++ b/oxidation/libparsec/crates/core/Cargo.toml @@ -20,7 +20,7 @@ use-sodiumoxide = ["libparsec_crypto/use-sodiumoxide"] libparsec_client_types = { path = "../client_types", default-features = false } libparsec_crypto = { path = "../crypto", default-features = false } libparsec_platform_async = { path = "../platform_async" } -libparsec_platform_device_loader = { path = "../platform_device_loader" } +libparsec_platform_device_loader = { path = "../platform_device_loader", default-features = false } libparsec_protocol = { path = "../protocol", default-features = false } libparsec_types = { path = "../types", default-features = false } From e1e919966395a4d0eb6da981ac80c209145fc97b Mon Sep 17 00:00:00 2001 From: TimeEngineer Date: Thu, 19 Jan 2023 22:03:30 +0100 Subject: [PATCH 2/8] Fix web --- .../crates/platform_device_loader/src/web/local_device.rs | 2 +- .../crates/platform_device_loader/src/web/local_device_file.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/oxidation/libparsec/crates/platform_device_loader/src/web/local_device.rs b/oxidation/libparsec/crates/platform_device_loader/src/web/local_device.rs index b9b5e62004c..d0f74ad5eb6 100644 --- a/oxidation/libparsec/crates/platform_device_loader/src/web/local_device.rs +++ b/oxidation/libparsec/crates/platform_device_loader/src/web/local_device.rs @@ -15,7 +15,7 @@ pub fn load_device_with_password(slug: &str, password: &str) -> LocalDeviceResul DeviceFile::Password(x) => Some(x), _ => None, }) - .find(|x| x.slug.as_ref().map(|x| x.as_str()) == Some(slug)) + .find(|x| x.slug.as_str() == slug) .ok_or_else(|| LocalDeviceError::NotFound { slug: slug.into() })?; return load_device_with_password_core(password, &device_file); diff --git a/oxidation/libparsec/crates/platform_device_loader/src/web/local_device_file.rs b/oxidation/libparsec/crates/platform_device_loader/src/web/local_device_file.rs index 0e8437a77b8..899efd7083e 100644 --- a/oxidation/libparsec/crates/platform_device_loader/src/web/local_device_file.rs +++ b/oxidation/libparsec/crates/platform_device_loader/src/web/local_device_file.rs @@ -19,8 +19,7 @@ pub async fn list_available_devices(_config_dir: &Path) -> Vec device.device_id, device.human_handle, device.device_label, - // There are no legacy device - device.slug.unwrap(), + device.slug, ), DeviceFile::Recovery(device) => ( DeviceFileType::Recovery, From 0e3d12fef33b7f283c8191470c5b5498742c347e Mon Sep 17 00:00:00 2001 From: TimeEngineer Date: Fri, 20 Jan 2023 00:37:56 +0100 Subject: [PATCH 3/8] Add CARGO_FEATURES env & set for cibuildwheel --- build.py | 9 +++------ pyproject.toml | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/build.py b/build.py index 024de30a104..47d40db234e 100644 --- a/build.py +++ b/build.py @@ -64,14 +64,11 @@ def build(): # native module and discard the rest ! maturin_build_profile = "--profile=" + os.environ.get("CARGO_PROFILE", DEFAULT_CARGO_PROFILE) - features = ( - "--no-default-features --features use-sodiumoxide" - if maturin_build_profile == "--profile=release" - else "" - ) + maturin_build_features = os.environ.get("CARGO_FEATURES", "") + with tempfile.TemporaryDirectory() as distdir: run( - f"maturin build {maturin_build_profile} --interpreter {PYTHON_EXECUTABLE_PATH} --out {distdir} {features}" + f"maturin build {maturin_build_profile} {maturin_build_features} --interpreter {PYTHON_EXECUTABLE_PATH} --out {distdir}" ) outputs = list(pathlib.Path(distdir).iterdir()) diff --git a/pyproject.toml b/pyproject.toml index 4f70927c200..88cd706d595 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -166,6 +166,7 @@ test-command = "parsec --version && parsec core list_devices" # non-existent and hence $PATH don't know about it (and maturin will fail when calling cargo). # For this reason we force $PATH to contain Rust bin dir. PATH = "$PATH:$HOME/.cargo/bin" +CARGO_FEATURES = "--no-default-features --features use-sodiumoxide" [tool.maturin] features = ["extension-module"] From 397e19819024e9f4ab6f2fb84ede713d772fcd15 Mon Sep 17 00:00:00 2001 From: TimeEngineer Date: Fri, 20 Jan 2023 01:02:51 +0100 Subject: [PATCH 4/8] Add additional check in QA --- .github/workflows/ci.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34b47f4c847..adb32e79f93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -124,6 +124,13 @@ jobs: env: POETRY_LIBPARSEC_BUILD_STRATEGY: no_build + - name: Additional Check + run: | + set -ex + rustup target add wasm32-unknown-unknown + cargo check --no-default-features --features use-sodiumoxide + cargo check --target wasm32-unknown-unknown + # Clippy basically compile the project, hence it's faster to run it in # the test-rust-matrix job where compilation cache is reused ! - uses: ./.github/actions/use-pre-commit @@ -408,7 +415,6 @@ jobs: id: web-change if: >- steps.changes.outputs.client-web == 'true' - || steps.changes.outputs.client-common == 'true' || github.ref == 'refs/heads/master' run: echo "run=true" >> $GITHUB_OUTPUT shell: bash From b3ea66e8236a6cd3cb585f11351aac6b8e70a25f Mon Sep 17 00:00:00 2001 From: TimeEngineer Date: Fri, 20 Jan 2023 11:08:48 +0100 Subject: [PATCH 5/8] Move cargo check --- .github/workflows/ci.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index adb32e79f93..152cc67004c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -124,13 +124,6 @@ jobs: env: POETRY_LIBPARSEC_BUILD_STRATEGY: no_build - - name: Additional Check - run: | - set -ex - rustup target add wasm32-unknown-unknown - cargo check --no-default-features --features use-sodiumoxide - cargo check --target wasm32-unknown-unknown - # Clippy basically compile the project, hence it's faster to run it in # the test-rust-matrix job where compilation cache is reused ! - uses: ./.github/actions/use-pre-commit @@ -380,6 +373,14 @@ jobs: shell: bash run: echo OPENSSL_SRC_PERL=C:/Strawberry/perl/bin/perl >> $GITHUB_ENV + - name: Additional Check + if: startsWith(matrix.os, 'ubuntu') + run: | + set -ex + rustup target add wasm32-unknown-unknown + cargo check --no-default-features --features use-sodiumoxide + cargo check --target wasm32-unknown-unknown + - name: Test rust codebase if: steps.rust-changes.outputs.run == 'true' shell: bash From 7d10eb1b4d6c2e18b4dcabf6d50891abd18a2809 Mon Sep 17 00:00:00 2001 From: TimeEngineer Date: Fri, 20 Jan 2023 11:35:00 +0100 Subject: [PATCH 6/8] Rename CARGO_FEATURES to CARGO_EXTRA_ARGS --- build.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.py b/build.py index 47d40db234e..c529cc2f35a 100644 --- a/build.py +++ b/build.py @@ -64,7 +64,7 @@ def build(): # native module and discard the rest ! maturin_build_profile = "--profile=" + os.environ.get("CARGO_PROFILE", DEFAULT_CARGO_PROFILE) - maturin_build_features = os.environ.get("CARGO_FEATURES", "") + maturin_build_features = os.environ.get("CARGO_EXTRA_ARGS", "") with tempfile.TemporaryDirectory() as distdir: run( diff --git a/pyproject.toml b/pyproject.toml index 88cd706d595..aef90fa2ad8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -166,7 +166,7 @@ test-command = "parsec --version && parsec core list_devices" # non-existent and hence $PATH don't know about it (and maturin will fail when calling cargo). # For this reason we force $PATH to contain Rust bin dir. PATH = "$PATH:$HOME/.cargo/bin" -CARGO_FEATURES = "--no-default-features --features use-sodiumoxide" +CARGO_EXTRA_ARGS = "--no-default-features --features use-sodiumoxide" [tool.maturin] features = ["extension-module"] From b81f836e7a83806cb528b1542b091f1160a8bb73 Mon Sep 17 00:00:00 2001 From: TimeEngineer Date: Fri, 20 Jan 2023 11:41:48 +0100 Subject: [PATCH 7/8] Run web test if change instead of check --- .github/actions/paths-filter/filters.yml | 6 +++++- .github/workflows/ci.yml | 8 ++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/actions/paths-filter/filters.yml b/.github/actions/paths-filter/filters.yml index 4d922926f91..9c23d2c0ee3 100644 --- a/.github/actions/paths-filter/filters.yml +++ b/.github/actions/paths-filter/filters.yml @@ -9,6 +9,9 @@ rust: - Cargo.lock - rust-toolchain.toml +rust-platform-web: &rust-platform-web + - oxidation/libparsec/crates/platform_*/src/web/** + python: - *shared - parsec/** @@ -33,11 +36,12 @@ client-common: &client-common - oxidation/client/capacitor.config.ts - oxidation/client/babel.config.js - oxidation/client/tsconfig.json - - oxidation/bindings/common/** + - oxidation/bindings/generator/** client-web: - *shared - *client-common + - *rust-platform-web - oxidation/bindings/web/** - oxidation/client/tests/** - oxidation/client/jest.config.js diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 152cc67004c..c28c79f5a58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -373,13 +373,9 @@ jobs: shell: bash run: echo OPENSSL_SRC_PERL=C:/Strawberry/perl/bin/perl >> $GITHUB_ENV - - name: Additional Check + - name: Additional Check (for packaging) if: startsWith(matrix.os, 'ubuntu') - run: | - set -ex - rustup target add wasm32-unknown-unknown - cargo check --no-default-features --features use-sodiumoxide - cargo check --target wasm32-unknown-unknown + run: cargo check --no-default-features --features use-sodiumoxide - name: Test rust codebase if: steps.rust-changes.outputs.run == 'true' From 585c28664aaea03bdad6ae0404bb405ce5b2ad48 Mon Sep 17 00:00:00 2001 From: TimeEngineer Date: Fri, 20 Jan 2023 15:25:40 +0100 Subject: [PATCH 8/8] Fix changes --- .github/workflows/ci.yml | 2 +- build.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c28c79f5a58..8f65c29f0f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -375,7 +375,7 @@ jobs: - name: Additional Check (for packaging) if: startsWith(matrix.os, 'ubuntu') - run: cargo check --no-default-features --features use-sodiumoxide + run: cargo check --profile ci-rust --no-default-features --features use-sodiumoxide - name: Test rust codebase if: steps.rust-changes.outputs.run == 'true' diff --git a/build.py b/build.py index c529cc2f35a..3cc127c46a9 100644 --- a/build.py +++ b/build.py @@ -64,11 +64,11 @@ def build(): # native module and discard the rest ! maturin_build_profile = "--profile=" + os.environ.get("CARGO_PROFILE", DEFAULT_CARGO_PROFILE) - maturin_build_features = os.environ.get("CARGO_EXTRA_ARGS", "") + maturin_build_extra_args = os.environ.get("CARGO_EXTRA_ARGS", "") with tempfile.TemporaryDirectory() as distdir: run( - f"maturin build {maturin_build_profile} {maturin_build_features} --interpreter {PYTHON_EXECUTABLE_PATH} --out {distdir}" + f"maturin build {maturin_build_profile} {maturin_build_extra_args} --interpreter {PYTHON_EXECUTABLE_PATH} --out {distdir}" ) outputs = list(pathlib.Path(distdir).iterdir())