Skip to content
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

feat: add CI workflows #11

Merged
merged 2 commits into from
Sep 4, 2024
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
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build

on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
branches:
- main

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: --deny warnings

jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
commits: ${{ steps.commits.outputs.hashes }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Get all commit hashes
id: commits
run: |
echo "hashes=[$(git log -z --pretty=format:"'%H'," ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | sed 's/.$//')]" >> "$GITHUB_OUTPUT"
build:
name: Build
needs: generate-matrix
strategy:
matrix:
commit: ${{ fromJson(needs.generate-matrix.outputs.commits) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.commit }}
- name: Install toolchain and tools
run: |
rustup toolchain install nightly --profile minimal
rustup default nightly
sudo apt update && sudo apt install -y libudev-dev
cargo install flip-link elf2uf2-rs
- name: Build
run: cargo run --verbose --release
- uses: actions/upload-artifact@v4
with:
name: Picoprog-Image-${{ matrix.commit }}
path: target/thumbv6m-none-eabi/release/picoprog.uf2
73 changes: 73 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Lint

on:
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
branches:
- main

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
RUSTFLAGS: --deny warnings

jobs:
generate-matrix:
runs-on: ubuntu-latest
outputs:
commits: ${{ steps.commits.outputs.hashes }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- name: Get all commit hashes
id: commits
run: |
echo "hashes=[$(git log -z --pretty=format:"'%H'," ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} | sed 's/.$//')]" >> "$GITHUB_OUTPUT"
commit-lint:
name: Conventional Commits
needs: generate-matrix
strategy:
matrix:
commit: ${{ fromJson(needs.generate-matrix.outputs.commits) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.commit }}
- uses: bugbundle/[email protected]
cargo:
name: Rustfmt and Clippy
needs: generate-matrix
strategy:
matrix:
commit: ${{ fromJson(needs.generate-matrix.outputs.commits) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.commit }}
- name: Install toolchain and tools
run: |
rustup toolchain install nightly --profile minimal
rustup default nightly
rustup component add clippy rustfmt
- name: Check Code Formatting
run: cargo fmt -- --check
- name: Lint with Clippy
run: cargo clippy -- -D warnings
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: SLSA generic generator

on:
workflow_dispatch:
release:
types:
- created

jobs:
build:
runs-on: ubuntu-latest
outputs:
digests: ${{ steps.hash.outputs.digests }}
steps:
- uses: actions/checkout@v4
- name: Install toolchain and tools
run: |
rustup toolchain install nightly --profile minimal
rustup default nightly
- name: Install toolchain and tools
run: |
rustup toolchain install nightly --profile minimal
rustup default nightly
sudo apt update && sudo apt install -y libudev-dev
cargo install flip-link elf2uf2-rs
- name: Build
run: cargo run --release
- name: Generate subject for provenance
id: hash
run: |
set -euo pipefail
echo "hashes=$(sha256sum target/thumbv6m-none-eabi/release/picoprog.uf2 | base64 -w0)" >> "${GITHUB_OUTPUT}"
- uses: actions/upload-artifact@v4
with:
name: Picoprog-Image
path: target/thumbv6m-none-eabi/release/picoprog.uf2
provenance:
needs: build
permissions:
actions: read # To read the workflow path.
id-token: write # To sign the provenance.
contents: write # To add assets to a release.
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
with:
base64-subjects: "${{ needs.build.outputs.digests }}"
upload-assets: true
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,12 +202,12 @@ async fn usb_task(mut usb: CustomUsbDevice) -> ! {
}

#[embassy_executor::task]
async fn logger_task(class: CdcAcmClass<'static, CustomUsbDriver>) -> () {
async fn logger_task(class: CdcAcmClass<'static, CustomUsbDriver>) {
with_class!(1024, log::LevelFilter::Info, class).await
}

#[embassy_executor::task]
async fn uart_task(class: CdcAcmClass<'static, CustomUsbDriver>, r: UartResources) -> () {
async fn uart_task(class: CdcAcmClass<'static, CustomUsbDriver>, r: UartResources) {
let config = UartConfig::default(); // TODO: make this configurable

let uart = Uart::new(
Expand Down