patterns/.github/workflows/build.yml

120 lines
3.3 KiB
YAML
Raw Normal View History

name: Test mdbook chapters
on:
pull_request:
push:
branches:
- main
env:
CARGO_TERM_COLOR: always
jobs:
mdbook-test:
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
# TODO: Activate when first translation is available
# i18n-helpers:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Install Gettext
# run: sudo apt install gettext
# - name: Setup Rust cache
# uses: ./.github/workflows/setup-rust-cache
# - 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 --color=always --unified --recursive 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 }}
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Install Gettext
# run: sudo apt install gettext
# - name: Setup Rust cache
# uses: ./.github/workflows/setup-rust-cache
# - 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 book with ${{ matrix.language }} translation
# run: mdbook build
# - name: Upload ${{ matrix.language }} translation
# uses: actions/upload-artifact@v3
# with:
# name: rust-design-patterns-${{ matrix.language }}
# path: book/
# - name: Test code snippets with ${{ matrix.language }} translation
# run: mdbook test