Skip to content

Commit

Permalink
CI update (#655)
Browse files Browse the repository at this point in the history
- Rework crates.json
- Build the HAL for every PAC with every relevant feature
- Remove deprecated actions-rs workflows
- Deny clippy errors but allow warnings
  • Loading branch information
sajattack authored Dec 31, 2022
1 parent 14295b3 commit bd065f7
Show file tree
Hide file tree
Showing 12 changed files with 283 additions and 144 deletions.
2 changes: 1 addition & 1 deletion .github/actions/list-BSPs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ runs:
shell: bash
run: |
matrix_json=$(cat crates.json | jq -Mr -c '{ "bsp": (.boards | keys ), "toolchain": ["stable", "nightly"] }')
echo "::set-output name=matrix::${matrix_json}"
echo "matrix=${matrix_json}" >> $GITHUB_OUTPUT
17 changes: 17 additions & 0 deletions .github/actions/list-HAL-variants/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: 'Compute HAL matrix'
description: 'Prepares the build environment'

outputs:
matrix:
description: "HAL Build matrix"
value: ${{ steps.compute-matrix.outputs.matrix }}
runs:
using: "composite"
steps:
- run: sudo apt-get install -y jq
shell: bash
- id: compute-matrix
shell: bash
run: |
matrix_json=$(cat crates.json | jq -Mr -c '{ "pac": (.hal_build_variants | keys ), "toolchain": ["stable", "nightly"] }')
echo "matrix=${matrix_json}" >> $GITHUB_OUTPUT
5 changes: 4 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@

## If Adding a new Board
- [ ] Board CI added to `crates.json`
- [ ] Board is properly following "Tier 2" conventions, unless otherwise decided to be "Tier 1"
- [ ] Board is properly following "Tier 2" conventions, unless otherwise decided to be "Tier 1"

## If Adding a new cargo `feature` to the HAL
- [ ] Feature is added to the test matrix for applicable boards / PACs in `crates.json`
60 changes: 19 additions & 41 deletions .github/workflows/build-bsp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout sources
uses: actions/checkout@v2
uses: actions/checkout@v3
- id: set-matrix
uses: ./.github/actions/list-BSPs

Expand All @@ -20,53 +20,31 @@ jobs:
matrix: ${{fromJson(needs.setup.outputs.matrix)}}
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install Rust (thumbv6m)
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true
target: thumbv6m-none-eabi
components: clippy
- name: Install Rust (thumbv7em)
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.toolchain }}
override: true
target: thumbv7em-none-eabihf
components: clippy
uses: actions/checkout@v3

- name: Test ${{ matrix.bsp }}
- name: Install Rust
run: |
rustup set profile minimal
rustup override set ${{ matrix.toolchain }}
target=$(cat ./crates.json | jq -Mr --arg board '${{ matrix.bsp }}' -c '.boards | .[$board] | .target')
rustup target add ${target}
rustup component add clippy
- name: Setup cache
uses: Swatinem/rust-cache@v2

- name: Build ${{ matrix.bsp }}
run: |
build_invocation=$(cat ./crates.json | jq -Mr --arg board '${{ matrix.bsp }}' -c '.boards | .[$board] | .build')
set -ex
cd boards/${{ matrix.bsp }}
$(${build_invocation})
- uses: actions-rs/clippy-check@v1
- name: Clippy ${{ matrix.bsp }}
if: ${{ matrix.toolchain == 'nightly' }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Clippy ${{ matrix.bsp }}
args: --all-features --manifest-path=boards/${{ matrix.bsp }}/Cargo.toml

build_hal:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install Rust (thumbv6m)
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: thumbv6m-none-eabi
components: clippy
- name: Build HAL
run: |
set -ex
cd hal
cargo build --features="library"
build_invocation=$(cat ./crates.json | jq -Mr --arg board '${{ matrix.bsp }}' -c '.boards | .[$board] | .build')
clippy_invocation=$(echo ${build_invocation} | sed 's/cargo build/cargo clippy/g')
cd boards/${{ matrix.bsp }}
$(${clippy_invocation})
49 changes: 49 additions & 0 deletions .github/workflows/build-hal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Build HAL
on: [push, pull_request]

jobs:
setup:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout sources
uses: actions/checkout@v3
- id: set-matrix
uses: ./.github/actions/list-HAL-variants

build:
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.toolchain == 'nightly' }}
needs: setup
strategy:
matrix: ${{fromJson(needs.setup.outputs.matrix)}}
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install Rust
run: |
rustup set profile minimal
rustup override set ${{ matrix.toolchain }}
target=$(cat ./crates.json | jq -Mr --arg pac "${{matrix.pac}}" -c '.hal_build_variants["${{matrix.pac}}"].target')
rustup target add ${target}
rustup component add clippy
- name: Setup cache
uses: Swatinem/rust-cache@v2

