Skip to content

Simplify CI & expand coverage #1044

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

Merged
merged 12 commits into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
392 changes: 79 additions & 313 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

74 changes: 74 additions & 0 deletions .github/workflows/clippy-check-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: check-clippy-examples
on:
workflow_call:
inputs:
backend:
description: The backend to execute for
required: true
type: string

platform:
description: The platform to execute for
required: true
type: string

# TODO: get this from `cargo xtask`!
rustup-target:
description: The rustup target to install
required: true
type: string

example-args:
description: Extra args to pass when checking examples
required: false
type: string

jobs:
check:
runs-on: ubuntu-22.04
name: Validate platform ${{ inputs.platform }}, backend ${{ inputs.backend }}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure Rust target ${{ inputs.rustup-target }}
run: rustup target add ${{ inputs.rustup-target }}

- name: Cache Dependencies
uses: Swatinem/rust-cache@v2

- run: cargo xtask --deny-warnings check -p ${{ inputs.platform }} -b ${{ inputs.backend }}

check-examples:
runs-on: ubuntu-22.04
name: Check examples
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure Rust target ${{ inputs.rustup-target }}
run: rustup target add ${{ inputs.rustup-target }}

- name: Cache Dependencies
uses: Swatinem/rust-cache@v2

- name: Check the examples
run: cargo xtask example-check --platform ${{ inputs.platform }} --backend ${{ inputs.backend }} ${{ inputs.example-args }}

clippy:
runs-on: ubuntu-22.04
name: Run clippy
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Configure Rust target ${{ inputs.rustup-target }}
run: rustup target add ${{ inputs.rustup-target }}

- name: Add Rust component clippy
run: rustup component add clippy

- name: Cache Dependencies
uses: Swatinem/rust-cache@v2

- run: cargo xtask --deny-warnings --platform ${{ inputs.platform }} --backend ${{ inputs.backend }} clippy
7 changes: 4 additions & 3 deletions rtic-macros/src/codegen/bindings/esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pub use esp32c3::*;

