From 2379d33b26371dc5c7327e789f8622b204946c81 Mon Sep 17 00:00:00 2001 From: Jan Teske Date: Fri, 24 Jul 2020 20:05:15 +0200 Subject: [PATCH 1/6] Add GitHub Actions CI configuration --- .github/workflows/ci.yml | 83 ++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 6 ++- 2 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..e9c3c54ff --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,83 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + +jobs: + check: + name: Check + runs-on: ubuntu-latest + strategy: + matrix: + mcu: + - stm32f301 + - stm32f318 + - stm32f302xb + - stm32f302xc + - stm32f302xd + - stm32f302xe + - stm32f303xb + - stm32f303xc + - stm32f303xd + - stm32f303xe + - stm32f303x6 + - stm32f303x8 + - stm32f373 + - stm32f378 + - stm32f334 + - stm32f328 + - stm32f358 + - stm32f398 + features: ["rt"] + include: + - mcu: stm32f303xc + features: rt,stm32-usbd + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: thumbv7em-none-eabihf + override: true + profile: minimal + - uses: actions-rs/cargo@v1 + with: + command: check + args: --features=${{ matrix.mcu }},${{ matrix.features }} + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + target: thumbv7em-none-eabihf + override: true + profile: minimal + components: clippy + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: > + --features=stm32f303xc,rt,stm32-usbd --examples + -- -D warnings + + rustfmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + profile: minimal + components: rustfmt + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check diff --git a/Cargo.toml b/Cargo.toml index e5863ad57..0d29f4473 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,10 +53,13 @@ cortex-m-semihosting = "0.3" [features] default = ["unproven"] +unproven = ["embedded-hal/unproven"] device-selected = [] direct-call-deprecated = [] rt = ["stm32f3/rt"] -# Any Changes here should be mirrored in README.md and src/lib.rs + +# Any Changes here should be mirrored in README.md, src/lib.rs, and +# .github/workflows/ci.yml. stm32f301 = ["stm32f3/stm32f301", "device-selected"] stm32f318 = ["stm32f3/stm32f301", "device-selected"] stm32f302 = ["stm32f3/stm32f302", "direct-call-deprecated"] @@ -77,7 +80,6 @@ stm32f334 = ["stm32f3/stm32f3x4", "device-selected"] stm32f328 = ["stm32f3/stm32f3x8", "device-selected"] stm32f358 = ["stm32f3/stm32f3x8", "device-selected"] stm32f398 = ["stm32f3/stm32f3x8", "device-selected"] -unproven = ["embedded-hal/unproven"] [profile.dev] debug = true From d4d93d17c24f44d6cc8dd4afb32001c278df76d7 Mon Sep 17 00:00:00 2001 From: Jan Teske Date: Fri, 24 Jul 2020 20:41:14 +0200 Subject: [PATCH 2/6] Fix clippy warnings --- examples/spi.rs | 4 ++-- src/i2c.rs | 3 +-- src/serial.rs | 3 +-- src/spi.rs | 3 +-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/examples/spi.rs b/examples/spi.rs index 1edaa9c74..30a076aa2 100644 --- a/examples/spi.rs +++ b/examples/spi.rs @@ -49,9 +49,9 @@ fn main() -> ! { // Create an `u8` array, which can be transfered via SPI. let msg_send: [u8; 8] = [0xD, 0xE, 0xA, 0xD, 0xB, 0xE, 0xE, 0xF]; - // Clone the array, as it would be mutually shared in `transfer` while simultaniously would be + // Copy the array, as it would be mutually shared in `transfer` while simultaneously would be // immutable shared in `assert_eq`. - let mut msg_sending = msg_send.clone(); + let mut msg_sending = msg_send; // Transfer the content of the array via SPI and receive it's output. // When MOSI and MISO pins are connected together, `msg_received` should receive the content. // from `msg_sending` diff --git a/src/i2c.rs b/src/i2c.rs index a2bc249ae..98a4e6eb6 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -27,6 +27,7 @@ use crate::time::Hertz; /// I2C error #[derive(Debug)] +#[non_exhaustive] pub enum Error { /// Bus error Bus, @@ -36,8 +37,6 @@ pub enum Error { // Pec, // SMBUS mode only // Timeout, // SMBUS mode only // Alert, // SMBUS mode only - #[doc(hidden)] - _Extensible, } // FIXME these should be "closed" traits diff --git a/src/serial.rs b/src/serial.rs index 321cc93b9..3597c1e27 100644 --- a/src/serial.rs +++ b/src/serial.rs @@ -52,6 +52,7 @@ pub enum Event { /// Serial error #[derive(Debug)] +#[non_exhaustive] pub enum Error { /// Framing error Framing, @@ -61,8 +62,6 @@ pub enum Error { Overrun, /// Parity check error Parity, - #[doc(hidden)] - _Extensible, } // FIXME these should be "closed" traits diff --git a/src/spi.rs b/src/spi.rs index e148130bf..b6d0e74e5 100644 --- a/src/spi.rs +++ b/src/spi.rs @@ -49,6 +49,7 @@ use crate::time::Hertz; /// SPI error #[derive(Debug)] +#[non_exhaustive] pub enum Error { /// Overrun occurred Overrun, @@ -56,8 +57,6 @@ pub enum Error { ModeFault, /// CRC error Crc, - #[doc(hidden)] - _Extensible, } // FIXME these should be "closed" traits From 68d03a6a562a5f1d377f9ac5377b71366cf4b15c Mon Sep 17 00:00:00 2001 From: Jan Teske Date: Fri, 24 Jul 2020 21:14:23 +0200 Subject: [PATCH 3/6] ci: Use checkout@v1 action The checkout@v2 action currently has a bug that makes it sometimes check out the wrong commit. Since we can't have that we'll use v1 for now, until that is fixed. --- .github/workflows/ci.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e9c3c54ff..3ff1c79e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,3 +1,7 @@ +# Note: The checkout@v2 action sometimes checks out the wrong commit: +# https://github.com/actions/checkout/issues/237 +# Until that is fixed we use checkout@v1 here instead. + name: CI on: @@ -35,7 +39,7 @@ jobs: - mcu: stm32f303xc features: rt,stm32-usbd steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: toolchain: stable @@ -51,7 +55,7 @@ jobs: name: Clippy runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: toolchain: nightly @@ -70,7 +74,7 @@ jobs: name: Rustfmt runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v1 - uses: actions-rs/toolchain@v1 with: toolchain: stable From aa1f30e856d677e7521be020010ce3299143fa17 Mon Sep 17 00:00:00 2001 From: Jan Teske Date: Fri, 24 Jul 2020 21:38:37 +0200 Subject: [PATCH 4/6] Remove Travis-based CI --- .travis.yml | 18 ------------------ Cargo.toml | 3 --- README.md | 2 +- ci/build.py | 48 ------------------------------------------------ 4 files changed, 1 insertion(+), 70 deletions(-) delete mode 100644 .travis.yml delete mode 100755 ci/build.py diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ecf70c1c1..000000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: rust - -rust: - - stable - - nightly - -matrix: - allow_failures: - - rust: nightly - fast_finish: true - -install: - - rustup target add thumbv7em-none-eabihf - - rustup component add rustfmt - -script: - - ci/build.py - - cargo fmt -- --check diff --git a/Cargo.toml b/Cargo.toml index 0d29f4473..ffa669625 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,9 +15,6 @@ version = "0.5.0" features = ["stm32f303xc", "rt", "stm32-usbd"] targets = ["thumbv7em-none-eabihf"] -[badges] -travis-ci = { repository = "stm32-rs/stm32f3xx-hal" } - [dependencies] cortex-m = "0.6" cortex-m-rt = "0.6" diff --git a/README.md b/README.md index a6b027579..d6e817085 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # stm32f3xx-hal -[![Build Status](https://travis-ci.com/stm32-rs/stm32f3xx-hal.svg)](https://travis-ci.com/stm32-rs/stm32f3xx-hal) +[![Build Status](https://github.com/stm32-rs/stm32f3xx-hal/workflows/CI/badge.svg)](https://github.com/stm32-rs/stm32f3xx-hal/actions) [![Crate](https://img.shields.io/crates/v/stm32f3xx-hal.svg)](https://crates.io/crates/stm32f3xx-hal) [![Docs](https://docs.rs/stm32f3xx-hal/badge.svg)](https://docs.rs/stm32f3xx-hal) diff --git a/ci/build.py b/ci/build.py deleted file mode 100755 index 03427544f..000000000 --- a/ci/build.py +++ /dev/null @@ -1,48 +0,0 @@ -#!/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 = [ - "{},rt".format(feature) - for feature, derived in crate_info["features"].items() - if "device-selected" in derived - ] - - cargo_build_cmd = ['cargo', 'build', '--verbose'] - - cargo_build_examples_cmd = ['cargo', 'build', '--examples', '--verbose'] - - if not all(map(lambda f: run(f, cargo_build_cmd), features)): - sys.exit(-1) - - if not all(map(lambda f: run(f, cargo_build_examples_cmd), features)): - sys.exit(-1) - - -if __name__ == "__main__": - main() From 7568897457fb9be922684ce643722b1ff2a21000 Mon Sep 17 00:00:00 2001 From: Jan Teske Date: Fri, 24 Jul 2020 22:33:57 +0200 Subject: [PATCH 5/6] Remove default Rust GHA workflow --- .github/workflows/rust.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .github/workflows/rust.yml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index 3c13d1be2..000000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Rust - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v2 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose From ee261b4d686c0db06d63dc34c91c326b90bf5613 Mon Sep 17 00:00:00 2001 From: Jan Teske Date: Sat, 25 Jul 2020 20:37:55 +0200 Subject: [PATCH 6/6] ci: Make check run on examples too --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3ff1c79e3..f018040e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ jobs: - uses: actions-rs/cargo@v1 with: command: check - args: --features=${{ matrix.mcu }},${{ matrix.features }} + args: --features=${{ matrix.mcu }},${{ matrix.features }} --examples clippy: name: Clippy