Add a simple CI workflow to verify the template #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
push: | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
# Cancel any currently running workflows from the same PR, branch, or | |
# tag when a new workflow is triggered. | |
# | |
# https://stackoverflow.com/a/66336834 | |
concurrency: | |
cancel-in-progress: true | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
jobs: | |
# -------------------------------------------------------------------------- | |
# Check | |
check: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
mcu: [esp32, esp32c2, esp32c3, esp32c6, esp32h2, esp32s2, esp32s3] | |
env: | |
PROJECT_NAME: test-project | |
steps: | |
- uses: actions/checkout@v4 | |
# Install the Rust toolchain for RISC-V devices: | |
- if: ${{ !contains(fromJson('["esp32", "esp32s2", "esp32s3"]'), matrix.mcu) }} | |
uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: nightly-2024-06-01 # TODO: Remove date when able | |
# Install the Rust toolchain for Xtensa devices: | |
- if: ${{ contains(fromJson('["esp32", "esp32s2", "esp32s3"]'), matrix.mcu) }} | |
uses: esp-rs/xtensa-toolchain@v1.5 | |
with: | |
buildtargets: ${{ matrix.mcu }} | |
ldproxy: false | |
- uses: cargo-generate/cargo-generate-action@latest | |
with: | |
name: ${{ env.PROJECT_NAME }} | |
arguments: "--define mcu=${{ matrix.mcu }}" | |
# We need to move the generated project to a temporary folder, away | |
# from the template project, otherwise `cargo` runs would fail. | |
# | |
# See: https://github.com/rust-lang/cargo/issues/9922 | |
- run: | | |
mv $PROJECT_NAME ${{ runner.temp }}/ | |
cd ${{ runner.temp }}/$PROJECT_NAME | |
cargo check |