-
Notifications
You must be signed in to change notification settings - Fork 3
Add sample workflows docs #131
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
Merged
rffontenelle
merged 7 commits into
python-docs-translations:main
from
StanFromIreland:workflows-rst
Jun 9, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b9aa7f7
Add sample workflows docs
StanFromIreland 8cf7f7a
Fix index
StanFromIreland 9cea151
Fix markup
StanFromIreland c297381
Updates
StanFromIreland 3e124f5
Apply suggestions from code review
StanFromIreland 4197e64
Changes
StanFromIreland 9027a7d
Move & reword
StanFromIreland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
================ | ||
GitHub Workflows | ||
================ | ||
|
||
All Python documentation translation repositories are hosted on `GitHub <https://github.com>`_. | ||
GitHub provides a very useful `CI <https://en.wikipedia.org/wiki/Continuous_integration>`_ | ||
system, *GitHub Actions*, which runs *workflows*. Workflows are particularly useful | ||
for testing projects, in translation repos they can be used to update translations | ||
from Transifex, lint translated files, and test build the translated documentation. | ||
|
||
This repository provides three sample workflows: a Linting workflow, a Test Build | ||
workflow, and a workflow for pulling translations from Transifex. They can be found | ||
in the `sample-workflows <https://github.com/python-docs-translations/transifex-automations/tree/main/sample-workflows>`_ | ||
directory and explanations of how they work and what you need to do to set them up can be found below. | ||
|
||
.. seealso:: | ||
- `GitHub docs: Writing workflows <https://docs.github.com/en/actions/writing-workflows>`_ | ||
- :doc:`Setting up Transifex <commands>` | ||
|
||
Running Workflows | ||
----------------- | ||
|
||
To run on of our provided workflows (or any workflow), put the file in the | ||
``.github/workflows`` folder and it will run automatically depending on how it | ||
is configured. | ||
|
||
General Overview | ||
---------------- | ||
|
||
.. code-block:: yaml | ||
|
||
name: Linting Workflow | ||
|
||
The name can be freely configured and will be displayed in the "Actions" tab. | ||
|
||
.. code-block:: yaml | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * *' | ||
|
||
Using `cron <https://en.wikipedia.org/wiki/Cron>`_, the frequency of the workflow | ||
runs can be set. In the sample workflows it is configured to ``'0 0 * * *'``, | ||
meaning it will run once daily. See `crontab.guru <https://crontab.guru/>`_ for | ||
a simple cron editor. | ||
|
||
.. code-block:: yaml | ||
|
||
on: | ||
... | ||
push: | ||
branches: | ||
- '*' | ||
workflow_dispatch: | ||
|
||
The workflow can also be set to run under different conditions, in the case of the | ||
sample workflows it is set to run on a ``push`` to any branch, and can be run | ||
manually due to the ``workflow_dispatch`` option. | ||
|
||
.. code-block:: yaml | ||
|
||
jobs: | ||
|
||
All jobs or sections under ``jobs:`` will be run. The sample workflows can be | ||
merged into one by combining all of their jobs. (Note: there must only be one `jobs:`) | ||
|
||
In the workflows, replace all instances of ``XX`` with your `IETF <https://datatracker.ietf.org/doc/html/rfc5646.html>`_ | ||
language tag, as described in `PEP 545 <https://peps.python.org/pep-0545/#language-tag>`_. | ||
These tools, however, require and underscore (``_``) rather than a dash (``-``); | ||
for example ``pl`` or ``pt_BR``. | ||
rffontenelle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
Transifex Pull Workflow | ||
----------------------- | ||
|
||
How to configure the `Transifex Pull Workflow <https://github.com/python-docs-translations/transifex-automations/blob/main/sample-workflows/transifex-pull.yml>`_. | ||
|
||
This workflow automatically pulls updated translations from Transifex, commits | ||
them to the repository, and pushes them back to the relevant branch, if | ||
significant changes are detected. | ||
|
||
Ensure the ``TX_TOKEN`` secret is configured in your repository with your Transifex API token. | ||
For generating your API key, see this `Transifex article <https://help.transifex.com/en/articles/6248858-generating-an-api-token>`_, | ||
for setting up secrets, see this `guide <https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository>`_. | ||
|
||
.. code-block:: yaml | ||
|
||
matrix: | ||
version: [ 3.14 ] | ||
|
||
Set the ``version`` list to the branches for which translations should be updated. | ||
|
||
.. code-block:: yaml | ||
|
||
- name: Filter files | ||
run: | | ||
! git diff -I'^"POT-Creation-Date: ' \ | ||
-I'^"Language-Team: ' \ | ||
-I'^# ' -I'^"Last-Translator: ' \ | ||
--exit-code \ | ||
&& echo "SIGNIFICANT_CHANGES=1" >> $GITHUB_ENV || exit 0 | ||
|
||
This step detects whether the changes are significant by ignoring changes | ||
to the file header. A commit and push only occur if meaningful changes are found, | ||
these filters can be modified to suit. | ||
|
||
|
||
Test Build Workflow | ||
------------------- | ||
|
||
How to configure the `Test Build Workflow <https://github.com/python-docs-translations/transifex-automations/blob/main/sample-workflows/test-build.yml>`_. | ||
|
||
.. code-block:: yaml | ||
|
||
matrix: | ||
version: [ 3.14 ] | ||
format: [ html, latex ] | ||
|
||
Set version to the branches in your translation repository that you want to be | ||
built, for example: ``version: [ 3.14, 3.13, 3.12 ]``, note that this has to be | ||
changed in both ``matrix``'s in the workflow. The format can be modified | ||
to run for just ``html`` if that is preferred. | ||
|
||
.. code-block:: yaml | ||
|
||
- uses: actions/setup-python@master | ||
with: | ||
python-version: 3.12 # pin for Sphinx 3.4.3 for 3.10 | ||
|
||
The ``python-version`` can be unpinned if no branches older than ``3.11`` are set | ||
in the ``version`` list. | ||
|
||
.. code-block:: yaml | ||
|
||
output-pdf: | ||
|
||
Remove the ``output-pdf`` job if you do not want pdf output to be built. The | ||
section also has to be removed if ``latex`` is not in the ``format`` list. | ||
|
||
The workflow uses the ``actions/upload-artifact@master`` tool which allows for | ||
the generated builds to be downloaded. In a run in the "Actions" tab they can be | ||
found in the "Artifacts" section. | ||
|
||
|
||
Linting Workflow | ||
---------------- | ||
|
||
How to configure the po linting `workflow <https://github.com/python-docs-translations/transifex-automations/blob/main/sample-workflows/po-lint.yml>`_. | ||
This workflow will lint all po files on your branch using `sphinx-lint <https://pypi.org/project/sphinx-lint/>`_. | ||
|
||
.. code-block:: yaml | ||
|
||
matrix: | ||
version: [ 3.14 ] | ||
|
||
Set the ``version`` list to the versions you have available and want the linting | ||
workflow to be run on. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.