From 1a5e2f82d0b07b3685f5f3708fa935d851e3d56a Mon Sep 17 00:00:00 2001 From: Johann Hemmann Date: Fri, 29 Mar 2024 17:40:27 +0100 Subject: [PATCH 1/5] CI: update to `actions/checkout@v4` --- .github/workflows/changelog.yml | 2 +- .github/workflows/ci.yml | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 82766b80..61a65a10 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout sources - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Check that changelog updated uses: dangoslen/changelog-enforcer@v3 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 087032b0..0164a520 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: runs-on: ${{ matrix.os }} timeout-minutes: 20 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use the latest stable release run: rustup update stable && rustup default stable - name: Install C libraries for tooling on ubuntu @@ -36,7 +36,7 @@ jobs: cross: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use the latest stable release run: rustup update stable && rustup default stable - 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 @@ -46,7 +46,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use the latest stable release run: rustup update stable && rustup default stable - name: Run rustfmt & clippy @@ -55,7 +55,7 @@ jobs: ui: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use the latest stable release run: rustup update stable && rustup default stable - name: Install Rust stable, run all UI tests on the host @@ -65,7 +65,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use the latest stable release run: rustup update stable && rustup default stable - name: Setup mdBook @@ -83,7 +83,7 @@ jobs: # - nightly # some tests use unstable features runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use the latest stable release run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} - name: Install QEMU_TARGET @@ -96,7 +96,7 @@ jobs: backcompat: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - name: Use the latest stable release From dea42be16688a82d02e3e0136c7c51c791885155 Mon Sep 17 00:00:00 2001 From: Johann Hemmann Date: Mon, 13 May 2024 15:39:17 +0200 Subject: [PATCH 2/5] Fix CI https://github.com/rust-lang/rustup/issues/3709 --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0164a520..bd645ec1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use the latest stable release - run: rustup update stable && rustup default stable + run: | + rustup update --no-self-update stable + rustup default stable - 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 @@ -38,7 +40,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use the latest stable release - run: rustup update stable && rustup default stable + run: | + rustup update --no-self-update stable + rustup default stable - 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 @@ -48,7 +52,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use the latest stable release - run: rustup update stable && rustup default stable + run: | + rustup update --no-self-update stable + rustup default stable - name: Run rustfmt & clippy run: cargo xtask test-lint @@ -57,7 +63,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use the latest stable release - run: rustup update stable && rustup default stable + run: | + rustup update --no-self-update stable + rustup default stable - name: Install Rust stable, run all UI tests on the host run: cargo xtask test-ui @@ -67,7 +75,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use the latest stable release - run: rustup update stable && rustup default stable + run: | + rustup update --no-self-update stable + rustup default stable - name: Setup mdBook uses: peaceiris/actions-mdbook@v1 with: @@ -84,8 +94,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Use the latest stable release - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} + - name: Use the latest ${{ matrix.toolchain }} release + run: | + rustup update --no-self-update ${{ matrix.toolchain }} + rustup default ${{ matrix.toolchain }} - name: Install QEMU_TARGET run: rustup target add ${{ env.QEMU_TARGET }} - name: Install dependencies @@ -100,7 +112,9 @@ jobs: with: fetch-depth: 0 - name: Use the latest stable release - run: rustup update stable && rustup default stable + run: | + rustup update --no-self-update stable + rustup default stable - name: Install QEMU_TARGET run: rustup target add ${{ env.QEMU_TARGET }} - name: Install dependencies From e318b3489ed3de0557a437cdc29fb6690485ebfb Mon Sep 17 00:00:00 2001 From: Johann Hemmann Date: Mon, 13 May 2024 16:03:01 +0200 Subject: [PATCH 3/5] Fix tests --- defmt/src/encoding/mod.rs | 1 + defmt/tests/encode.rs | 1 + firmware/qemu/tests/defmt-test.out | 16 ++++++++-------- firmware/qemu/tests/defmt-test.rs | 9 +++++++++ 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/defmt/src/encoding/mod.rs b/defmt/src/encoding/mod.rs index f6d004ac..1ef945c8 100644 --- a/defmt/src/encoding/mod.rs +++ b/defmt/src/encoding/mod.rs @@ -39,6 +39,7 @@ pub struct Encoder { impl Encoder { /// Create a new `Encoder`. + #[allow(clippy::new_without_default)] pub const fn new() -> Self { Self { inner: inner::Encoder::new(), diff --git a/defmt/tests/encode.rs b/defmt/tests/encode.rs index c87d27c0..67f0677e 100644 --- a/defmt/tests/encode.rs +++ b/defmt/tests/encode.rs @@ -438,6 +438,7 @@ fn c_like_enum() { } #[test] +#[allow(dead_code)] fn uninhabited_enum() { #[derive(Format)] enum Void {} diff --git a/firmware/qemu/tests/defmt-test.out b/firmware/qemu/tests/defmt-test.out index f04de682..20c44b8f 100644 --- a/firmware/qemu/tests/defmt-test.out +++ b/firmware/qemu/tests/defmt-test.out @@ -1,9 +1,9 @@ -(1/8) running `change_init_struct`... -(2/8) running `test_for_changed_init_struct`... -(3/8) running `assert_true`... -(4/8) running `assert_imported_max`... -(5/8) running `result`... -(6/8) running `should_error`... -(7/8) ignoring `ignored`... -(8/8) running `fail`... +(1/9) running `change_init_struct`... +(2/9) running `test_for_changed_init_struct`... +(3/9) running `assert_true`... +(4/9) running `assert_imported_max`... +(5/9) running `result`... +(6/9) running `should_error`... +(7/9) ignoring `ignored`... +(8/9) running `fail`... ERROR panicked at '`#[should_error]` test failed with outcome: Ok(this should have returned `Err`)' diff --git a/firmware/qemu/tests/defmt-test.rs b/firmware/qemu/tests/defmt-test.rs index 7f0a5bad..7aa40317 100644 --- a/firmware/qemu/tests/defmt-test.rs +++ b/firmware/qemu/tests/defmt-test.rs @@ -83,6 +83,15 @@ mod tests { Ok("this should have returned `Err`") } + + #[test] + fn assert_some_data() { + let a = SomeData { + elem1: 1, + elem2: 2.0, + }; + assert_eq!(a.elem2, 2.0); + } } // like `panic-semihosting` but doesn't print to stdout (that would corrupt the defmt stream) From 55371db8b8cf1d583afeb7a73d24df1b5e228b8e Mon Sep 17 00:00:00 2001 From: Johann Hemmann Date: Mon, 13 May 2024 16:04:14 +0200 Subject: [PATCH 4/5] Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fb0f766..3702e7ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +- [#831]: Fix CI - [#828]: `defmt-decoder`: Update to `gimli 0.29` - [#821]: Cleanup - [#813]: doc: add note for the alloc feature flag @@ -14,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [#811]: `book`: Add some examples for byte slice/array hints as well - [#800]: `defmt-macros`: Fix generic trait bounds in Format derive macro +[#831]: https://github.com/knurling-rs/defmt/pull/831 [#828]: https://github.com/knurling-rs/defmt/pull/828 [#821]: https://github.com/knurling-rs/defmt/pull/821 [#813]: https://github.com/knurling-rs/defmt/pull/813 From bae9ace5516fd0f6c687e0f456bdb7fc28dabb63 Mon Sep 17 00:00:00 2001 From: Johann Hemmann Date: Mon, 13 May 2024 15:49:14 +0200 Subject: [PATCH 5/5] Use composite action --- .github/actions/update-rust/action.yml | 14 ++++++++++++ .github/workflows/ci.yml | 30 ++++++++------------------ 2 files changed, 23 insertions(+), 21 deletions(-) create mode 100644 .github/actions/update-rust/action.yml diff --git a/.github/actions/update-rust/action.yml b/.github/actions/update-rust/action.yml new file mode 100644 index 00000000..77e703c6 --- /dev/null +++ b/.github/actions/update-rust/action.yml @@ -0,0 +1,14 @@ +name: "Update Rust" +description: "Update the Rust toolchain" +inputs: + toolchain: + required: true + default: "stable" + description: "The toolchain channel or version to use" +runs: + using: "composite" + steps: + - run: rustup update --no-self-update ${{ inputs.toolchain }} + shell: bash + - run: rustup default ${{ inputs.toolchain }} + shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd645ec1..443c9af7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,9 +26,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use the latest stable release - run: | - rustup update --no-self-update stable - rustup default stable + uses: ./.github/actions/update-rust - 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 @@ -40,9 +38,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use the latest stable release - run: | - rustup update --no-self-update stable - rustup default stable + uses: ./.github/actions/update-rust - 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 @@ -52,9 +48,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use the latest stable release - run: | - rustup update --no-self-update stable - rustup default stable + uses: ./.github/actions/update-rust - name: Run rustfmt & clippy run: cargo xtask test-lint @@ -63,9 +57,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use the latest stable release - run: | - rustup update --no-self-update stable - rustup default stable + uses: ./.github/actions/update-rust - name: Install Rust stable, run all UI tests on the host run: cargo xtask test-ui @@ -75,9 +67,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use the latest stable release - run: | - rustup update --no-self-update stable - rustup default stable + uses: ./.github/actions/update-rust - name: Setup mdBook uses: peaceiris/actions-mdbook@v1 with: @@ -95,9 +85,9 @@ jobs: steps: - uses: actions/checkout@v4 - name: Use the latest ${{ matrix.toolchain }} release - run: | - rustup update --no-self-update ${{ matrix.toolchain }} - rustup default ${{ matrix.toolchain }} + uses: ./.github/actions/update-rust + with: + toolchain: ${{ matrix.toolchain }} - name: Install QEMU_TARGET run: rustup target add ${{ env.QEMU_TARGET }} - name: Install dependencies @@ -112,9 +102,7 @@ jobs: with: fetch-depth: 0 - name: Use the latest stable release - run: | - rustup update --no-self-update stable - rustup default stable + uses: ./.github/actions/update-rust - name: Install QEMU_TARGET run: rustup target add ${{ env.QEMU_TARGET }} - name: Install dependencies