Skip to content

Commit

Permalink
ci: run MSRV checks with minimal dep versions (#670)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
hawkw committed Jun 17, 2022
1 parent 12a0603 commit d264bc7
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 20 deletions.
84 changes: 68 additions & 16 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -51,27 +75,27 @@ 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,
# 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, 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
Expand All @@ -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
Expand Down
9 changes: 5 additions & 4 deletions tower/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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
Expand Down

0 comments on commit d264bc7

Please sign in to comment.