Merge pull request #212 from ferrous-systems/fix-canary-again #130
This file contains hidden or 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
# This is a workflow file to run, build, and test all crates used as part of `rust-exercises`. | |
# It is cached with Swatinem/rust-cache@v2 and setup so that no jobs depend on any other jobs, | |
# EXCEPT for the last `deploy` job, which pulls in artifacts-producing jobs in the `needs:` field. | |
# The brunt of the work is defined in `build_fns.sh` where the actual build/testing logic is defined. | |
name: rust-exercises | |
env: | |
CARGO_TERM_COLOR: always # We want colors in our CI output | |
CARGO_INCREMENTAL: 0 # Don't waste time writing out incremental build files | |
CARGO_PROFILE_TEST_DEBUG: 0 # These are thrown away anyways, don't produce them | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "**" | |
pull_request: | |
branches: | |
- main | |
# * All jobs defined here run independently of each other EXCEPT for `deploy`. | |
# * Jobs that have a `matrix` field will setup up a job per entry in said | |
# `matrix`. | |
# | |
# If you add any jobs that produce artifacts, make sure to add them to the | |
# `needs:` field of the `deploy` job, since that ensures `deploy` will run | |
# last and can pull said artifacts | |
# | |
# ========== TEMPLATE =========== | |
# my_cool_new_job: | |
# runs-on: ubuntu-24.04 | |
# steps: | |
# - uses: actions/checkout@v4 # This is what downloads a fresh clone of the repo and cd's into it | |
# - uses: ./.github/actions/setup | |
# with: | |
# cache: dir_where_I_want_results_cached | |
# - uses: taiki-e/install-action@v2 # For adding arbitrary binaries as tools | |
# with: | |
# tool: [email protected] | |
# - run: just do-thing | |
# =========== END TEMPLATE ======== | |
# | |
# And then you'd add `my_cool_new_job` to the `needs` field of `deploy`. | |
jobs: | |
test-build-mdbook: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
with: | |
cache: exercise-book | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: [email protected],[email protected] | |
- run: just test-mdbook | |
- run: just build-mdbook | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: mdbook-dir | |
path: exercise-book/book/ | |
if-no-files-found: error | |
test-exercise-templates: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
with: | |
cache: exercise-templates | |
- run: just test-exercise-templates | |
test-exercise-solutions: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
with: | |
cache: exercise-solutions | |
- run: just test-exercise-solutions | |
test-connected-mailbox: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
- run: just test-connected-mailbox | |
test-multi-threaded-mailbox: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
- run: just test-multi-threaded-mailbox | |
build-qemu-uart-driver: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
with: | |
cache: qemu-code/uart-driver | |
target: thumbv7em-none-eabihf | |
- run: rustup component add rust-src | |
- run: just build-qemu-uart-driver | |
build-radio-app: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
with: | |
cache: nrf52-code/radio-app | |
target: thumbv7em-none-eabihf | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: [email protected] | |
- run: just build-radio-app | |
build-usb-app: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
with: | |
cache: nrf52-code/usb-app | |
target: thumbv7em-none-eabihf | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: [email protected] | |
- run: just build-usb-app | |
test-usb-lib: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
with: | |
cache: nrf52-code/usb-lib | |
target: thumbv7em-none-eabihf | |
- run: just test-usb-lib | |
build-puzzle-fw: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
with: | |
cache: nrf52-code/puzzle-fw | |
target: thumbv7em-none-eabihf | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: [email protected] | |
- run: just build-puzzle-fw | |
env: | |
HIDDEN_MESSAGE: ${{ secrets.HIDDEN_MESSAGE }} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: puzzle-fw | |
path: nrf52-code/puzzle-fw/target/thumbv7em-none-eabihf/release/puzzle-fw | |
if-no-files-found: error | |
build-loopback-fw: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
with: | |
cache: nrf52-code/loopback-fw | |
target: thumbv7em-none-eabihf | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: [email protected] | |
- run: just build-loopback-fw | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: loopback-fw | |
path: nrf52-code/loopback-fw/target/thumbv7em-none-eabihf/release/loopback-fw | |
if-no-files-found: error | |
format-check: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
- run: just format-check | |
# This is the last job, and waits (`needs:`) only on those that pass artifacts to it. | |
# It the necessary resulting builds as artifacts, zips them, and uploads with a tag if necessary. | |
deploy: | |
runs-on: ubuntu-24.04 | |
# Notice that because our repo expects all checks to pass, we don't need to include every other job | |
# as a dependency of the `deploy` job. | |
needs: [test-build-mdbook, build-puzzle-fw, build-loopback-fw] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/setup | |
# Download the produced artifacts | |
- uses: actions/download-artifact@v4 | |
with: | |
# Move the mdbook `book` dir to where we expect it to be | |
name: mdbook-dir | |
path: ./exercise-book/book | |
- uses: actions/download-artifact@v4 | |
with: | |
name: puzzle-fw | |
path: ./nrf52-code/puzzle-fw/target/thumbv7em-none-eabihf/release/ | |
- uses: actions/download-artifact@v4 | |
with: | |
name: loopback-fw | |
path: ./nrf52-code/loopback-fw/target/thumbv7em-none-eabihf/release/ | |
- run: | | |
slug=$(./describe.sh "${GITHUB_REF}") | |
echo "Building with slug '${slug}'" | |
echo "slug=${slug}" >> "${GITHUB_ENV}" | |
- run: just assemble ${{ env.slug }} | |
- uses: actions/upload-artifact@v4 | |
if: ${{success()}} | |
with: | |
name: Artifacts | |
if-no-files-found: error | |
path: | | |
./rust-exercises-* | |
- if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/') | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "./rust-exercises-${{ env.slug }}.zip,./rust-exercises-${{ env.slug }}/nrf52-code/boards/dongle-fw/*-fw" | |
allowUpdates: true | |
updateOnlyUnreleased: true |