605: GHA: Tune CI r=AfoHT a=AfoHT

- GHA: Use rust-cache
- GHA: Cleanup single target jobs
- GHA: Add cargo clippy


Co-authored-by: Henrik Tjäder <henrik@grepit.se>
This commit is contained in:
bors[bot] 2022-02-10 08:36:43 +00:00 committed by GitHub
commit e65ca34471
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 195 deletions

View file

@ -6,6 +6,8 @@ on:
- master - master
- staging - staging
- trying - trying
- bors/staging
- bors/trying
env: env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
@ -17,7 +19,7 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v2
- name: Install Rust - name: Install Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
@ -52,28 +54,6 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 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 }}) - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -84,6 +64,9 @@ jobs:
- name: Fail on warnings - name: Fail on warnings
run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs 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 - name: cargo check
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
@ -91,6 +74,33 @@ jobs:
command: check command: check
args: --target=${{ matrix.target }} 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 # Verify all examples, checks
checkexamples: checkexamples:
name: checkexamples name: checkexamples
@ -106,28 +116,6 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 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 }}) - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -136,8 +124,10 @@ jobs:
override: true override: true
components: llvm-tools-preview components: llvm-tools-preview
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1
- name: Check the examples - name: Check the examples
if: matrix.target == 'thumbv7m-none-eabi'
uses: actions-rs/cargo@v1 uses: actions-rs/cargo@v1
with: with:
use-cross: false use-cross: false
@ -159,28 +149,6 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 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 }}) - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -197,6 +165,9 @@ jobs:
version: latest version: latest
use-tool-cache: true use-tool-cache: true
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1
- name: Install QEMU - name: Install QEMU
run: | run: |
sudo apt update sudo apt update
@ -223,28 +194,6 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 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 }}) - name: Install Rust ${{ matrix.toolchain }} with target (${{ matrix.target }})
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
@ -252,6 +201,9 @@ jobs:
target: ${{ matrix.target }} target: ${{ matrix.target }}
override: true override: true
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1
- name: Fail on warnings - name: Fail on warnings
run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs
@ -266,45 +218,20 @@ jobs:
testmacros: testmacros:
name: testmacros name: testmacros
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
toolchain:
- stable
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Cache cargo dependencies - name: Install Rust
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 uses: actions-rs/toolchain@v1
with: with:
toolchain: ${{ matrix.toolchain }} toolchain: stable
target: ${{ matrix.target }} target: x86_64-unknown-linux-gnu
override: true override: true
- name: Cache Dependencies
uses: Swatinem/rust-cache@v1
- name: Fail on warnings - name: Fail on warnings
run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs run: sed -i 's,//deny_warnings_placeholder_for_ci,#![deny(warnings)],' src/lib.rs macros/src/lib.rs
@ -313,84 +240,43 @@ jobs:
with: with:
use-cross: false use-cross: false
command: test 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: tests:
name: tests name: tests
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
toolchain:
- stable
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 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 - name: Install Rust
uses: actions-rs/toolchain@v1 uses: actions-rs/toolchain@v1
with: with:
toolchain: ${{ matrix.toolchain }} toolchain: stable
target: ${{ matrix.target }} target: x86_64-unknown-linux-gnu
override: true 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 - uses: actions-rs/cargo@v1
with: with:
use-cross: false use-cross: false
command: test command: test
args: --test tests --target=${{ matrix.target }} args: --test tests
# Build documentation, check links # Build documentation, check links
docs: docs:
name: docs name: docs
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v2 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 - name: Cache pip installed linkchecker
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
@ -453,7 +339,7 @@ jobs:
run: pip install git+https://github.com/linkchecker/linkchecker.git run: pip install git+https://github.com/linkchecker/linkchecker.git
- name: mdBook Action - name: mdBook Action
uses: peaceiris/actions-mdbook@v1.1.13 uses: peaceiris/actions-mdbook@v1
with: with:
mdbook-version: 'latest' mdbook-version: 'latest'
@ -509,7 +395,7 @@ jobs:
run: python -c "import sys; print(sys.version)" run: python -c "import sys; print(sys.version)"
- name: mdBook Action - name: mdBook Action
uses: peaceiris/actions-mdbook@v1.1.13 uses: peaceiris/actions-mdbook@v1
with: with:
mdbook-version: 'latest' mdbook-version: 'latest'
@ -610,6 +496,7 @@ jobs:
needs: needs:
- style - style
- check - check
- clippy
- checkexamples - checkexamples
- testexamples - testexamples
- checkmacros - checkmacros

