2023-01-03 15:46:25 +02:00
|
|
|
name: Test
|
2022-12-22 16:09:57 +02:00
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
2023-01-03 15:39:24 +02:00
|
|
|
env:
|
|
|
|
CARGO_TERM_COLOR: always
|
|
|
|
|
2022-12-22 16:09:57 +02:00
|
|
|
jobs:
|
2023-03-16 17:56:23 +02:00
|
|
|
format:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
2023-05-16 12:35:49 +02:00
|
|
|
- name: Install nightly rustfmt
|
|
|
|
run: |
|
|
|
|
rustup default nightly
|
|
|
|
rustup component add rustfmt
|
|
|
|
|
2023-05-30 17:04:19 +02:00
|
|
|
- name: Check formatting
|
|
|
|
uses: dprint/check@v2.2
|
2023-03-16 17:56:23 +02:00
|
|
|
|
2023-01-03 15:39:24 +02:00
|
|
|
cargo:
|
2023-06-22 10:38:41 +02:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os:
|
|
|
|
- ubuntu-latest
|
|
|
|
- macos-latest
|
|
|
|
runs-on: ${{ matrix.os }}
|
2023-01-03 15:39:24 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Setup Rust cache
|
2023-01-23 18:08:29 +02:00
|
|
|
uses: ./.github/workflows/setup-rust-cache
|
2023-01-03 15:39:24 +02:00
|
|
|
|
2023-02-02 18:14:34 +02:00
|
|
|
- name: Build Rust code
|
|
|
|
run: cargo build
|
2023-01-09 15:01:29 +02:00
|
|
|
|
2023-02-02 18:14:34 +02:00
|
|
|
- name: Test Rust code
|
2023-01-09 15:03:00 +02:00
|
|
|
run: cargo test
|
|
|
|
|
2023-03-21 19:24:49 +02:00
|
|
|
bare-metal:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
include:
|
|
|
|
- directory: src/bare-metal/alloc-example
|
|
|
|
target: aarch64-unknown-none
|
|
|
|
- directory: src/bare-metal/aps/examples
|
|
|
|
target: aarch64-unknown-none
|
|
|
|
- directory: src/bare-metal/microcontrollers/examples
|
|
|
|
target: thumbv7em-none-eabihf
|
|
|
|
- directory: src/exercises/bare-metal/compass
|
|
|
|
target: thumbv7em-none-eabihf
|
|
|
|
- directory: src/exercises/bare-metal/rtc
|
|
|
|
target: aarch64-unknown-none
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Setup Rust cache
|
|
|
|
uses: ./.github/workflows/setup-rust-cache
|
|
|
|
|
|
|
|
- name: Install dependencies
|
2023-05-24 21:58:34 +02:00
|
|
|
run: |
|
|
|
|
sudo apt update
|
|
|
|
sudo apt install gcc-aarch64-linux-gnu
|
2023-03-21 19:24:49 +02:00
|
|
|
|
|
|
|
- name: Install toolchain
|
2023-05-08 16:32:25 +02:00
|
|
|
run: rustup target add ${{ matrix.target }}
|
2023-03-21 19:24:49 +02:00
|
|
|
|
|
|
|
- name: Build Rust code
|
|
|
|
working-directory: ${{ matrix.directory }}
|
|
|
|
run: cargo build
|
|
|
|
|
2023-05-08 16:32:25 +02:00
|
|
|
find-languages:
|
2023-01-30 14:41:19 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
2023-05-08 16:32:25 +02:00
|
|
|
languages: ${{ steps.find-languages.outputs.languages }}
|
2023-01-30 14:41:19 +02:00
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
2023-05-08 16:32:25 +02:00
|
|
|
- name: Find languages
|
|
|
|
id: find-languages
|
2023-01-30 14:41:19 +02:00
|
|
|
shell: python
|
|
|
|
run: |
|
|
|
|
import os, json, pathlib
|
2023-05-08 16:32:25 +02:00
|
|
|
languages = ["en"] + [p.stem for p in pathlib.Path("po").iterdir() if p.suffix == ".po"]
|
2023-01-30 14:41:19 +02:00
|
|
|
github_output = open(os.environ["GITHUB_OUTPUT"], "a")
|
|
|
|
github_output.write("languages=")
|
|
|
|
json.dump(sorted(languages), github_output)
|
|
|
|
|
2023-05-08 16:32:25 +02:00
|
|
|
build:
|
2023-01-09 15:01:29 +02:00
|
|
|
runs-on: ubuntu-latest
|
2023-01-30 14:41:19 +02:00
|
|
|
needs:
|
2023-05-08 16:32:25 +02:00
|
|
|
- find-languages
|
2023-01-09 15:01:29 +02:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-05-08 16:32:25 +02:00
|
|
|
language: ${{ fromJSON(needs.find-languages.outputs.languages) }}
|
2023-01-09 15:01:29 +02:00
|
|
|
env:
|
|
|
|
MDBOOK_BOOK__LANGUAGE: ${{ matrix.language }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Setup Rust cache
|
2023-01-23 18:08:29 +02:00
|
|
|
uses: ./.github/workflows/setup-rust-cache
|
2023-01-09 15:01:29 +02:00
|
|
|
|
|
|
|
- name: Install Gettext
|
2023-05-08 16:32:25 +02:00
|
|
|
if: matrix.language != 'en'
|
2023-05-24 21:58:34 +02:00
|
|
|
run: |
|
|
|
|
sudo apt update
|
|
|
|
sudo apt install gettext
|
2023-01-09 15:01:29 +02:00
|
|
|
|
|
|
|
- name: Install mdbook
|
2023-01-23 18:08:29 +02:00
|
|
|
uses: ./.github/workflows/install-mdbook
|
2023-01-09 15:01:29 +02:00
|
|
|
|
|
|
|
- name: Test ${{ matrix.language }} translation
|
2023-05-08 16:32:25 +02:00
|
|
|
if: matrix.language != 'en'
|
2023-01-09 15:01:29 +02:00
|
|
|
run: msgfmt --statistics -o /dev/null po/${{ matrix.language }}.po
|
|
|
|
|
2023-05-08 16:32:25 +02:00
|
|
|
- name: Build course
|
2023-01-09 15:01:29 +02:00
|
|
|
run: mdbook build
|
|
|
|
|
2023-05-08 16:32:25 +02:00
|
|
|
- name: Zip exercise templates
|
|
|
|
run: zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/
|
|
|
|
working-directory: book/exerciser
|
|
|
|
|
|
|
|
- name: Prepare book for upload
|
|
|
|
run: |
|
|
|
|
mv book/html book/comprehensive-rust-${{ matrix.language }}
|
|
|
|
rm -r book/exerciser
|
2023-04-05 13:04:54 +02:00
|
|
|
|
2023-05-08 16:32:25 +02:00
|
|
|
# Upload the book now to retain it in case mdbook test fails.
|
|
|
|
- name: Upload book
|
2023-02-06 18:20:32 +02:00
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: comprehensive-rust-${{ matrix.language }}
|
|
|
|
path: book/
|
|
|
|
|
2023-05-08 16:32:25 +02:00
|
|
|
- name: Test code snippets
|
2023-01-09 15:01:29 +02:00
|
|
|
run: mdbook test
|