Skip to content

Commit

Permalink
Add minimal versions test to CI (#373)
Browse files Browse the repository at this point in the history
Add step to CI that compiles and runs all tests against the lowest compatible versions of all crates to ensure that the specified dependency ranges are actually compatible.

See also <https://users.rust-lang.org/t/psa-please-specify-precise-dependency-versions-in-cargo-toml/71277>.
  • Loading branch information
sagebind committed Feb 5, 2022
1 parent 5175f9f commit 3a49173
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ coverage:
project:
default:
threshold: 1%
patch: false
ignore:
- "testserver/**/*"
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,46 @@ jobs:
- name: Run example program
run: cargo run --release --example simple

test-minimal-versions:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v2
with:
submodules: true

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
components: clippy
default: true

# openssl-sys <0.9.45 relies on a feature in rustc_version >=0.2.2, but
# specifies its dependency as "^0.2".
- name: Override openssl-sys version
run: |
printf '[dependencies.openssl-sys]\nversion = "0.9.45"\n' >> Cargo.toml
- name: Update Cargo.lock
run: cargo -Z minimal-versions update

- name: Cache Cargo dependencies
uses: actions/cache@v2
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: cargo-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-${{ runner.os }}-
- name: Run tests
run: cargo test --features ${{ env.FEATURES }}

analyze:
runs-on: ubuntu-latest
timeout-minutes: 20
Expand Down
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ unstable-rustls-tls = ["curl/rustls"]
unstable-interceptors = []

[dependencies]
async-channel = "1.6"
castaway = "0.1"
crossbeam-utils = "0.8"
async-channel = "1.4.2"
castaway = "0.1.1"
crossbeam-utils = ">=0.7.0, <0.9.0"
curl = "0.4.42"
curl-sys = "0.4.52"
event-listener = "2.5"
futures-lite = "1.11"
event-listener = "2.3.3"
futures-lite = "1.10.1"
http = "0.2.1"
log = "0.4"
once_cell = "1"
polling = "2.0"
polling = "2"
slab = "0.4"
sluice = "0.5.4"
url = "2.2"
url = "2.1"
waker-fn = "1"

[dependencies.encoding_rs]
Expand All @@ -62,7 +62,7 @@ version = "0.3"
optional = true

[dependencies.parking_lot]
version = "0.11"
version = ">=0.9.0, <0.12.0"
optional = true

[dependencies.publicsuffix]
Expand All @@ -89,7 +89,7 @@ features = ["std", "std-future"]

[dev-dependencies]
env_logger = "0.9"
flate2 = "1.0"
flate2 = "1.0.3"
indicatif = "0.15"
rayon = "1"
static_assertions = "1.1"
Expand Down
2 changes: 1 addition & 1 deletion src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl Decoder {
{
if let Some(charset) = content_type.get_param(mime::CHARSET) {
if let Some(encoding) =
encoding_rs::Encoding::for_label(charset.as_str().as_bytes())
encoding_rs::Encoding::for_label(charset.as_ref().as_bytes())
{
return Self::new(encoding);
} else {
Expand Down
2 changes: 1 addition & 1 deletion tests/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ fn request_gzip_without_automatic_decompression() {
m.request().expect_header("Accept-Encoding", "gzip");

// Response body size should be known.
assert_eq!(response.body().len(), Some(31));
assert_eq!(response.body().len(), Some(body_encoded.len() as u64));
}

#[test]
Expand Down

0 comments on commit 3a49173

Please sign in to comment.