ci: run MSRV checks with minimal dep versions (#670)

In many cases, new releases of a dependency can break compatibility with
Tower's minimum supported Rust version (MSRV). It shouldn't be necessary
for Tower to bump its MSRV when a dependency does, as users on older
Rust versions should be able to depend on older versions of that crate.
Instead, we should probably just run our MSRV checks with minimal
dependency versions.

This branch changes Tower's CI jobs to do that. It was also necessary to 
make some changes to the `Cargo.toml` to actually fix the build with
minimal dependency versions.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
This commit is contained in:
Eliza Weisman 2022-06-17 11:23:32 -07:00
parent 12a06035eb
commit d264bc7968
No known key found for this signature in database
GPG Key ID: F9C1A595C3814436
2 changed files with 73 additions and 20 deletions

View File

@ -6,21 +6,18 @@ on:
- master
pull_request: {}
env:
MSRV: 1.49.0
jobs:
check:
check-stable:
# Run `cargo check` first to ensure that the pushed code at least compiles.
runs-on: ubuntu-latest
strategy:
# Disable fail-fast. If the test run for a particular Rust version fails,
# don't cancel the other test runs, so that we can determine whether a
# failure only occurs on a particular version.
fail-fast: false
matrix:
rust: [stable, 1.49.0]
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
toolchain: stable
profile: minimal
override: true
- name: Check
@ -43,6 +40,33 @@ jobs:
RUSTDOCFLAGS: "-D rustdoc::broken_intra_doc_links"
run: cargo doc --all-features --no-deps
check-msrv:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: "install Rust ${{ env.MSRV }}"
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.MSRV }}
profile: minimal
- name: "install Rust nightly"
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
- name: Select minimal versions
uses: actions-rs/cargo@v1
with:
command: update
args: -Z minimal-versions
toolchain: nightly
- name: Check
uses: actions-rs/cargo@v1
with:
command: check
args: --all --all-targets --all-features --locked
toolchain: ${{ env.MSRV }}
cargo-hack:
runs-on: ubuntu-latest
steps:
@ -51,16 +75,15 @@ jobs:
with:
toolchain: stable
profile: minimal
- name: Install cargo-hack
run: |
curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-x86_64-unknown-linux-gnu.tar.gz | tar xzf - -C ~/.cargo/bin
- name: install cargo-hack
uses: taiki-e/install-action@cargo-hack
- name: cargo hack check
working-directory: ${{ matrix.subcrate }}
run: cargo hack check --each-feature --no-dev-deps --workspace
test-versions:
# Test against the stable, beta, and nightly Rust toolchains on ubuntu-latest.
needs: check
needs: check-stable
runs-on: ubuntu-latest
strategy:
# Disable fail-fast. If the test run for a particular Rust version fails,
@ -68,10 +91,11 @@ jobs:
# failure only occurs on a particular version.
fail-fast: false
matrix:
rust: [stable, beta, nightly, 1.49.0]
rust: [stable, beta, nightly]
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
- name: "install Rust ${{ matrix.rust }}"
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
@ -82,8 +106,36 @@ jobs:
command: test
args: --workspace --all-features
test-msrv:
needs: check-msrv
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: "install Rust ${{ env.MSRV }}"
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ env.MSRV }}
profile: minimal
- name: "install Rust nightly"
uses: actions-rs/toolchain@v1
with:
toolchain: nightly
profile: minimal
- name: Select minimal versions
uses: actions-rs/cargo@v1
with:
command: update
args: -Z minimal-versions
toolchain: nightly
- name: test
uses: actions-rs/cargo@v1
with:
command: check
args: --workspace --all-features --locked
toolchain: ${{ env.MSRV }}
style:
needs: check
needs: check-stable
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master

View File

@ -71,7 +71,7 @@ tower-service = { version = "0.3.1", path = "../tower-service" }
futures-core = { version = "0.3", optional = true }
futures-util = { version = "0.3", default-features = false, features = ["alloc"], optional = true }
hdrhistogram = { version = "7.0", optional = true }
hdrhistogram = { version = "7.0", optional = true, default-features = false }
indexmap = { version = "1.0.2", optional = true }
rand = { version = "0.8", features = ["small_rng"], optional = true }
slab = { version = "0.4", optional = true }
@ -84,14 +84,15 @@ pin-project-lite = { version = "0.2.7", optional = true }
[dev-dependencies]
futures = "0.3"
hdrhistogram = "7.0"
hdrhistogram = { version = "7.0", default-features = false }
pin-project-lite = "0.2.7"
tokio = { version = "1.6", features = ["macros", "sync", "test-util", "rt-multi-thread"] }
tokio = { version = "1.6.2", features = ["macros", "sync", "test-util", "rt-multi-thread"] }
tokio-stream = "0.1"
tokio-test = "0.4"
tower-test = { version = "0.4", path = "../tower-test" }
tracing-subscriber = "0.2.14"
tracing-subscriber = { version = "0.3", default-features = false, features = ["fmt", "ansi"] }
http = "0.2"
lazy_static = "1.4.0"
[package.metadata.docs.rs]
all-features = true