Skip to content

feat: Add tls-native, tls-rustls features to allow building w/o Rustls #110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/cross-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down