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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
- name: Test Rust code
|
|
|
|
run: cargo test
|
2023-01-09 15:01:29 +02:00
|
|
|
|
2023-01-09 15:03:00 +02:00
|
|
|
- name: Test i18n-helpers
|
|
|
|
run: cargo test
|
|
|
|
working-directory: i18n-helpers
|
|
|
|
|
2023-01-10 16:00:20 +02:00
|
|
|
i18n-helpers:
|
|
|
|
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-10 16:00:20 +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-10 16:00:20 +02:00
|
|
|
|
|
|
|
- name: Generate po/messages.pot
|
|
|
|
run: mdbook build -d po
|
|
|
|
env:
|
|
|
|
MDBOOK_OUTPUT: '{"xgettext": {"pot-file": "messages.pot"}}'
|
|
|
|
|
|
|
|
- name: Test messages.pot
|
|
|
|
run: msgfmt --statistics -o /dev/null po/messages.pot
|
|
|
|
|
|
|
|
- name: Expand includes without translation
|
|
|
|
run: mdbook build -d expanded
|
|
|
|
env:
|
|
|
|
MDBOOK_OUTPUT: '{"markdown": {}}'
|
|
|
|
|
|
|
|
- name: Expand includes with no-op translation
|
|
|
|
run: mdbook build -d no-op
|
|
|
|
env:
|
|
|
|
MDBOOK_OUTPUT: '{"markdown": {}}'
|
|
|
|
MDBOOK_PREPROCESSOR__GETTEXT__PO_FILE: po/messages.pot
|
|
|
|
|
|
|
|
- name: Compare no translation to no-op translation
|
|
|
|
run: diff -r expanded no-op
|
|
|
|
|
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 }}
|
|
|
|
MDBOOK_PREPROCESSOR__GETTEXT__PO_FILE: po/${{ matrix.language }}.po
|
|
|
|
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
|
|
|
|
|
|
|
|
- name: Test code snippets with ${{ matrix.language }} translation
|
|
|
|
run: mdbook test
|