View file

@ -7,6 +7,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Added ### Added
- Cargo clippy in CI
- Use rust-cache Github Action
- CI changelog entry enforcer - CI changelog entry enforcer
- `examples/periodic-at.rs`, an example of a periodic timer without accumulated drift. - `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. - `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.

View file

@ -269,7 +269,7 @@ pub fn codegen(
let m_ident = util::monotonic_ident(&monotonic_name); let m_ident = util::monotonic_ident(&monotonic_name);
let m_isr = &monotonic.args.binds; let m_isr = &monotonic.args.binds;
let enum_ = util::interrupt_ident(); 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" { let (enable_interrupt, pend) = if &*m_isr.to_string() == "SysTick" {
( (

View file

@ -38,6 +38,7 @@ pub fn codegen(
// Create free queues and inputs / instants buffers // Create free queues and inputs / instants buffers
let fq = util::fq_ident(name); let fq = util::fq_ident(name);
#[allow(clippy::redundant_closure)]
let (fq_ty, fq_expr, mk_uninit): (_, _, Box<dyn Fn() -> Option<_>>) = { let (fq_ty, fq_expr, mk_uninit): (_, _, Box<dyn Fn() -> Option<_>>) = {
( (
quote!(rtic::export::SCFQ<#cap_lit_p1>), quote!(rtic::export::SCFQ<#cap_lit_p1>),

View file

@ -16,7 +16,7 @@ pub fn capacity_literal(capacity: usize) -> LitInt {
/// Identifier for the free queue /// Identifier for the free queue
pub fn fq_ident(task: &Ident) -> Ident { 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 /// Generates a `Mutex` implementation
@ -103,17 +103,12 @@ pub fn mark_internal_name(name: &str) -> Ident {
/// Generate an internal identifier for monotonics /// Generate an internal identifier for monotonics
pub fn internal_monotonics_ident(task: &Ident, monotonic: &Ident, ident_name: &str) -> Ident { pub fn internal_monotonics_ident(task: &Ident, monotonic: &Ident, ident_name: &str) -> Ident {
mark_internal_name(&format!( mark_internal_name(&format!("{}_{}_{}", task, monotonic, ident_name,))
"{}_{}_{}",
task.to_string(),
monotonic.to_string(),
ident_name,
))
} }
/// Generate an internal identifier for tasks /// Generate an internal identifier for tasks
pub fn internal_task_ident(task: &Ident, ident_name: &str) -> Ident { 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 { 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 { 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 { 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 { pub fn declared_static_local_resource_ident(name: &Ident, task_name: &Ident) -> Ident {
mark_internal_name(&format!( mark_internal_name(&format!("local_{}_{}", task_name, name))
"local_{}_{}",
task_name.to_string(),
name.to_string()
))
} }
pub fn need_to_lock_ident(name: &Ident) -> Ident { pub fn need_to_lock_ident(name: &Ident) -> Ident {
Ident::new( Ident::new(&format!("{}_that_needs_to_be_locked", name), name.span())
&format!("{}_that_needs_to_be_locked", name.to_string()),
name.span(),
)
} }
/// The name to get better RT flag errors /// The name to get better RT flag errors

View file

@ -71,6 +71,7 @@ where
} }
/// Update the instant at an marker value to a new instant /// Update the instant at an marker value to a new instant
#[allow(clippy::result_unit_err)]
pub fn update_marker<F: FnOnce()>( pub fn update_marker<F: FnOnce()>(
&mut self, &mut self,
marker: u32, marker: u32,