Skip to content

Commit f8869ba

Browse files
committed
ci: install Transifex CLI before generating config
1 parent 2dbc487 commit f8869ba

1 file changed

Lines changed: 33 additions & 23 deletions

File tree

‎.github/workflows/transifex-push.yml‎

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ jobs:
5757
sudo apt-get install -y gettext
5858
python -m pip install requests cogapp polib transifex-python sphinx-intl blurb six
5959
60+
- name: Install Transifex CLI
61+
run: |
62+
curl -fsSL https://raw.githubusercontent.com/transifex/cli/master/install.sh \
63+
| bash -s -- "v${TX_CLI_VERSION}"
64+
command -v tx
65+
tx --version
66+
6067
- name: Generate Transifex configuration
6168
run: |
6269
curl -fsSLO https://raw.githubusercontent.com/python-docs-translations/transifex-automations/main/sample-workflows/transifex-util.py
@@ -66,18 +73,17 @@ jobs:
6673
--project-slug "$TX_PROJECT" \
6774
--version "$CPYTHON_VERSION"
6875
69-
- name: Validate custom builtins resource mappings
76+
- name: Validate Transifex configuration
7077
run: |
7178
python - <<'PY'
7279
import configparser
7380
from pathlib import Path
7481
7582
path = Path(".tx/config")
76-
if not path.is_file():
77-
raise SystemExit("ERROR: .tx/config was not generated")
78-
7983
config = configparser.ConfigParser()
80-
config.read(path)
84+
85+
if not path.is_file() or not config.read(path):
86+
raise SystemExit("ERROR: .tx/config was not generated")
8187
8288
expected = {
8389
"builtins--constants",
@@ -90,25 +96,28 @@ jobs:
9096
}
9197
9298
resources = {
93-
section.rsplit(":r:", 1)[-1]
99+
section.rsplit(":r:", 1)[-1]: section
94100
for section in config.sections()
95101
if ":r:" in section
96102
}
97-
missing = expected - resources
98103
104+
missing = expected - resources.keys()
99105
if missing:
100106
raise SystemExit(
101-
"ERROR: generated config is missing custom builtins resources: "
107+
"ERROR: missing builtins resources: "
102108
+ ", ".join(sorted(missing))
103109
)
104110
105-
print("All seven custom builtins resource mappings are present.")
106-
PY
111+
for resource in sorted(expected):
112+
section = resources[resource]
113+
source = config.get(section, "source_file", fallback="").strip()
114+
if source != f"gettext/{resource.replace('--', '/')}.pot":
115+
raise SystemExit(
116+
f"ERROR: unexpected source_file for {resource}: {source}"
117+
)
107118
108-
- name: Install Transifex CLI
109-
working-directory: /usr/local/bin
110-
run: |
111-
curl -fsSL https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash -s -- "v${TX_CLI_VERSION}"
119+
print("Transifex configuration and all seven builtins mappings validated.")
120+
PY
112121
113122
- name: Push Punjabi translations
114123
env:
@@ -148,6 +157,13 @@ jobs:
148157
python -m pip install -r cpython/Doc/requirements.txt
149158
python -m pip install requests cogapp polib transifex-python sphinx-intl blurb six
150159
160+
- name: Install Transifex CLI
161+
run: |
162+
curl -fsSL https://raw.githubusercontent.com/transifex/cli/master/install.sh \
163+
| bash -s -- "v${TX_CLI_VERSION}"
164+
command -v tx
165+
tx --version
166+
151167
- name: Generate gettext source templates
152168
run: |
153169
make -C cpython/Doc gettext
@@ -171,11 +187,10 @@ jobs:
171187
from pathlib import Path
172188
173189
path = Path(".tx/config")
174-
if not path.is_file():
175-
raise SystemExit("ERROR: .tx/config was not generated")
176-
177190
config = configparser.ConfigParser()
178-
config.read(path)
191+
192+
if not path.is_file() or not config.read(path):
193+
raise SystemExit("ERROR: .tx/config was not generated")
179194
180195
missing = []
181196
for section in config.sections():
@@ -191,11 +206,6 @@ jobs:
191206
print("All configured source templates exist.")
192207
PY
193208
194-
- name: Install Transifex CLI
195-
working-directory: /usr/local/bin
196-
run: |
197-
curl -fsSL https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash -s -- "v${TX_CLI_VERSION}"
198-
199209
- name: Push source templates
200210
env:
201211
TX_TOKEN: ${{ secrets.TX_TOKEN }}

0 commit comments

Comments
 (0)