Fix rustls-tls feature (#1194)

* Fix rustls-tls feature

Commit 14e74879 (cookie support #1146) re-introduced an unconditional
dependency on the openssl-sys crate. That is, building Lychee with the
Rustls TLS backend now requires OpenSSL. I suppose this change was
unintended, maybe due to automatic conflict resolution. If not, please
let me know.

You can review the re-introduced dependency like so:

```
cargo tree --no-default-features --features rustls-tls -i openssl-sys
```

This commit puts the OpenSSL dependency behind the native-tls feature
flag again.

You can check the TLS features like so:

```
cargo check --workspace --all-targets --features vendored-openssl

cargo check --workspace --all-targets --all-features

cargo check --workspace --all-targets --no-default-features --features rustls-tls
```

Maybe this should be added to CI. But I don't want to waste anybody's
time.

* Check feature flags during CI

Adds a new CI job 'check-feature-flags' to verify the following:

- Lychee with rustls-tls feature only doesn't depend on OpenSSL
- Cargo check passes with default features
- Cargo check passes with all features
- Cargo check passes with rustls-tls feature only
This commit is contained in:
Stefan Kreutz 2023-08-04 15:11:29 +02:00 committed by GitHub
parent fef06e72f2
commit b1b32e7717
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 33 additions and 3 deletions

View file

@ -84,6 +84,7 @@ jobs:
needs:
- test
- lint
- check-feature-flags
- publish-check
runs-on: ubuntu-latest
steps:
@ -109,3 +110,29 @@ jobs:
with:
command: publish
args: --manifest-path lychee-bin/Cargo.toml
check-feature-flags:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Check that rustls-tls feature doesn't depend on OpenSSL
shell: bash
run: |
! cargo tree --package lychee --no-default-features --features rustls-tls -i openssl-sys
- name: Run cargo check with default features
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-targets
- name: Run cargo check with all features
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-targets --all-features
- name: Run cargo check with rustls-tls feature
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-targets --no-default-features --features rustls-tls

View file

@ -73,7 +73,6 @@ use log::{error, info, warn};
#[cfg(feature = "native-tls")]
use openssl_sys as _; // required for vendored-openssl feature
use openssl_sys as _;
use options::LYCHEE_CONFIG_FILE;
use ring as _; // required for apple silicon

View file

@ -41,7 +41,7 @@ pulldown-cmark = "0.9.3"
regex = "1.9.1"
# Use trust-dns to avoid lookup failures on high concurrency
# https://github.com/seanmonstar/reqwest/issues/296
reqwest = { version = "0.11.18", features = ["gzip", "trust-dns", "cookies"] }
reqwest = { version = "0.11.18", default-features = false, features = ["gzip", "trust-dns", "cookies"] }
reqwest_cookie_store = "0.6.0"
# Make build work on Apple Silicon.
# See https://github.com/briansmith/ring/issues/1163

View file

@ -715,8 +715,12 @@ impl Client {
}
}
/// Check a mail address, or equivalently a `mailto` URI.
///
/// This implementation simply excludes all email addresses.
#[cfg(not(all(feature = "email-check", feature = "native-tls")))]
pub async fn check_mail(&self, uri: &Uri) -> Status {
#[allow(clippy::unused_async)]
pub async fn check_mail(&self, _uri: &Uri) -> Status {
Status::Excluded
}
}