#[cfg(feature = "riscv-esp32c3")]
#[allow(clippy::module_inception)]
mod esp32c3 {
use crate::{
analyze::Analysis as CodegenAnalysis,
Expand Down Expand Up @@ -92,7 +93,7 @@ mod esp32c3 {
for (&priority, name) in interrupt_ids.chain(
app.hardware_tasks
.values()
.filter_map(|task| Some((&task.args.priority, &task.args.binds))),
.map(|task| (&task.args.priority, &task.args.binds)),
) {
let es = format!(
"Maximum priority used by interrupt vector '{name}' is more than supported by hardware"
Expand Down Expand Up @@ -207,7 +208,7 @@ mod esp32c3 {
stmts
}

pub fn async_prio_limit(app: &App, analysis: &CodegenAnalysis) -> Vec<TokenStream2> {
pub fn async_prio_limit(_app: &App, analysis: &CodegenAnalysis) -> Vec<TokenStream2> {
let max = if let Some(max) = analysis.max_async_prio {
quote!(#max)
} else {
Expand All @@ -232,7 +233,7 @@ mod esp32c3 {
for (_, name) in interrupt_ids.chain(
app.hardware_tasks
.values()
.filter_map(|task| Some((&task.args.priority, &task.args.binds))),
.map(|task| (&task.args.priority, &task.args.binds)),
) {
if *name == dispatcher_name {
let ret = &("interrupt".to_owned() + &curr_cpu_id.to_string());
Expand Down
6 changes: 3 additions & 3 deletions rtic-monotonics/src/esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ impl TimerBackend {
/// Use the prelude macros instead.
pub fn _start(timer: SYSTIMER) {
const INTERRUPT_MAP_BASE: u32 = 0x600c2000;
let interrupt_number = 37 as isize;
let cpu_interrupt_number = 31 as isize;
let interrupt_number = 37isize;
let cpu_interrupt_number = 31isize;
unsafe {
let intr_map_base = INTERRUPT_MAP_BASE as *mut u32;
intr_map_base
Expand All @@ -65,7 +65,7 @@ impl TimerBackend {

intr_prio_base
.offset(cpu_interrupt_number)
.write_volatile(15 as u32);
.write_volatile(15);
}
timer.conf().write(|w| w.timer_unit0_work_en().set_bit());
timer
Expand Down
1 change: 1 addition & 0 deletions rtic/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Example:

### Changed

- Placate clippy
- Updated esp32c3 dependency to v0.27.0

### Added
Expand Down
2 changes: 1 addition & 1 deletion rtic/src/export/riscv_common.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/// GENERIC RE-EXPORTS: needed for all RTIC backends
//! GENERIC RE-EXPORTS: needed for all RTIC backends

/// Read the stack pointer.
#[inline(always)]
Expand Down
3 changes: 1 addition & 2 deletions rtic/src/export/riscv_esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ where
pub unsafe fn lock<T, R>(ptr: *mut T, ceiling: u8, f: impl FnOnce(&mut T) -> R) -> R {
if ceiling == (15) {
//turn off interrupts completely, were at max prio
let r = critical_section::with(|_| f(&mut *ptr));
r
critical_section::with(|_| f(&mut *ptr))
} else {
let current = unsafe {
(*INTERRUPT_CORE0::ptr())
Expand Down
101 changes: 61 additions & 40 deletions xtask/src/argument_parsing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,47 +63,26 @@ impl Package {
vec![Some(backend.to_rtic_macros_feature().to_string())]
}
Package::RticMonotonics => {
let features = if partial {
&[
"cortex-m-systick",
"rp2040",
"nrf52840",
"imxrt_gpt1,imxrt-ral/imxrt1062",
"stm32_tim2,stm32h725ag",
][..]
let features = backend.to_rtic_monotonics_features(partial);

if let Some(features) = features {
features
.iter()
.map(|&s| {
if matches!(backend, Backends::Thumbv6) {
format!("{s},portable-atomic/critical-section")
} else {
s.to_string()
}
})
.map(Some)
.chain(std::iter::once(None))
.collect()
} else {
&[
"cortex-m-systick",
"cortex-m-systick,systick-64bit",
"rp2040",
"nrf52805",
"nrf52810",
"nrf52811",
"nrf52832",
"nrf52833",
"nrf52840",
"nrf5340-app",
"nrf5340-net",
"nrf9160",
"imxrt_gpt1,imxrt_gpt2,imxrt-ral/imxrt1062",
"stm32_tim2,stm32_tim3,stm32_tim4,stm32_tim5,stm32_tim15,stm32h725ag",
][..]
};

features
.iter()
.map(|&s| {
if matches!(backend, Backends::Thumbv6) {
format!("{s},portable-atomic/critical-section")
} else {
s.to_string()
}
})
.map(Some)
.chain(std::iter::once(None))
.collect()
vec![None]
}
}
Package::RticSync if matches!(backend, Backends::Thumbv6) => {
Package::RticSync if matches!(backend, Backends::Thumbv6) || !backend.is_arm() => {
vec![Some("portable-atomic/critical-section".into())]
}
_ => vec![None],
Expand Down Expand Up @@ -159,7 +138,7 @@ impl TestMetadata {
}
}

#[derive(clap::ValueEnum, Copy, Clone, Default, Debug)]
#[derive(clap::ValueEnum, Copy, Clone, Default, Debug, PartialEq)]
pub enum Backends {
Thumbv6,
#[default]
Expand Down Expand Up @@ -200,6 +179,7 @@ impl Backends {
Backends::Riscv32ImcMecall | Backends::Riscv32ImacMecall => "riscv-mecall-backend",
}
}

#[allow(clippy::wrong_self_convention)]
pub fn to_rtic_macros_feature(&self) -> &'static str {
match self {
Expand All @@ -210,6 +190,47 @@ impl Backends {
Backends::Riscv32ImcMecall | Backends::Riscv32ImacMecall => "riscv-mecall",
}
}

#[allow(clippy::wrong_self_convention)]
pub fn to_rtic_monotonics_features(&self, partial: bool) -> Option<&[&str]> {
if self == &Self::RiscvEsp32C3 {
Some(&["esp32c3-systimer"])
} else if !self.is_arm() {
None
} else if partial {
Some(&[
"cortex-m-systick",
"rp2040",
"nrf52840",
"imxrt_gpt1,imxrt-ral/imxrt1062",
"stm32_tim2,stm32h725ag",
])
} else {
Some(&[
"cortex-m-systick",
"cortex-m-systick,systick-64bit",
"rp2040",
"nrf52805",
"nrf52810",
"nrf52811",
"nrf52832",
"nrf52833",
"nrf52840",
"nrf5340-app",
"nrf5340-net",
"nrf9160",
"imxrt_gpt1,imxrt_gpt2,imxrt-ral/imxrt1062",
"stm32_tim2,stm32_tim3,stm32_tim4,stm32_tim5,stm32_tim15,stm32h725ag",
])
}
}

pub fn is_arm(&self) -> bool {
matches!(
self,
Self::Thumbv6 | Self::Thumbv7 | Self::Thumbv8Base | Self::Thumbv8Main
)
}
}

#[derive(Copy, Clone, Default, Debug)]
Expand Down
Loading