diff --git a/.github/bors.toml b/.github/bors.toml deleted file mode 100644 index bb1a0763..00000000 --- a/.github/bors.toml +++ /dev/null @@ -1,11 +0,0 @@ -required_approvals = 1 -block_labels = ["wip"] -delete_merged_branches = true -status = [ - "Rustfmt", - "ci (stm32f100, stable)", - "ci (stm32f101, stable)", - "ci (stm32f103, stable)", - "ci (stm32f105, stable)", - "ci (stm32f107, stable)", -] diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 00000000..c0d72f31 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,19 @@ +on: + pull_request_target: + +name: Changelog check + +jobs: + changelog: + name: Changelog check + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v3 + + - name: Changelog updated + uses: Zomzog/changelog-checker@v1.2.0 + with: + fileName: CHANGELOG.md + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7c930ba2..034cde6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,22 @@ on: push: - branches: [ staging, trying, master ] + branches: master pull_request: + merge_group: name: Continuous integration jobs: ci: + name: CI + runs-on: ubuntu-latest + needs: [check] + if: always() + steps: + - name: Done + run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}' + + check: runs-on: ubuntu-latest strategy: matrix: @@ -33,7 +43,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: check - args: --features=${{ matrix.mcu }},rt --examples + args: --features=${{ matrix.mcu }},rtic,high --examples - uses: actions-rs/cargo@v1 with: diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 628f1166..35c2ea1c 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -1,4 +1,7 @@ -on: [push, pull_request] +on: + push: + branches: master + pull_request: name: Clippy check jobs: diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml index 06d134ce..8b6ecab3 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/rustfmt.yml @@ -1,4 +1,8 @@ -on: [push, pull_request] +on: + push: + branches: master + pull_request: + merge_group: name: Code formatting check diff --git a/CHANGELOG.md b/CHANGELOG.md index 780daf58..43acf6e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +- Move from bors/manual merge to GH merge queue +- Add tools/check.py python script for local check +- Add changelog check on PRs + ## [v0.10.0] - 2022-12-12 - `Timer`: adds `get_interrupt` to `Timer` diff --git a/Cargo.toml b/Cargo.toml index 99e77875..8415a1a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,8 @@ unwrap-infallible = "0.1.5" [features] device-selected = [] doc = [] -rt = ["stm32f1/rt"] +# deprecated feature +rt = [] stm32f100 = ["stm32f1/stm32f100", "device-selected"] stm32f101 = ["stm32f1/stm32f101", "device-selected"] stm32f103 = ["stm32f1/stm32f103", "device-selected", "has-can", "stm32-usbd"] @@ -68,7 +69,7 @@ connectivity = ["medium", "has-can"] # Devices with CAN interface has-can = [] -rtic = ["rt", "rtic-monotonic"] +rtic = ["rtic-monotonic"] [profile.dev] incremental = false @@ -81,23 +82,23 @@ lto = true [[example]] name = "usb_serial" -required-features = ["rt", "stm32-usbd"] +required-features = ["stm32-usbd"] [[example]] name = "usb_serial_interrupt" -required-features = ["rt", "stm32-usbd"] +required-features = ["stm32-usbd"] [[example]] name = "usb_serial_rtic" -required-features = ["rt", "stm32-usbd"] +required-features = ["stm32-usbd"] [[example]] name = "blinky_timer_irq" -required-features = ["rt"] +required-features = [] [[example]] name = "blinky_rtcalarm_irq" -required-features = ["rt"] +required-features = [] [[example]] name = "qei" @@ -105,11 +106,11 @@ required-features = ["medium"] [[example]] name = "timer-interrupt-rtic" -required-features = ["rt", "medium"] +required-features = ["stm32f103", "medium"] [[example]] name = "exti" -required-features = ["rt"] +required-features = [] [[example]] name = "can-echo" @@ -121,7 +122,7 @@ required-features = ["has-can"] [[example]] name = "can-rtic" -required-features = ["has-can", "rt"] +required-features = ["has-can"] [[example]] name = "gpio_input" @@ -129,4 +130,4 @@ required-features = ["stm32f103"] [[example]] name = "serial-interrupt-idle" -required-features = ["stm32f103", "rt", "medium"] +required-features = ["stm32f103", "medium"] diff --git a/examples/serial-interrupt-idle.rs b/examples/serial-interrupt-idle.rs index ac48deca..41af5eef 100644 --- a/examples/serial-interrupt-idle.rs +++ b/examples/serial-interrupt-idle.rs @@ -13,7 +13,7 @@ use stm32f1xx_hal::{ pac::interrupt, pac::USART1, prelude::*, - serial::{Config, Rx, Serial, Tx}, + serial::{Rx, Serial, Tx}, }; static mut RX: Option> = None; @@ -44,14 +44,8 @@ fn main() -> ! { // Set up the usart device. Takes ownership over the USART register and tx/rx pins. The rest of // the registers are used to enable and configure the device. - let (mut tx, mut rx) = Serial::usart1( - p.USART1, - (tx, rx), - &mut afio.mapr, - Config::default().baudrate(115200.bps()), - clocks, - ) - .split(); + let (mut tx, mut rx) = + Serial::new(p.USART1, (tx, rx), &mut afio.mapr, 115200.bps(), &clocks).split(); tx.listen(); rx.listen(); rx.listen_idle(); diff --git a/src/flash.rs b/src/flash.rs index dbd51cde..605eb4ab 100644 --- a/src/flash.rs +++ b/src/flash.rs @@ -112,7 +112,7 @@ impl<'a> FlashWriter<'a> { } fn valid_length(&self, offset: u32, length: usize) -> Result<()> { - if offset + length as u32 > self.flash_sz.kbytes() as u32 { + if offset + length as u32 > self.flash_sz.kbytes() { Err(Error::LengthTooLong) } else if length & 0x1 != 0 { Err(Error::LengthNotMultiple2) @@ -178,7 +178,7 @@ impl<'a> FlashWriter<'a> { let size = self.sector_sz.kbytes() as u32; let start = start_offset & !(size - 1); for idx in (start..start + size).step_by(2) { - let write_address = (FLASH_START + idx as u32) as *const u16; + let write_address = (FLASH_START + idx) as *const u16; let verify: u16 = unsafe { core::ptr::read_volatile(write_address) }; if verify != 0xFFFF { return Err(Error::VerifyError); @@ -209,7 +209,7 @@ impl<'a> FlashWriter<'a> { pub fn read(&self, offset: u32, length: usize) -> Result<&[u8]> { self.valid_address(offset)?; - if offset + length as u32 > self.flash_sz.kbytes() as u32 { + if offset + length as u32 > self.flash_sz.kbytes() { return Err(Error::LengthTooLong); } diff --git a/src/gpio.rs b/src/gpio.rs index 5b89bbee..60535459 100644 --- a/src/gpio.rs +++ b/src/gpio.rs @@ -125,6 +125,9 @@ pub trait GpioExt { fn split(self) -> Self::Parts; /// Splits the GPIO block into independent pins and registers without resetting its state. + /// + /// # Safety + /// Make sure that all pins modes are set in reset state. unsafe fn split_without_reset(self) -> Self::Parts; } diff --git a/src/timer.rs b/src/timer.rs index 8b0903a3..7faa1e7a 100644 --- a/src/timer.rs +++ b/src/timer.rs @@ -62,9 +62,8 @@ use crate::time::Hertz; pub mod monotonic; #[cfg(feature = "rtic")] pub use monotonic::*; -pub mod pwm_input; -pub use pwm_input::*; pub(crate) mod pins; +pub mod pwm_input; pub use pins::*; pub mod delay; pub use delay::*; diff --git a/tools/check.py b/tools/check.py new file mode 100755 index 00000000..939d221c --- /dev/null +++ b/tools/check.py @@ -0,0 +1,50 @@ +#! /usr/bin/env python3 + +import json +import subprocess +import sys + + +def run_inner(args): + print("Running `{}`...".format(" ".join(args))) + ret = subprocess.call(args) == 0 + print("") + return ret + + +def run(mcu, cargo_cmd): + if mcu == "": + return run_inner(cargo_cmd) + else: + return run_inner(cargo_cmd + ["--features={}".format(mcu)]) + + +def main(): + cargo_meta = json.loads( + subprocess.check_output("cargo metadata --no-deps --format-version=1", + shell=True, + universal_newlines=True) + ) + + crate_info = cargo_meta["packages"][0] + + features = ["{},rtic,high".format(x) + for x in crate_info["features"].keys() + if x.startswith("stm32f1")] + + if 'size_check' in sys.argv: + cargo_cmd = ['cargo', 'build', '--release'] + else: + cargo_cmd = ['cargo', 'check'] + + if '--examples' in sys.argv: + cargo_cmd += ['--examples'] + + if not all(map(lambda f: run(f, cargo_cmd), + features)): + sys.exit(-1) + + +if __name__ == "__main__": + main() +