mirror of
https://github.com/google/comprehensive-rust.git
synced 2024-12-02 11:03:18 +02:00
413098cdac
This makes it super easy for translators to see the results of their work: every PR will now have a list of artifacts, one per translation.
135 lines
3.4 KiB
YAML
135 lines
3.4 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
|
|
|
|
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
|
|
|
|
i18n-helpers:
|
|
runs-on: ubuntu-latest
|
|
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: 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
|
|
|
|
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 }}
|
|
MDBOOK_PREPROCESSOR__GETTEXT__PO_FILE: po/${{ matrix.language }}.po
|
|
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
|