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-01-03 15:39:24 +02:00
|
|
|
mdbook:
|
2022-12-22 16:09:57 +02:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
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
|
2022-12-22 16:09:57 +02:00
|
|
|
|
|
|
|
- name: Install mdbook
|
2023-01-23 18:08:29 +02:00
|
|
|
uses: ./.github/workflows/install-mdbook
|
2022-12-22 16:09:57 +02:00
|
|
|
|
|
|
|
- name: Test code snippets
|
|
|
|
run: mdbook test
|
2023-01-03 15:39:24 +02:00
|
|
|
|
2023-03-16 17:56:23 +02:00
|
|
|
format:
|
|
|
|
name: Format
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Format Rust code
|
|
|
|
run: cargo fmt --all -- --check
|
|
|
|
|
2023-01-03 15:39:24 +02:00
|
|
|
cargo:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
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:
|
|
|
|
name: Build bare-metal Rust examples
|
|
|
|
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
|
|
|
|
run: sudo apt update && sudo apt install gcc-aarch64-linux-gnu
|
|
|
|
|
|
|
|
- name: Install toolchain
|
|
|
|
uses: actions-rs/toolchain@v1
|
|
|
|
with:
|
|
|
|
toolchain: stable
|
|
|
|
target: ${{ matrix.target }}
|
|
|
|
|
|
|
|
- name: Build Rust code
|
|
|
|
working-directory: ${{ matrix.directory }}
|
|
|
|
run: cargo build
|
|
|
|
|
2023-01-30 14:41:19 +02:00
|
|
|
find-translations:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
|
|
languages: ${{ steps.find-translations.outputs.languages }}
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
|
|
|
uses: actions/checkout@v3
|
|
|
|
|
|
|
|
- name: Find translations
|
|
|
|
id: find-translations
|
|
|
|
shell: python
|
|
|
|
run: |
|
|
|
|
import os, json, pathlib
|
|
|
|
languages = [p.stem for p in pathlib.Path("po").iterdir() if p.suffix == ".po"]
|
|
|
|
github_output = open(os.environ["GITHUB_OUTPUT"], "a")
|
|
|
|
github_output.write("languages=")
|
|
|
|
json.dump(sorted(languages), github_output)
|
|
|
|
|
2023-01-09 15:01:29 +02:00
|
|
|
translations:
|
|
|
|
runs-on: ubuntu-latest
|
2023-01-30 14:41:19 +02:00
|
|
|
needs:
|
|
|
|
- find-translations
|
2023-01-09 15:01:29 +02:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2023-01-30 14:41:19 +02:00
|
|
|
language: ${{ fromJSON(needs.find-translations.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
|
|
|
|
run: sudo apt install gettext
|
|
|
|
|
|
|
|
- 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
|
|
|
|
run: msgfmt --statistics -o /dev/null po/${{ matrix.language }}.po
|
|
|
|
|
|
|
|
- name: Build course with ${{ matrix.language }} translation
|
|
|
|
run: mdbook build
|
|
|
|
|
2023-04-05 13:04:54 +02:00
|
|
|
- name: Zip exercise templates for ${{ matrix.language }} translation
|
2023-04-05 17:15:42 +02:00
|
|
|
run: cd book/exerciser && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/
|
2023-04-05 13:04:54 +02:00
|
|
|
|
2023-02-06 18:20:32 +02:00
|
|
|
- name: Upload ${{ matrix.language }} translation
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: comprehensive-rust-${{ matrix.language }}
|
|
|
|
path: book/
|
|
|
|
|
2023-01-09 15:01:29 +02:00
|
|
|
- name: Test code snippets with ${{ matrix.language }} translation
|
|
|
|
run: mdbook test
|