|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +env: |
| 10 | + CARGO_TERM_COLOR: always |
| 11 | + |
| 12 | +jobs: |
| 13 | + mdbook: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v3 |
| 18 | + |
| 19 | + - name: Install mdbook |
| 20 | + uses: ./.github/workflows/install-mdbook |
| 21 | + |
| 22 | + - name: Test code snippets |
| 23 | + run: mdbook test |
| 24 | + |
| 25 | + i18n-helpers: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v3 |
| 30 | + |
| 31 | + - name: Install Gettext |
| 32 | + run: sudo apt install gettext |
| 33 | + |
| 34 | + - name: Install mdbook |
| 35 | + uses: ./.github/workflows/install-mdbook |
| 36 | + |
| 37 | + - name: Generate po/messages.pot |
| 38 | + run: mdbook build -d po |
| 39 | + env: |
| 40 | + MDBOOK_OUTPUT: '{"xgettext": {"pot-file": "messages.pot"}}' |
| 41 | + |
| 42 | + - name: Test messages.pot |
| 43 | + run: msgfmt --statistics -o /dev/null po/messages.pot |
| 44 | + |
| 45 | + - name: Expand includes without translation |
| 46 | + run: mdbook build -d expanded |
| 47 | + env: |
| 48 | + MDBOOK_OUTPUT: '{"markdown": {}}' |
| 49 | + |
| 50 | + - name: Expand includes with no-op translation |
| 51 | + run: mdbook build -d no-op |
| 52 | + env: |
| 53 | + MDBOOK_OUTPUT: '{"markdown": {}}' |
| 54 | + MDBOOK_PREPROCESSOR__GETTEXT__PO_FILE: po/messages.pot |
| 55 | + |
| 56 | + - name: Compare no translation to no-op translation |
| 57 | + run: diff --color=always --unified --recursive expanded no-op |
| 58 | + |
| 59 | + find-translations: |
| 60 | + runs-on: ubuntu-latest |
| 61 | + outputs: |
| 62 | + languages: ${{ steps.find-translations.outputs.languages }} |
| 63 | + steps: |
| 64 | + - name: Checkout |
| 65 | + uses: actions/checkout@v3 |
| 66 | + |
| 67 | + - name: Find translations |
| 68 | + id: find-translations |
| 69 | + shell: python |
| 70 | + run: | |
| 71 | + import os, json, pathlib |
| 72 | + languages = [p.stem for p in pathlib.Path("po").iterdir() if p.suffix == ".po"] |
| 73 | + github_output = open(os.environ["GITHUB_OUTPUT"], "a") |
| 74 | + github_output.write("languages=") |
| 75 | + json.dump(sorted(languages), github_output) |
| 76 | +
|
| 77 | + translations: |
| 78 | + runs-on: ubuntu-latest |
| 79 | + needs: |
| 80 | + - find-translations |
| 81 | + strategy: |
| 82 | + matrix: |
| 83 | + language: ${{ fromJSON(needs.find-translations.outputs.languages) }} |
| 84 | + env: |
| 85 | + MDBOOK_BOOK__LANGUAGE: ${{ matrix.language }} |
| 86 | + steps: |
| 87 | + - name: Checkout |
| 88 | + uses: actions/checkout@v3 |
| 89 | + |
| 90 | + - name: Install Gettext |
| 91 | + run: sudo apt install gettext |
| 92 | + |
| 93 | + - name: Install mdbook |
| 94 | + uses: ./.github/workflows/install-mdbook |
| 95 | + |
| 96 | + - name: Test ${{ matrix.language }} translation |
| 97 | + run: msgfmt --statistics -o /dev/null po/${{ matrix.language }}.po |
| 98 | + |
| 99 | + - name: Build book with ${{ matrix.language }} translation |
| 100 | + run: mdbook build |
| 101 | + |
| 102 | + - name: Upload ${{ matrix.language }} translation |
| 103 | + uses: actions/upload-artifact@v3 |
| 104 | + with: |
| 105 | + name: comprehensive-rust-${{ matrix.language }} |
| 106 | + path: book/ |
| 107 | + |
| 108 | + - name: Test code snippets with ${{ matrix.language }} translation |
| 109 | + run: mdbook test |
0 commit comments