Harmonising README text with rust-training. #118
Workflow file for this run
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 | |
# - name: Install tools | |
# uses: taiki-e/install-action@v2 # For adding arbitrary binaries as tools | |
# with: | |
# tool: [email protected] | |
# - uses: Swatinem/rust-cache@v2 | |
# with: | |
# workspaces: dir_where_I_want_results_cached # This job will look up this specific cached dir | |
# - name: Build foo | |
# run: | | |
# . ${{github.workspace}}/build_fns.sh | |
# cd interesting_directory | |
# command_defined_in_build_fns.sh | |
# =========== END TEMPLATE ======== | |
# | |
# And then you'd add `my_cool_new_job` to the `needs` field of `deploy`. | |
jobs: | |
test_and_build_mdbook: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install mdbook, mdbook-mermaid | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: [email protected],[email protected] | |
# From Rust Cache Action: | |
# selecting a toolchain either by action or manual `rustup` calls should happen | |
# before the plugin, as the cache uses the current rustc version as its cache key | |
- run: rustup toolchain install stable --profile minimal | |
# For the cache to be keyed properly, we need to declare the workspace and then `cd` into it. | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: exercise-book | |
- name: Build mdbook, Test mdbook, Load cache | |
run: | | |
. ${{github.workspace}}/build_fns.sh | |
cd exercise-book | |
mdbook_test_build | |
# Uploading an artifact is how we can share data between different jobs | |
- name: Upload mdbook artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: mdbook-dir | |
path: exercise-book/book/ | |
if-no-files-found: error | |
test_exercise_solutions_and_examples: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
rustup toolchain install stable --profile minimal | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: exercise-solutions | |
- name: Test exercise-solutions and examples, with cache | |
run: | | |
. ${{github.workspace}}/build_fns.sh | |
cd exercise-solutions | |
test_examples | |
test_exercise_solutions_standalone_crates: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
crates: [exercise-solutions/connected-mailbox, | |
exercise-solutions/multi-threaded-mailbox] | |
steps: | |
- uses: actions/checkout@v4 | |
- run: rustup toolchain install stable --profile minimal | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: ${{matrix.crates}} | |
- name: Test exercise-solutions standalone crates, Load cache | |
run: | | |
. ${{github.workspace}}/build_fns.sh | |
cd ${{matrix.crates}} | |
test_standalone | |
build_qemu_core: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: rustup toolchain install stable --profile minimal --component rust-src | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: qemu-code/uart-driver | |
- name: Build-qemu-code/uart-driver, load cache | |
run: | | |
cd qemu-code/uart-driver | |
. ../../build_fns.sh | |
build_qemu_core | |
build_nrf52_usb_crates: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
crates: [nrf52-code/boards/dk, | |
nrf52-code/boards/dk-solution, | |
nrf52-code/boards/dongle, | |
nrf52-code/radio-app, | |
nrf52-code/usb-app, | |
nrf52-code/usb-app-solutions, | |
nrf52-code/consts] | |
steps: | |
- name: Install flip-link | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: [email protected] | |
- uses: actions/checkout@v4 | |
- run: rustup toolchain install stable --profile minimal --target thumbv7em-none-eabihf | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: ${{matrix.crates}} | |
- name: build-nrf52 usb crates, Load cache | |
run: | | |
. ${{github.workspace}}/build_fns.sh | |
cd ${{matrix.crates}} | |
build_thumbv7em | |
# This job is different from the one above because we cannot make individual steps conditional, | |
# but we can define a different `matrix` of files that we have to upload | |
build_nrf52_usb_crates_and_upload_fw: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
crates: [puzzle-fw, loopback-fw] | |
steps: | |
- name: Install flip-link | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: [email protected] | |
- uses: actions/checkout@v4 | |
- run: rustup toolchain install stable --profile minimal --target thumbv7em-none-eabihf | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: nrf52-code/${{matrix.crates}} | |
- name: build-only-nrf52 crates, load cache | |
run: | | |
. ${{github.workspace}}/build_fns.sh | |
cd nrf52-code/${{matrix.crates}} | |
build_thumbv7em | |
# We also upload the built binaries in the puzzle-fw and loopback-fw cases | |
- name: Upload ${{matrix.crates}} artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{matrix.crates}} | |
path: nrf52-code/${{matrix.crates}}/target/thumbv7em-none-eabihf/release/${{matrix.crates}} | |
if-no-files-found: error | |
build_and_test_nrf52_crates: | |
runs-on: ubuntu-24.04 | |
strategy: | |
matrix: | |
crates: [nrf52-code/usb-lib-solutions/complete, | |
nrf52-code/usb-lib-solutions/get-descriptor-config, | |
nrf52-code/usb-lib-solutions/get-device, | |
nrf52-code/usb-lib-solutions/set-config] | |
steps: | |
- name: Install flip-link | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: [email protected] | |
- uses: actions/checkout@v4 | |
- run: rustup toolchain install stable --profile minimal --target thumbv7em-none-eabihf | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: ${{matrix.crates}} | |
- name: build-and-test nrf52 crates, load cache | |
run: | | |
. ${{github.workspace}}/build_fns.sh | |
cd ${{matrix.crates}} | |
build_test_thumbv7em | |
check_templates: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: rustup toolchain install stable --profile minimal | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: exercise-templates | |
- name: Check exercise-templates, Load cache | |
run: | | |
. ${{github.workspace}}/build_fns.sh | |
cd exercise-templates | |
check_templates | |
check_fmt: | |
runs-on: ubuntu-24.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- run: rustup toolchain install stable --profile minimal --component rustfmt | |
- name: Check fmt | |
run: | | |
. ${{github.workspace}}/build_fns.sh | |
check_fmt | |
# 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_and_build_mdbook, build_nrf52_usb_crates_and_upload_fw] | |
steps: | |
- uses: actions/checkout@v4 | |
# Download the produced artifacts | |
- name: Download mdbook-dir artifact | |
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 | |
- name: Download puzzle-fw artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: puzzle-fw | |
path: ./nrf52-code/puzzle-fw/target/thumbv7em-none-eabihf/release/ | |
- name: Download loopback-fw artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: loopback-fw | |
path: ./nrf52-code/loopback-fw/target/thumbv7em-none-eabihf/release/ | |
- name: Find slug name | |
run: | | |
slug=$(./describe.sh "${GITHUB_REF}") | |
echo "Building with slug '${slug}'" | |
echo "slug=${slug}" >> "${GITHUB_ENV}" | |
- name: Build and test | |
env: # Or as an environment variable | |
HIDDEN_MESSAGE: ${{ secrets.HIDDEN_MESSAGE }} | |
run: | | |
. ${{github.workspace}}/build_fns.sh | |
zip_output "./rust-exercises-${{ env.slug }}" | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
if: ${{success()}} | |
with: | |
name: Artifacts | |
if-no-files-found: error | |
path: | | |
./rust-exercises-* | |
- name: Create and Upload Release | |
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 |