Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document translation workflow #2579

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ set -Eeuo pipefail
#
# The src/ and third_party/ directories are left in a dirty state so
# you can run `mdbook test` and other commands afterwards.
#
# See also TRANSLATIONS.md.

book_lang=${1:?"Usage: $0 <book-lang> <dest-dir>"}
dest_dir=${2:?"Usage: $0 <book-lang> <dest-dir>"}
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Publish

# See also TRANSLATIONS.md.

on:
push:
branches:
Expand Down
48 changes: 48 additions & 0 deletions TRANSLATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,54 @@ the hard work, even if it is incomplete.

[CODEOWNERS]: https://github.com/google/comprehensive-rust/blob/main/.github/CODEOWNERS

## Publication Workflow

> This section is for the developers of Comprehensive Rust, but it might give
> you valuable background information on how the translations are published.

When a change is made to the `main` branch, the
[`publish.yml`](https://github.com/google/comprehensive-rust/blob/main/.github/workflows/publish.yml)
GitHub CI workflow starts.

The `publish` job in this workflow will:

- Install dependencies as described in [`CONTRIBUTING`](CONTRIBUTING.md).

- Build every translation of the course, including the original English, using
[`build.sh`](https://github.com/google/comprehensive-rust/blob/main/.github/workflows/build.sh).
The English HTML ends up in `book/html/`, the HTML for the `xx` language ends
up in `book/xx/html/`.

- Publish the entire `book/html/` directory to
https://google.github.io/comprehensive-rust/.

### `build.sh`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should mention when this script is being called (publish.yml and build.yml) and that both times there are artifacts that can be inspected if necessary.


The `build.sh` script is used both when testing code from a PR and when
publishing the finished book.

The job of the script is to call `mdbook build`, but with a few extra steps:

- It will enable the PDF output using `mdbook-pandoc`. This is disabled by
default to make it easier for people to run `mdbook build` without having to
configure LaTeX.

#### Restoring Translations
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should include that the English translation does not involve the git restore step and always builds from HEAD


When building a translation, `build.sh` will restore all Markdown files to how
they looked at the time recorded in the POT-Creation-Date header. This means
that:

- A translation does not degrade when the English text is changed.
- A translation will not received the latest fixes to the English text.

The script restores the Markdown with a simple
`git restore --source $LAST_COMMIT src/ third_party/` command, where
`$LAST_COMMIT` is the commit at the time of the POT-Creation-Date header.

A consequence of this is that we use the latest theme, CSS, JavaScript, etc for
each translation.

## Status reports

Two translation status reports are automatically generated:
Expand Down
Loading