Skip to content

Commit

Permalink
uploading latest changes from @ismoilovdevml
Browse files Browse the repository at this point in the history
  • Loading branch information
orzklv committed Nov 20, 2023
1 parent 82e933c commit 1995260
Show file tree
Hide file tree
Showing 215 changed files with 112,896 additions and 19,642 deletions.
6 changes: 5 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Translations
po/da.po @mgeisler
po/da.po @mgeisler @voss @thedataking
po/de.po @ronaldfw @fechu
po/el.po @Mandragorian
po/es.po @deavid
po/fr.po @sakex @lb034582341
po/it.po @detro @nicomazz @bznein
po/ko.po @jiyongp @jooyunghan
po/pt-BR.po @rastringer @hugojacob
96 changes: 51 additions & 45 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,19 @@ env:
CARGO_TERM_COLOR: always

jobs:
mdbook:
format:
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: Install nightly rustfmt
run: |
rustup default nightly
rustup component add rustfmt
- name: Test code snippets
run: mdbook test
- name: Check Rust formatting
run: cargo fmt --all -- --check

cargo:
runs-on: ubuntu-latest
Expand All @@ -40,68 +39,63 @@ jobs:
- name: Test Rust code
run: cargo test

i18n-helpers:
bare-metal:
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 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: Install dependencies
run: sudo apt update && sudo apt install gcc-aarch64-linux-gnu

- 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: Install toolchain
run: rustup target add ${{ matrix.target }}

- name: Compare no translation to no-op translation
run: diff --color=always --unified --recursive expanded no-op
- name: Build Rust code
working-directory: ${{ matrix.directory }}
run: cargo build

find-translations:
find-languages:
runs-on: ubuntu-latest
outputs:
languages: ${{ steps.find-translations.outputs.languages }}
languages: ${{ steps.find-languages.outputs.languages }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Find translations
id: find-translations
- name: Find languages
id: find-languages
shell: python
run: |
import os, json, pathlib
languages = [p.stem for p in pathlib.Path("po").iterdir() if p.suffix == ".po"]
languages = ["en"] + [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:
build:
runs-on: ubuntu-latest
needs:
- find-translations
- find-languages
strategy:
matrix:
language: ${{ fromJSON(needs.find-translations.outputs.languages) }}
language: ${{ fromJSON(needs.find-languages.outputs.languages) }}
env:
MDBOOK_BOOK__LANGUAGE: ${{ matrix.language }}
steps:
Expand All @@ -112,22 +106,34 @@ jobs:
uses: ./.github/workflows/setup-rust-cache

- name: Install Gettext
if: matrix.language != 'en'
run: sudo apt install gettext

- name: Install mdbook
uses: ./.github/workflows/install-mdbook

- name: Test ${{ matrix.language }} translation
if: matrix.language != 'en'
run: msgfmt --statistics -o /dev/null po/${{ matrix.language }}.po

- name: Build course with ${{ matrix.language }} translation
- name: Build course
run: mdbook build

- name: Upload ${{ matrix.language }} translation
- name: Zip exercise templates
run: zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/
working-directory: book/exerciser

- name: Prepare book for upload
run: |
mv book/html book/comprehensive-rust-${{ matrix.language }}
rm -r book/exerciser
# Upload the book now to retain it in case mdbook test fails.
- name: Upload book
uses: actions/upload-artifact@v3
with:
name: comprehensive-rust-${{ matrix.language }}
path: book/

- name: Test code snippets with ${{ matrix.language }} translation
- name: Test code snippets
run: mdbook test
12 changes: 8 additions & 4 deletions .github/workflows/install-mdbook/action.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
name: Install mdbook and dependencies

description: Install the mdbook with the dependencies we need.
description: Install mdbook with the dependencies we need.

runs:
using: composite
steps:
# The --locked flag is important for reproducible builds. It also
# avoids breakage due to skews between mdbook and mdbook-svgbob.
- name: Install mdbook
run: cargo install mdbook --locked --version 0.4.25
run: cargo install mdbook --locked --version 0.4.28
shell: bash

- name: Install mdbook-svgbob
run: cargo install mdbook-svgbob --locked --version 0.2.1
shell: bash

- name: Install i18n-helpers
run: cargo install --path i18n-helpers --locked
- name: Install mdbook-i18n-helpers
run: cargo install mdbook-i18n-helpers --locked --version 0.1.0
shell: bash

- name: Install exerciser
run: cargo install --path mdbook-exerciser --locked
shell: bash
9 changes: 7 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ concurrency:
env:
CARGO_TERM_COLOR: always
# Update the language picker in index.hbs to link new languages.
LANGUAGES: uz
LANGUAGES: da pt-BR ko

jobs:
publish:
Expand All @@ -40,13 +40,18 @@ jobs:
- name: Build course in English
run: mdbook build -d book

- name: Zip exercise templates
run: cd book/exerciser && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/

- name: Build all translations
run: |
for po_lang in ${{ env.LANGUAGES }}; do
echo "::group::Building $po_lang translation"
MDBOOK_BOOK__LANGUAGE=$po_lang \
MDBOOK_OUTPUT__HTML__SITE_URL=/comprehensive-rust/$po_lang/ \
mdbook build -d book/$po_lang
(cd book/$po_lang/exerciser && zip --recurse-paths ../html/comprehensive-rust-exercises.zip comprehensive-rust-exercises/)
mv book/$po_lang/html book/html/$po_lang
echo "::endgroup::"
done
Expand All @@ -56,7 +61,7 @@ jobs:
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: book
path: book/html

- name: Deploy to GitHub Pages
id: deployment
Expand Down
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Build artifacts
/book/
target/
*.bin

# Translation artifacts
po/messages.pot
po/*.mo

# macOS artifacts
.DS_Store

# Jetbrains IDEs project files
.idea/
.iml
.iws
Loading

0 comments on commit 1995260

Please sign in to comment.