Add zero-width space checker in CI #380
Workflow file for this run
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
# Run some tests in the Python Doc translations | |
name: Check | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "Branch name corresponding to a Python version" | |
required: true | |
type: string | |
tx_project: | |
description: "Name of the Transifex translation project" | |
required: true | |
type: string | |
workflow_call: | |
inputs: | |
version: | |
description: "Branch name corresponding to a Python version" | |
required: true | |
type: string | |
tx_project: | |
description: "Name of the Transifex translation project" | |
required: true | |
type: string | |
secrets: | |
TELEGRAM_TOKEN: | |
description: "Token required for interacting with Telegram API" | |
required: false | |
TELEGRAM_TO: | |
description: "Account ID that will receive the telegram notification" | |
required: false | |
permissions: | |
contents: read | |
env: | |
PYDOC_LANGUAGE: pt_BR | |
PYDOC_REPO: ${{ github.server_url }}/${{ github.repository }} | |
PYDOC_VERSION: ${{ inputs.version }} | |
jobs: | |
# Build documentation handling warnings as errors. | |
# If success, upload built docs. If failure, notify telegram and upload logs. | |
build: | |
name: Build translated docs | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 5 | |
- name: Set up Python 3 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ inputs.version }} | |
cache: pip | |
allow-prereleases: true | |
- name: Make sure the repository is up to date | |
if: github.event_name != 'pull_request' | |
run: git pull --rebase | |
- name: setup | |
run: ./scripts/setup.sh | |
- name: Add problem matcher | |
uses: sphinx-doc/[email protected] | |
- name: Build docs | |
id: build | |
run: ./scripts/build.sh | |
- name: Upload artifact - docs | |
if: steps.build.outcome == 'success' | |
uses: actions/[email protected] | |
with: | |
name: docs | |
path: cpython/Doc/build/html | |
- name: Prepare notification (only on error) | |
if: always() && steps.build.outcome == 'failure' | |
id: prepare | |
run: | | |
scripts/prepmsg.sh logs/sphinxwarnings.txt logs/notify.txt | |
cat logs/notify.txt | |
env: | |
GITHUB_JOB: ${{ github.job }} | |
GITHUB_RUN_ID: ${{ github.run_id }} | |
- name: Notify via Telegram | |
if: always() && steps.prepare.outcome == 'success' && github.event_name == 'schedule' && inputs.tx_project == 'python-newest' | |
uses: appleboy/[email protected] | |
with: | |
to: ${{ secrets.TELEGRAM_TO }} | |
token: ${{ secrets.TELEGRAM_TOKEN }} | |
format: markdown | |
disable_web_page_preview: true | |
message_file: logs/notify.txt | |
- name: Upload artifact - log files | |
if: always() && steps.build.outcome == 'failure' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ inputs.version }}-build-logs | |
path: logs/* | |
# Run sphinx-lint to find wrong reST syntax in PO files. Always store logs. | |
# If issues are found, notify telegram and upload logs. | |
lint: | |
name: Lint translations | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 5 | |
- name: Set up Python 3 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ inputs.version }} | |
cache: pip | |
allow-prereleases: true | |
- name: Make sure the repository is up to date | |
if: github.event_name != 'pull_request' | |
run: git pull --rebase | |
- name: setup | |
run: ./scripts/setup.sh | |
- name: Add problem matcher | |
uses: rffontenelle/[email protected] | |
- name: lint translations files | |
id: lint | |
run: ./scripts/lint.sh | |
- name: Prepare notification (only on error) | |
if: always() && steps.lint.outcome == 'failure' | |
id: prepare | |
run: | | |
scripts/prepmsg.sh logs/sphinxlint.txt logs/notify.txt | |
cat logs/notify.txt | |
env: | |
GITHUB_JOB: ${{ github.job }} | |
GITHUB_RUN_ID: ${{ github.run_id }} | |
- name: Notify via Telegram | |
if: always() && steps.prepare.outcome == 'success' && github.event_name == 'schedule' && inputs.tx_project == 'python-newest' | |
uses: appleboy/[email protected] | |
with: | |
to: ${{ secrets.TELEGRAM_TO }} | |
token: ${{ secrets.TELEGRAM_TOKEN }} | |
format: markdown | |
disable_web_page_preview: true | |
message_file: logs/notify.txt | |
- name: Upload artifact - log files | |
if: always() && steps.lint.outcome == 'failure' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ inputs.version }}-lint-logs | |
path: logs/* | |
# Check for zero-width space charcters in translations. | |
# These are known to come together with (some?) machine translation like Google translate, | |
# and - as one of the consequences - it may avoid Transifex glossary matching (e.g. variáveis) | |
zero-width-space: | |
name: Check for zero-width space characters | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ inputs.version }} | |
- name: Make sure the repository is up to date | |
if: github.event_name != 'pull_request' | |
run: git pull --rebase | |
- name: Remove zero-width space characters | |
run: | | |
sed -i 's/\xe2\x80\x8b//g' *.po **/*.po | |
- name: Show difference (error if there is any) | |
git diff --exit-code |