diff --git a/.github/workflows/run_test_suite.yaml b/.github/workflows/run_test_suite.yaml index f6311545e..77793c7aa 100644 --- a/.github/workflows/run_test_suite.yaml +++ b/.github/workflows/run_test_suite.yaml @@ -61,31 +61,43 @@ jobs: run-linting-linux: runs-on: ubuntu-latest + strategy: + matrix: + include: + - toolchain: stable + - toolchain: nightly steps: - uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - name: 'Setup Rust' run: | curl -sSf https://sh.rustup.rs | sh -s -- -y - rustup component add clippy - rustup component add rustfmt + rustup toolchain install ${{matrix.toolchain}} + rustup +${{matrix.toolchain}} component add clippy + rustup +${{matrix.toolchain}} component add rustfmt - name: 'Install environment packages' run: | sudo apt-get update -qqy sudo apt-get install jq protobuf-compiler cmake - name: 'Check Format' - run: cargo fmt --all -- --check + run: cargo +${{matrix.toolchain}} fmt --all -- --check - name: 'Run Linter' - run: cargo clippy --all -- -D warnings + run: cargo +${{matrix.toolchain}} clippy --all -- -D warnings run-test-suite-linux: runs-on: ubuntu-latest + strategy: + matrix: + include: + - toolchain: stable + - toolchain: nightly steps: - uses: actions/checkout@v3 - uses: Swatinem/rust-cache@v2 - name: 'Setup Rust' run: | curl -sSf https://sh.rustup.rs | sh -s -- -y + rustup toolchain install ${{matrix.toolchain}} - name: 'Install environment packages' run: | sudo apt-get update -qqy @@ -96,7 +108,7 @@ jobs: ipfs_version: v0.17.0 run_daemon: true - name: 'Run Rust native target tests' - run: NOOSPHERE_LOG=deafening cargo test --features test-kubo,headers + run: NOOSPHERE_LOG=deafening cargo +${{matrix.toolchain}} test --features test-kubo,headers run-test-suite-linux-rocksdb: runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index d2cc1e7db..ccfd95694 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3411,6 +3411,7 @@ dependencies = [ "rand", "reqwest", "rexie", + "rustc_version", "safer-ffi", "serde_json", "subtext", @@ -4779,8 +4780,7 @@ checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" [[package]] name = "safer-ffi" version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9c1d19b288ca9898cd421c7b105fb7269918a7f8e9253a991e228981ca421ad" +source = "git+https://github.com/jsantell/safer_ffi?branch=fix-190#3b829b4f6998c7a394989e8bf06c61378c737e4d" dependencies = [ "inventory", "libc", @@ -4796,8 +4796,7 @@ dependencies = [ [[package]] name = "safer_ffi-proc_macros" version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2d7a04caa3ca2224f5ea4ddd850e2629c3b36b2b83621f87a8303bf41020110" +source = "git+https://github.com/jsantell/safer_ffi?branch=fix-190#3b829b4f6998c7a394989e8bf06c61378c737e4d" dependencies = [ "macro_rules_attribute", "prettyplease 0.1.25", diff --git a/rust/noosphere-gateway/src/handlers/v0alpha2/push.rs b/rust/noosphere-gateway/src/handlers/v0alpha2/push.rs index 06fdc442d..769e3c068 100644 --- a/rust/noosphere-gateway/src/handlers/v0alpha2/push.rs +++ b/rust/noosphere-gateway/src/handlers/v0alpha2/push.rs @@ -50,7 +50,7 @@ pub async fn push_route( stream: BodyStream, ) -> Result>>, GatewayErrorResponse> where - C: HasMutableSphereContext, + for<'a> C: HasMutableSphereContext + 'a, S: Storage + 'static, { debug!("Invoking push route..."); diff --git a/rust/noosphere/Cargo.toml b/rust/noosphere/Cargo.toml index 525e4269d..d3e5a3184 100644 --- a/rust/noosphere/Cargo.toml +++ b/rust/noosphere/Cargo.toml @@ -73,7 +73,7 @@ features = [ ] [target.'cfg(not(target_arch = "wasm32"))'.dependencies] -safer-ffi = { version = "0.1.2", features = ["proc_macros", "python-headers"] } +safer-ffi = { git = "https://github.com/jsantell/safer_ffi", branch = "fix-190", features = ["proc_macros", "python-headers"] } tokio = { workspace = true, features = ["full"] } [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] @@ -92,3 +92,4 @@ gloo-timers = { workspace = true } [build-dependencies] cfg_aliases = "0.1.0" +rustc_version = "0.4.0" diff --git a/rust/noosphere/build.rs b/rust/noosphere/build.rs index 3747db77c..9adf91ff0 100644 --- a/rust/noosphere/build.rs +++ b/rust/noosphere/build.rs @@ -1,6 +1,26 @@ use cfg_aliases::cfg_aliases; +use rustc_version::{version_meta, Channel}; fn main() { + println!("cargo:rerun-if-changed=build.rs"); + println!("cargo:rerun-if-env-changed=RUSTC"); + + // Enables `#[cfg(channel = "nightly")]` configuration. + match version_meta().unwrap().channel { + Channel::Stable => { + println!("cargo:rustc-cfg=channel=\"stable\""); + } + Channel::Beta => { + println!("cargo:rustc-cfg=channel=\"beta\""); + } + Channel::Nightly => { + println!("cargo:rustc-cfg=channel=\"nightly\""); + } + Channel::Dev => { + println!("cargo:rustc-cfg=channel=\"dev\""); + } + } + cfg_aliases! { // Platforms wasm: { target_arch = "wasm32" }, diff --git a/rust/noosphere/src/ffi/mod.rs b/rust/noosphere/src/ffi/mod.rs index 4d7c26378..2da4bfc25 100644 --- a/rust/noosphere/src/ffi/mod.rs +++ b/rust/noosphere/src/ffi/mod.rs @@ -1,5 +1,13 @@ // TODO(getditto/safer_ffi#181): Re-enable this lint -#![allow(clippy::incorrect_clone_impl_on_copy_type, non_snake_case)] +// Note different linting rules in nightly. +#![cfg_attr( + not(channel = "nightly"), + allow(clippy::incorrect_clone_impl_on_copy_type, non_snake_case) +)] +#![cfg_attr( + channel = "nightly", + allow(clippy::non_canonical_clone_impl, non_snake_case) +)] //! This module defins a C FFI for Noosphere, suitable for cross-language //! embedding on many different targets