mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-12-16 14:53:28 +02:00
159 lines
4.0 KiB
YAML
159 lines
4.0 KiB
YAML
name: Test
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
mdbook:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Rust cache
|
|
uses: ./.github/workflows/setup-rust-cache
|
|
|
|
- name: Install mdbook
|
|
uses: ./.github/workflows/install-mdbook
|
|
|
|
- name: Test code snippets
|
|
run: mdbook test
|
|
|
|
format:
|
|
name: Format
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Format Rust code
|
|
run: cargo fmt --all -- --check
|
|
|
|
cargo:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Rust cache
|
|
uses: ./.github/workflows/setup-rust-cache
|
|
|
|
- name: Build Rust code
|
|
run: cargo build
|
|
|
|
- name: Test Rust code
|
|
run: cargo test
|
|
|
|
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
|
|
|
|
exercises:
|
|
name: Build exercise templates
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Build
|
|
run: ./build-exercise-templates.sh
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: exercise-templates
|
|
path: exercise-templates/
|
|
|
|
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)
|
|
|
|
translations:
|
|
runs-on: ubuntu-latest
|
|
needs:
|
|
- find-translations
|
|
strategy:
|
|
matrix:
|
|
language: ${{ fromJSON(needs.find-translations.outputs.languages) }}
|
|
env:
|
|
MDBOOK_BOOK__LANGUAGE: ${{ matrix.language }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Setup Rust cache
|
|
uses: ./.github/workflows/setup-rust-cache
|
|
|
|
- name: Install Gettext
|
|
run: sudo apt install gettext
|
|
|
|
- name: Install mdbook
|
|
uses: ./.github/workflows/install-mdbook
|
|
|
|
- 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
|
|
|
|
- name: Upload ${{ matrix.language }} translation
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: comprehensive-rust-${{ matrix.language }}
|
|
path: book/
|
|
|
|
- name: Test code snippets with ${{ matrix.language }} translation
|
|
run: mdbook test
|