Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set MSRV to 1.76 #871

Merged
merged 4 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/update-rust/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ runs:
shell: bash
- run: rustup default ${{ inputs.toolchain }}
shell: bash
- run: rustup component add clippy rustfmt
shell: bash
53 changes: 47 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,53 +21,86 @@ jobs:
- ubuntu-latest
- macOS-latest
- windows-latest
toolchain:
- "stable"
- "1.76" # MSRV
runs-on: ${{ matrix.os }}
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- name: Use the latest stable release
- name: Set Rust version
uses: ./.github/actions/update-rust
with:
toolchain: ${{ matrix.toolchain }}
- name: Install C libraries for tooling on ubuntu
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install libudev-dev libusb-1.0-0-dev
- name: Check that all crates that can be compiled for the host build, check that defmt compiles with different features, run all unit tests on the host
run: cargo xtask -d test-host

cross:
strategy:
matrix:
toolchain:
- "stable"
- "1.76" # MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use the latest stable release
- name: Set Rust version
uses: ./.github/actions/update-rust
with:
toolchain: ${{ matrix.toolchain }}
- name: Install Rust targets, build defmt crates for no_std targets, build defmt dependent crates for cortex-m targets, build panic-probe with different features
run: cargo xtask test-cross

lint:
strategy:
matrix:
toolchain:
- "stable"
- "1.76" # MSRV
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Use the latest stable release
- name: Set Rust version
uses: ./.github/actions/update-rust
with:
toolchain: ${{ matrix.toolchain }}
- name: Run rustfmt & clippy
run: cargo xtask test-lint

ui:
strategy:
matrix:
toolchain:
- "stable"
- "1.76" # MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use the latest stable release
- name: Set Rust version
uses: ./.github/actions/update-rust
with:
toolchain: ${{ matrix.toolchain }}
- name: Install Rust stable, run all UI tests on the host
run: cargo xtask test-ui

mdbook:
strategy:
matrix:
toolchain:
- "stable"
- "1.76" # MSRV
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Use the latest stable release
- name: Set Rust version
uses: ./.github/actions/update-rust
with:
toolchain: ${{ matrix.toolchain }}
- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
Expand All @@ -80,6 +113,7 @@ jobs:
matrix:
toolchain:
- stable
- "1.76" # MSRV
- nightly # some tests use unstable features
runs-on: ubuntu-latest
steps:
Expand All @@ -96,13 +130,20 @@ jobs:
run: cargo xtask test-snapshot

