From 0f903f60bd7486cbf86663d42f3abb8b67c1e04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Wed, 9 Feb 2022 18:44:57 +0100 Subject: [PATCH 1/6] GHA: Use rust-cache --- .github/workflows/build.yml | 178 +++++------------------------------- 1 file changed, 24 insertions(+), 154 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc07519fde..c2f635d5ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Install Rust uses: actions-rs/toolchain@v1 @@ -52,28 +52,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-build- - - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) uses: actions-rs/toolchain@v1 with: @@ -84,6 +62,9 @@ jobs: - name: Fail on warnings run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - name: cargo check uses: actions-rs/cargo@v1 with: @@ -106,28 +87,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-build- - - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) uses: actions-rs/toolchain@v1 with: @@ -136,8 +95,10 @@ jobs: override: true components: llvm-tools-preview + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - name: Check the examples - if: matrix.target == 'thumbv7m-none-eabi' uses: actions-rs/cargo@v1 with: use-cross: false @@ -159,28 +120,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-build- - - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) uses: actions-rs/toolchain@v1 with: @@ -197,6 +136,9 @@ jobs: version: latest use-tool-cache: true + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - name: Install QEMU run: | sudo apt update @@ -223,28 +165,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-build- - - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) uses: actions-rs/toolchain@v1 with: @@ -252,6 +172,9 @@ jobs: target: ${{ matrix.target }} override: true + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - name: Fail on warnings run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs @@ -276,28 +199,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - ${{ runner.OS }}-build- - - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) uses: actions-rs/toolchain@v1 with: @@ -305,6 +206,9 @@ jobs: target: ${{ matrix.target }} override: true + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + - name: Fail on warnings run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs @@ -329,26 +233,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build- - - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -356,6 +240,12 @@ jobs: target: ${{ matrix.target }} override: true + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + - name: Fail on warnings + run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs + - uses: actions-rs/cargo@v1 with: use-cross: false @@ -371,26 +261,6 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Cache cargo dependencies - uses: actions/cache@v2 - with: - path: | - - ~/.cargo/bin/ - - ~/.cargo/registry/index/ - - ~/.cargo/registry/cache/ - - ~/.cargo/git/db/ - key: ${{ runner.OS }}-cargo-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-cargo- - - - name: Cache build output dependencies - uses: actions/cache@v2 - with: - path: target - key: ${{ runner.OS }}-build-${{ hashFiles('**/Cargo.lock') }} - restore-keys: | - ${{ runner.OS }}-build- - - name: Cache pip installed linkchecker uses: actions/cache@v2 with: @@ -453,7 +323,7 @@ jobs: run: pip install git+https://github.com/linkchecker/linkchecker.git - name: mdBook Action - uses: peaceiris/actions-mdbook@v1.1.13 + uses: peaceiris/actions-mdbook@v1 with: mdbook-version: 'latest' @@ -509,7 +379,7 @@ jobs: run: python -c "import sys; print(sys.version)" - name: mdBook Action - uses: peaceiris/actions-mdbook@v1.1.13 + uses: peaceiris/actions-mdbook@v1 with: mdbook-version: 'latest' From b42abe1b4fdba8cb3b027ea12b55e583d3147ea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Wed, 9 Feb 2022 18:45:31 +0100 Subject: [PATCH 2/6] GHA: Cleanup single target jobs --- .github/workflows/build.yml | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c2f635d5ef..1bc0a71dbd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -189,21 +189,15 @@ jobs: testmacros: name: testmacros runs-on: ubuntu-20.04 - strategy: - matrix: - target: - - x86_64-unknown-linux-gnu - toolchain: - - stable steps: - name: Checkout uses: actions/checkout@v2 - - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }}) + - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: ${{ matrix.toolchain }} - target: ${{ matrix.target }} + toolchain: stable + target: x86_64-unknown-linux-gnu override: true - name: Cache Dependencies @@ -217,18 +211,12 @@ jobs: with: use-cross: false command: test - args: --manifest-path macros/Cargo.toml --target=${{ matrix.target }} + args: --manifest-path macros/Cargo.toml - # Run test suite for thumbv7m + # Run test suite tests: name: tests runs-on: ubuntu-20.04 - strategy: - matrix: - target: - - x86_64-unknown-linux-gnu - toolchain: - - stable steps: - name: Checkout uses: actions/checkout@v2 @@ -236,8 +224,8 @@ jobs: - name: Install Rust uses: actions-rs/toolchain@v1 with: - toolchain: ${{ matrix.toolchain }} - target: ${{ matrix.target }} + toolchain: stable + target: x86_64-unknown-linux-gnu override: true - name: Cache Dependencies @@ -250,13 +238,12 @@ jobs: with: use-cross: false command: test - args: --test tests --target=${{ matrix.target }} + args: --test tests # Build documentation, check links docs: name: docs runs-on: ubuntu-20.04 - steps: - name: Checkout uses: actions/checkout@v2 From 10ec36b4434d3ba0426ad427c321067286ebc00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Wed, 9 Feb 2022 18:45:49 +0100 Subject: [PATCH 3/6] GHA: Add cargo clippy --- .github/workflows/build.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1bc0a71dbd..f0fac75dd5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,6 +72,33 @@ jobs: command: check args: --target=${{ matrix.target }} + # Clippy + clippy: + name: Cargo clippy + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Rust stable + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: x86_64-unknown-linux-gnu + override: true + + - name: Fail on warnings + run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs + + - name: Cache Dependencies + uses: Swatinem/rust-cache@v1 + + - name: cargo clippy + uses: actions-rs/cargo@v1 + with: + use-cross: false + command: clippy + # Verify all examples, checks checkexamples: name: checkexamples @@ -467,6 +494,7 @@ jobs: needs: - style - check + - clippy - checkexamples - testexamples - checkmacros From 099544f655795aa63b87d2f0b004331a57b93dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Wed, 9 Feb 2022 18:56:35 +0100 Subject: [PATCH 4/6] Fix/mute clippy errors --- macros/src/codegen/module.rs | 2 +- macros/src/codegen/software_tasks.rs | 1 + macros/src/codegen/util.rs | 26 +++++++------------------- src/tq.rs | 1 + 4 files changed, 10 insertions(+), 20 deletions(-) diff --git a/macros/src/codegen/module.rs b/macros/src/codegen/module.rs index 996af64175..8410b7d75c 100644 --- a/macros/src/codegen/module.rs +++ b/macros/src/codegen/module.rs @@ -269,7 +269,7 @@ pub fn codegen( let m_ident = util::monotonic_ident(&monotonic_name); let m_isr = &monotonic.args.binds; let enum_ = util::interrupt_ident(); - let spawn_handle_string = format!("{}::SpawnHandle", m.to_string()); + let spawn_handle_string = format!("{}::SpawnHandle", m); let (enable_interrupt, pend) = if &*m_isr.to_string() == "SysTick" { ( diff --git a/macros/src/codegen/software_tasks.rs b/macros/src/codegen/software_tasks.rs index 2008b6c98a..c767032f5c 100644 --- a/macros/src/codegen/software_tasks.rs +++ b/macros/src/codegen/software_tasks.rs @@ -38,6 +38,7 @@ pub fn codegen( // Create free queues and inputs / instants buffers let fq = util::fq_ident(name); + #[allow(clippy::redundant_closure)] let (fq_ty, fq_expr, mk_uninit): (_, _, Box Option<_>>) = { ( quote!(rtic::export::SCFQ<#cap_lit_p1>), diff --git a/macros/src/codegen/util.rs b/macros/src/codegen/util.rs index e865434528..46eace4c39 100644 --- a/macros/src/codegen/util.rs +++ b/macros/src/codegen/util.rs @@ -16,7 +16,7 @@ pub fn capacity_literal(capacity: usize) -> LitInt { /// Identifier for the free queue pub fn fq_ident(task: &Ident) -> Ident { - mark_internal_name(&format!("{}_FQ", task.to_string())) + mark_internal_name(&format!("{}_FQ", task)) } /// Generates a `Mutex` implementation @@ -103,17 +103,12 @@ pub fn mark_internal_name(name: &str) -> Ident { /// Generate an internal identifier for monotonics pub fn internal_monotonics_ident(task: &Ident, monotonic: &Ident, ident_name: &str) -> Ident { - mark_internal_name(&format!( - "{}_{}_{}", - task.to_string(), - monotonic.to_string(), - ident_name, - )) + mark_internal_name(&format!("{}_{}_{}", task, monotonic, ident_name,)) } /// Generate an internal identifier for tasks pub fn internal_task_ident(task: &Ident, ident_name: &str) -> Ident { - mark_internal_name(&format!("{}_{}", task.to_string(), ident_name)) + mark_internal_name(&format!("{}_{}", task, ident_name)) } fn link_section_index() -> usize { @@ -253,26 +248,19 @@ pub fn monotonic_ident(name: &str) -> Ident { } pub fn static_shared_resource_ident(name: &Ident) -> Ident { - mark_internal_name(&format!("shared_resource_{}", name.to_string())) + mark_internal_name(&format!("shared_resource_{}", name)) } pub fn static_local_resource_ident(name: &Ident) -> Ident { - mark_internal_name(&format!("local_resource_{}", name.to_string())) + mark_internal_name(&format!("local_resource_{}", name)) } pub fn declared_static_local_resource_ident(name: &Ident, task_name: &Ident) -> Ident { - mark_internal_name(&format!( - "local_{}_{}", - task_name.to_string(), - name.to_string() - )) + mark_internal_name(&format!("local_{}_{}", task_name, name)) } pub fn need_to_lock_ident(name: &Ident) -> Ident { - Ident::new( - &format!("{}_that_needs_to_be_locked", name.to_string()), - name.span(), - ) + Ident::new(&format!("{}_that_needs_to_be_locked", name), name.span()) } /// The name to get better RT flag errors diff --git a/src/tq.rs b/src/tq.rs index 26ebbd96c3..9033022bcd 100644 --- a/src/tq.rs +++ b/src/tq.rs @@ -71,6 +71,7 @@ where } /// Update the instant at an marker value to a new instant + #[allow(clippy::result_unit_err)] pub fn update_marker( &mut self, marker: u32, From e9675c9a615ac34ce71669a6a5bd8245672b8407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Wed, 9 Feb 2022 18:57:58 +0100 Subject: [PATCH 5/6] Update CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 84b42f2257..e16bb75c2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added +- Cargo clippy in CI +- Use rust-cache Github Action - CI changelog entry enforcer - `examples/periodic-at.rs`, an example of a periodic timer without accumulated drift. - `examples/periodic-at2.rs`, an example of a periodic process with two tasks, with offset timing. Here we depict two alternative usages of the timer type, explicit and trait based. From 578cc903c95aec324733df447cb7f54f41fa1581 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Thu, 10 Feb 2022 09:26:46 +0100 Subject: [PATCH 6/6] Add bors/* to branches --- .github/workflows/build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f0fac75dd5..d69740ba16 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,6 +6,8 @@ on: - master - staging - trying + - bors/staging + - bors/trying env: CARGO_TERM_COLOR: always