diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..964be60 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,24 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +# Cancel old workflows for PRs (only the most recent workflow can run). +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +# Avoid workflow-level permissions, instead use job-level permissions. +permissions: {} + +jobs: + ubuntu: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: ./ci.sh diff --git a/ci.sh b/ci.sh new file mode 100755 index 0000000..369b662 --- /dev/null +++ b/ci.sh @@ -0,0 +1,30 @@ +#!/bin/sh +set -ex + +has_target() { + rustup target list --installed | grep -q "$1" +} +ensure_target() { + has_target "$1" || rustup target add "$1" +} +cargo_check() { + cargo check "$@" + # TODO: Uncomment once clippy lints are fixed. + # cargo clippy "$@" -- --deny=warnings +} +cargo_test() { + cargo_check --all-targets "$@" + cargo test "$@" +} + +cargo_test --features=alloc,experimental-derive + +ensure_target thumbv7em-none-eabi +cargo_check --target=thumbv7em-none-eabi --no-default-features +cargo_check --target=thumbv7em-none-eabi --features=alloc,experimental-derive + +# TODO: Uncomment once formatting is correct. +# cargo fmt -- --check + +# TODO: Uncomment once documentation lints are fixed. +# env RUSTDOCFLAGS='--cfg=docsrs --deny=warnings' cargo doc --no-deps