- name: Build HAL for ${{ matrix.pac }}
run: |
set -ex
features=$(cat ./crates.json | jq -Mr --arg pac "${{matrix.pac}}" -c '.hal_build_variants["${{matrix.pac}}"].features | join(",")')
target=$(cat ./crates.json | jq -Mr --arg pac "${{matrix.pac}}" -c '.hal_build_variants["${{matrix.pac}}"].target')
cargo build --features=${features} --target=${target} --manifest-path=./hal/Cargo.toml
- name: Clippy HAL for ${{ matrix.pac }}
if: ${{ matrix.toolchain == 'nightly' }}
run: |
set -ex
features=$(cat ./crates.json | jq -Mr --arg pac "${{matrix.pac}}" -c '.hal_build_variants["${{matrix.pac}}"].features | join(",")')
target=$(cat ./crates.json | jq -Mr --arg pac "${{matrix.pac}}" -c '.hal_build_variants["${{matrix.pac}}"].target')
cargo clippy --features=${features} --target=${target} --manifest-path=./hal/Cargo.toml
8 changes: 5 additions & 3 deletions .github/workflows/bump-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@v2
run: |
rustup set profile minimal
rustup override set stable
- uses: actions/checkout@v3
- name: Setup
shell: bash
run: |
Expand Down Expand Up @@ -108,7 +110,7 @@ jobs:
git diff > bump.patch
- name: Upload diff
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: bump.patch
path: bump.patch
Expand Down
23 changes: 8 additions & 15 deletions .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Install Rust (thumbv6m)
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: thumbv6m-none-eabi
- name: Install Rust (thumbv7em)
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
target: thumbv7em-none-eabihf
uses: actions/checkout@v3

- name: Install Rust
run: |
rustup set profile minimal
rustup override set ${{ matrix.toolchain }}
rustup target add thumbv6m-none-eabi
rustup target add thumbv7em-none-eabihf
- name: Generate HAL docs
if: github.event.inputs.gen_hal_docs == 'yes'
Expand Down
24 changes: 6 additions & 18 deletions .github/workflows/release-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,12 @@ jobs:
release-crates:
runs-on: ubuntu-latest
steps:
- name: Set up Rust
uses: hecrj/setup-rust-action@v1
- uses: actions/checkout@v2
- name: Install thumbv6m
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
toolchain: stable
target: thumbv6m-none-eabi
- name: Install thumbv7em
uses: actions-rs/toolchain@v1
with:
profile: minimal
override: true
toolchain: stable
target: thumbv7em-none-eabihf

- name: Install Rust
run: |
rustup set profile minimal
rustup override set stable
rustup target add thumbv6m-none-eabi
rustup target add thumbv7em-none-eabihf
- name: Login
run: cargo login ${CRATES_IO_TOKEN}
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/rustfmt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: rustfmt
override: true
- run: ./rustfmt.sh
- name: Checkout sources
uses: actions/checkout@v3
- name: Install Rust
run: |
rustup set profile minimal
rustup override set nightly
rustup component add rustfmt
- name: Rustfmt
run: ./rustfmt.sh
16 changes: 3 additions & 13 deletions boards/edgebadge/examples/neopixel_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,19 +50,15 @@ fn main() -> ! {
for event in buttons.events() {
match event {
Keys::LeftDown => {
if pos_joy > 0 {
pos_joy -= 1;
}
pos_joy = pos_joy.saturating_sub(1);
}
Keys::RightDown => {
if pos_joy < 4 {
pos_joy += 1;
}
}
Keys::BDown => {
if pos_button > 0 {
pos_button -= 1;
}
pos_button = pos_button.saturating_sub(1);
}
Keys::ADown => {
if pos_button < 4 {
Expand All @@ -75,13 +71,7 @@ fn main() -> ! {

//finally paint the two leds at position, accel priority
let _ = neopixel.write((0..NUM_LEDS).map(|i| {
if i == pos_joy {
hsv2rgb(Hsv {
hue: color_button,
sat: 255,
val: 32,
})
} else if i == pos_button {
if i == pos_joy || i == pos_button {
hsv2rgb(Hsv {
hue: color_button,
sat: 255,
Expand Down
6 changes: 2 additions & 4 deletions boards/edgebadge/examples/neopixel_tilt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ impl TiltState {
if self.pos > 0 {
self.pos -= 1;
}
} else {
if self.pos < 4 {
self.pos += 1;
}
} else if self.pos < 4 {
self.pos += 1;
}
self.tilt = 0;
}
Expand Down
Loading

0 comments on commit bd065f7

Please sign in to comment.