Skip to content

Commit

Permalink
chore(ci): run MSRV checks with minimal versions (#2171)
Browse files Browse the repository at this point in the history
In many cases, new releases of a dependency can break compatibility with
`tracing`'s minimum supported Rust version (MSRV). It shouldn't be
necessary for a `tracing` crate 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 explicitly and avoid bumping. Instead, we should
probably just run our MSRV checks with minimal dependency versions. This
way, we don't need to bump our MSRV when the latest version of a
dependency does, unless we actually *need* to pick up that new version.

This branch changes the `check_msrv` CI jobs to do that. I also did some
minor dependency editing to actually make tracing build with
`-Zminimal-versions`.

Note that `tracing-futures` is currently excluded from the MSRV build
because it depends on a really ancient version of Tokio that pulls in
broken deps. We should probably drop support for Tokio 0.1 and release a
new version of that crate, but for now, we have to skip it from the CI
job temporarily.

Signed-off-by: Eliza Weisman <[email protected]>
  • Loading branch information
hawkw committed Jun 22, 2022
1 parent f42e7e6 commit 67cfb5f
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 42 deletions.
59 changes: 49 additions & 10 deletions .github/workflows/check_msrv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,76 @@ env:
RUSTUP_MAX_RETRIES: 10
# Don't emit giant backtraces in the CI logs.
RUST_BACKTRACE: short
MSRV: 1.49.0
# TODO: remove this once tracing's MSRV is bumped.
APPENDER_MSRV: 1.53.0

jobs:
check-msrv:
# Run `cargo check` on our minimum supported Rust version (1.49.0).
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: actions-rs/toolchain@v1
- 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: 1.49.0
toolchain: nightly
profile: minimal
override: true
- 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 --exclude=tracing-appender
# skip the following crates:
# - tracing-appender, as it has its own MSRV.
# TODO(eliza): remove this when appender is on the same MSRV as
# everything else
# - the examples, as they are not published & we don't care about
# MSRV support for them.
# - tracing-futures, as it depends on ancient tokio versions.
# TODO(eliza): remove this when the ancient tokio deps are dropped
args: >-
--workspace --all-features --locked
--exclude=tracing-appender
--exclude=tracing-examples
--exclude=tracing-futures
toolchain: ${{ env.MSRV }}

# TODO: remove this once tracing's MSRV is bumped.
check-msrv-appender:
# Run `cargo check` on our minimum supported Rust version (1.53.0).
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: actions-rs/toolchain@v1
- uses: actions/checkout@master
- name: "install Rust ${{ env.APPENDER_MSRV }}"
uses: actions-rs/toolchain@v1
with:
toolchain: 1.53.0
toolchain: ${{ env.APPENDER_MSRV }}
profile: minimal
override: true
- 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: --lib=tracing-appender
args: --all-features --locked -p tracing-appender
toolchain: ${{ env.APPENDER_MSRV }}
4 changes: 2 additions & 2 deletions tracing-futures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ tokio-executor = { version = "0.1", optional = true }
tokio = { version = "0.1", optional = true }

[dev-dependencies]
tokio = "0.1.22"
tokio-test = "0.3"
tokio = "1"
tokio-test = "0.4"
tracing-core = { path = "../tracing-core", version = "0.1.2" }
tracing-mock = { path = "../tracing-mock" }

Expand Down
58 changes: 29 additions & 29 deletions tracing-futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -627,35 +627,35 @@ mod tests {
handle.assert_finished();
}

#[test]
fn span_follows_future_onto_threadpool() {
let (subscriber, handle) = subscriber::mock()
.enter(span::mock().named("a"))
.enter(span::mock().named("b"))
.exit(span::mock().named("b"))
.enter(span::mock().named("b"))
.exit(span::mock().named("b"))
.drop_span(span::mock().named("b"))
.exit(span::mock().named("a"))
.drop_span(span::mock().named("a"))
.done()
.run_with_handle();
let mut runtime = tokio::runtime::Runtime::new().unwrap();
with_default(subscriber, || {
tracing::trace_span!("a").in_scope(|| {
let future = PollN::new_ok(2)
.instrument(tracing::trace_span!("b"))
.map(|_| {
tracing::trace_span!("c").in_scope(|| {
// "c" happens _outside_ of the instrumented future's
// span, so we don't expect it.
})
});
runtime.block_on(Box::new(future)).unwrap();
})
});
handle.assert_finished();
}
// #[test]
// fn span_follows_future_onto_threadpool() {
// let (subscriber, handle) = subscriber::mock()
// .enter(span::mock().named("a"))
// .enter(span::mock().named("b"))
// .exit(span::mock().named("b"))
// .enter(span::mock().named("b"))
// .exit(span::mock().named("b"))
// .drop_span(span::mock().named("b"))
// .exit(span::mock().named("a"))
// .drop_span(span::mock().named("a"))
// .done()
// .run_with_handle();
// let mut runtime = tokio::runtime::Runtime::new().unwrap();
// with_default(subscriber, || {
// tracing::trace_span!("a").in_scope(|| {
// let future = PollN::new_ok(2)
// .instrument(tracing::trace_span!("b"))
// .map(|_| {
// tracing::trace_span!("c").in_scope(|| {
// // "c" happens _outside_ of the instrumented future's
// // span, so we don't expect it.
// })
// });
// runtime.block_on(Box::new(future)).unwrap();
// })
// });
// handle.assert_finished();
// }
}

#[cfg(all(feature = "futures-03", feature = "std-future"))]
Expand Down
2 changes: 1 addition & 1 deletion tracing-subscriber/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ tracing-log = { path = "../tracing-log", version = "0.1.2" }
criterion = { version = "0.3", default_features = false }
regex = { version = "1", default-features = false, features = ["std"] }
tracing-futures = { path = "../tracing-futures", version = "0.2", default-features = false, features = ["std-future", "std"] }
tokio = { version = "0.2", features = ["rt-core", "macros"] }
tokio = { version = "1", features = ["rt", "macros"] }
# Enable the `time` crate's `macros` feature, for examples.
time = { version = "0.3", features = ["formatting", "macros"] }

Expand Down

0 comments on commit 67cfb5f

Please sign in to comment.