Skip to content
Open
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
139 changes: 91 additions & 48 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,106 @@ on:
pull_request:
workflow_dispatch:

env:
CARGO_INCREMENTAL: 0
RUSTUP_MAX_RETRIES: 10
CARGO_NET_RETRY: 10
RUST_BACKTRACE: full
defaults:
run:
shell: bash

jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: rustup component add rustfmt
- run: cargo fmt --all -- --check

rust:
name: Rust
test:
name: Test
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
fail-fast: true
matrix:
os: [ubuntu-latest]

os: [ ubuntu-latest ]
steps:
- name: Checkout repository
uses: actions/checkout@v6
- uses: actions/checkout@v6
with: { submodules: 'recursive' }
- if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with: { tool: 'just,cargo-binstall' }
- run: just ci-test

- name: Cache cargo registry
uses: actions/cache@v5
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo index
uses: actions/cache@v5
with:
path: ~/.cargo/git
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }}
- name: Cache cargo target dir
uses: actions/cache@v5
test-msrv:
name: Test MSRV
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with: { submodules: 'recursive' }
- if: github.event_name != 'release' && github.event_name != 'workflow_dispatch'
uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with: { tool: 'just' }
- name: Read MSRV
id: msrv
run: echo "value=$(just get-msrv)" >> $GITHUB_OUTPUT
- name: Install MSRV Rust ${{ steps.msrv.outputs.value }}
uses: dtolnay/rust-toolchain@stable
with:
path: target
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
toolchain: ${{ steps.msrv.outputs.value }}
- run: just ci_mode=0 ci-test-msrv # Ignore warnings in MSRV

- name: Build
run: cargo build --workspace --all-features --all-targets --verbose
- name: Tests
run: cargo test --workspace --all-features --all-targets --verbose
coverage:
name: Code Coverage
if: github.event_name != 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with: { submodules: 'recursive' }
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@v2
with: { tool: 'just,cargo-llvm-cov' }
- name: Generate code coverage
run: just ci-coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: target/llvm-cov/codecov.info

- name: Install Rust targets we use for embedded
run: rustup target install thumbv7em-none-eabihf
- name: Build for embedded
run: cargo build -p can-embedded --target=thumbv7em-none-eabihf --no-default-features
# This job checks if any of the previous jobs failed or were canceled.
# This approach also allows some jobs to be skipped if they are not needed.
ci-passed:
needs: [ test, test-msrv ]
if: always()
runs-on: ubuntu-latest
steps:
- name: Result of the needed steps
run: echo "${{ toJSON(needs) }}"
- if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}
run: exit 1

- name: Install clippy
run: rustup component add clippy
- name: Annotate commit with clippy warnings
if: startsWith(matrix.os, 'ubuntu')
run: cargo clippy --workspace --all-features --all-targets
# Release unpublished packages or create a PR with changes
release-plz:
needs: [ ci-passed ]
if: |
always()
&& needs.ci-passed.result == 'success'
&& github.event_name == 'push'
&& github.ref == 'refs/heads/main'
&& github.repository_owner == 'oxibus'
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
pull-requests: write
concurrency:
group: release-plz-${{ github.ref }}
cancel-in-progress: false
steps:
- uses: actions/checkout@v6
with: { fetch-depth: 0 }
- uses: dtolnay/rust-toolchain@stable
- name: Publish to crates.io if crate's version is newer
uses: release-plz/action@v0.5
id: release
with: { command: release }
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
- if: ${{ steps.release.outputs.releases_created == 'false' }}
name: If version is the same, create a PR proposing new version and changelog for the next release
uses: release-plz/action@v0.5
with: { command: release-pr }
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PLZ_TOKEN }}
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading