diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 65d5c5b5..f03fa03a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,6 +14,10 @@ on: merge_group: types: [checks_requested] +env: + # Comma-separated list of all non-conflicting features. + all_features: cli + jobs: fmt: name: Rustfmt @@ -41,7 +45,7 @@ jobs: components: clippy - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2 - name: Run clippy - run: cargo clippy --all-targets --all-features -- -D warnings + run: cargo clippy --all-targets --features ${{ env.all_features }} -- -D warnings test: name: Test @@ -71,7 +75,7 @@ jobs: toolchain: ${{ matrix.rust }} - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2 - name: Run Cargo Test - run: cargo +${{ matrix.rust }} test -r --all-targets --all-features --workspace + run: cargo +${{ matrix.rust }} test -r --all-targets --features ${{ env.all_features }} --workspace docs: name: Build docs @@ -101,7 +105,7 @@ jobs: toolchain: ${{ matrix.rust }} - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2 - name: Run Cargo Doc - run: cargo +${{ matrix.rust }} doc --no-deps --all-features --workspace --examples + run: cargo +${{ matrix.rust }} doc --no-deps --features ${{ env.all_features }} --workspace --examples powerset: name: Check Powerset of Features @@ -134,8 +138,17 @@ jobs: with: tool: cargo-hack - uses: Swatinem/rust-cache@a95ba195448af2da9b00fb742d14ffaaf3c21f43 # v2 - - name: Run Cargo Hack - run: cargo +${{ matrix.rust }} hack check --feature-powerset --no-dev-deps + + - name: Install libssl-dev + if: ${{ matrix.os == 'ubuntu-latest' }} + run: sudo apt-get install libssl-dev + + - name: Run Cargo Hack with tls-rustls + run: cargo +${{ matrix.rust }} hack check --feature-powerset --features tls-rustls --skip tls-native --no-dev-deps + + - name: Run Cargo Hack with tls-native + if: ${{ matrix.os == 'ubuntu-latest' }} + run: cargo +${{ matrix.rust }} hack check --feature-powerset --features tls-native --skip tls-rustls --no-dev-deps result: name: Result (CI) diff --git a/.github/workflows/cross-ci.yml b/.github/workflows/cross-ci.yml index 0afe339c..1f03b5c5 100644 --- a/.github/workflows/cross-ci.yml +++ b/.github/workflows/cross-ci.yml @@ -17,6 +17,10 @@ defaults: run: shell: bash +env: + # Comma-separated list of all non-conflicting features. + all_features: cli + jobs: cross-check: name: Cross checking ${{ matrix.job.target }} @@ -87,6 +91,8 @@ jobs: toolchain: ${{ matrix.rust }} target: ${{ matrix.job.target }} use-cross: ${{ matrix.job.use-cross }} + all-features: false + feature: ${{ env.all_features }} result: name: Result (Cross-CI) diff --git a/Cargo.toml b/Cargo.toml index a207748b..4f9fe84c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,10 +35,13 @@ harness = true edition = "2021" [features] -default = [] +default = ["tls-rustls"] cli = ["merge", "clap"] merge = ["dep:merge"] clap = ["dep:clap"] +# tls-native and tls-rustls are mutually exclusive. +tls-native = ["reqwest/native-tls"] +tls-rustls = ["reqwest/rustls-tls-native-roots"] [package.metadata.docs.rs] all-features = true @@ -96,7 +99,7 @@ walkdir = "2.4.0" # rest backend backoff = "0.4.0" -reqwest = { version = "0.11.23", default-features = false, features = ["json", "rustls-tls-native-roots", "stream", "blocking"] } +reqwest = { version = "0.11.23", default-features = false, features = ["json", "stream", "blocking"] } url = "2.5.0" # rclone backend diff --git a/README.md b/README.md index be79047c..c39bd6f7 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,12 @@ This crate exposes a few features for controlling dependency usage: by default*. - **clap** - Enables a dependency on the `clap` crate and enables parsing from the commandline. *This feature is disabled by default*. +- **tls-native** - Builds with native TLS support (i.e. link against system TLS + library). *This feature is mutually exclusive with `tls-rustls` and it is + disabled by default*. +- **tls-rustls** - Builds with Rustls support (i.e. with bundled TLS library). + *This feature is mutually exclusive with `tls-native` and it is enabled by + default*. ## Examples diff --git a/src/lib.rs b/src/lib.rs index 04bda03e..387b2185 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -139,6 +139,9 @@ This crate exposes a few features for controlling dependency usage. #![allow(rustdoc::private_intra_doc_links)] #![allow(clippy::needless_raw_string_hashes)] +#[cfg(all(feature = "tls-native", feature = "tls-rustls"))] +compile_error!("features \"tls-native\" and \"tls-rustls\" cannot be enabled at the same time. Please disable one of them."); + pub(crate) mod archiver; pub(crate) mod backend; pub(crate) mod blob;