backcompat:
strategy:
matrix:
toolchain:
- "stable"
- "1.76" # MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use the latest stable release
- name: Set Rust version
uses: ./.github/actions/update-rust
with:
toolchain: ${{ matrix.toolchain }}
- name: Install QEMU_TARGET
run: rustup target add ${{ env.QEMU_TARGET }}
- name: Install dependencies
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- [#871]: Set MSRV to Rust 1.76
- [#865]: `defmt`: Replace proc-macro-error with proc-macro-error2
- [#859]: `defmt`: Satisfy clippy
- [#858]: `defmt`: Implement "passthrough" trait impls for *2Format wrappers
Expand All @@ -21,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- [#822]: `CI`: Run `cargo semver-checks` on every PR
- [#807]: `defmt-print`: Add `watch_elf` flag to allow ELF file reload without restarting `defmt-print`

[#871]: https://github.com/knurling-rs/defmt/pull/871
[#859]: https://github.com/knurling-rs/defmt/pull/859
[#858]: https://github.com/knurling-rs/defmt/pull/858
[#857]: https://github.com/knurling-rs/defmt/pull/857
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ To include `defmt` in your existing project, follow our [Application Setup guide
[Application Setup guide]: https://defmt.ferrous-systems.com/setup.html

## MSRV
`defmt` always compiles on the [latest `stable` rust release](https://github.com/rust-lang/rust/releases/latest). This is enforced by our CI building and testing against this version.

It still might work on older rust versions, but this isn't ensured.
The minimum supported Rust version is 1.76, which is Ferrocene 24.05.
Urhengulas marked this conversation as resolved.
Show resolved Hide resolved

## defmt ecosystem

Expand Down
3 changes: 3 additions & 0 deletions firmware/defmt-semihosting/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
//! log frames so don't use those APIs.

#![no_std]
// nightly warns about static_mut_refs, but 1.76 (our MSRV) does not know about
// that lint yet, so we ignore it it but also ignore if it is unknown
#![allow(unknown_lints, static_mut_refs)]
Urhengulas marked this conversation as resolved.
Show resolved Hide resolved

use core::sync::atomic::{AtomicBool, Ordering};

Expand Down
21 changes: 18 additions & 3 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::sync::Mutex;

use anyhow::anyhow;
use clap::{Parser, Subcommand};
use utils::rustc_is_msrv;

use crate::{
snapshot::{test_snapshot, Snapshot},
Expand Down Expand Up @@ -136,8 +137,13 @@ fn test_cross(deny_warnings: bool) {
false => vec![],
};

let mut features = vec!["", "alloc"];
Urhengulas marked this conversation as resolved.
Show resolved Hide resolved
if !rustc_is_msrv() {
features.push("ip_in_core");
}

for target in &targets {
for feature in ["", "alloc", "ip_in_core"] {
for feature in &features {
do_test(
|| {
run_command(
Expand Down Expand Up @@ -203,12 +209,21 @@ fn test_cross(deny_warnings: bool) {
|| {
run_command(
"cargo",
&["clippy", "--target", "thumbv7m-none-eabi", "--", "-D", "warnings"],
&[
"clippy",
"--target",
"thumbv7m-none-eabi",
"--",
"-D",
"warnings",
"-A",
"unknown-lints",
],
Some("firmware/"),
&env,
)
},
"lint",
"cross",
);
}

Expand Down
11 changes: 9 additions & 2 deletions xtask/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use similar::{ChangeTag, TextDiff};

use crate::{
do_test,
utils::{load_expected_output, overwrite_expected_output, run_capturing_stdout, rustc_is_nightly},
utils::{
load_expected_output, overwrite_expected_output, run_capturing_stdout, rustc_is_msrv,
rustc_is_nightly,
},
};

pub const SNAPSHOT_TESTS_DIRECTORY: &str = "firmware/qemu";
Expand All @@ -25,15 +28,19 @@ pub(crate) fn all_snapshot_tests() -> Vec<&'static str> {
"hints",
"hints_inner",
"dbg",
"net",
"panic_info",
];
const NIGHTLY_SNAPSHOT_TESTS: &[&str] = &["alloc"];
const POST_MSRV_SNAPSHOT_TESTS: &[&str] = &["net"];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unclear to me what "post msrv snapshot tests" are. If we raise the msrv should this change?

Copy link
Member Author

@Urhengulas Urhengulas Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We have three brackets of tests

  1. tests that work on the msrv, stable and nightly
  2. tests that work on stable and nightly
  3. tests that work on nightly only

Regarding 2: The default defmt features support the msrv, but some of the optional features require a newer version, e.g. ip_in_core. These tests are the ones in POST_MSRV_TESTS. Maybe OPTIONAL_FEATURE_TESTS is better?

Regarding 3: These tests use unstable features.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So POST_MSRV means "any version above our MSRV"? If so, a little comment would be really nice:

// Tests which run on all Rustc versions later than our MSRV
const POST_MSRV_SNAPSHOT_TESTS: &[&str] = &["net"];

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well it's not all versions. It's some version in MSRV..=STABLE.


let mut tests = STABLE_SNAPSHOT_TESTS.to_vec();
if rustc_is_nightly() {
tests.extend(NIGHTLY_SNAPSHOT_TESTS);
}
if !rustc_is_msrv() {
tests.extend(POST_MSRV_SNAPSHOT_TESTS);
}

tests
}

Expand Down
6 changes: 6 additions & 0 deletions xtask/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,9 @@ pub fn rustc_is_nightly() -> bool {
let out = run_capturing_stdout(Command::new("rustc").args(["-V"])).unwrap();
out.contains("nightly")
}

pub fn rustc_is_msrv() -> bool {
const MSRV: &str = "1.76";
let out = run_capturing_stdout(Command::new("rustc").args(["-V"])).unwrap();
Urhengulas marked this conversation as resolved.
Show resolved Hide resolved
out.contains(MSRV)
}
Loading