-
Notifications
You must be signed in to change notification settings - Fork 45
84 lines (69 loc) · 2.7 KB
/
validate-translation-files.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# Validate the po files to ensure translation files are compilable.
name: Validate translation PO files
on:
- pull_request
jobs:
validate-po-files:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
# Define .po filepaths, so we can skip this action unless a .po
# file has been modified in this diff
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
pofiles:
- '**.po'
# Clones the openedx-translations repo
- name: clone openedx/openedx-translations
if: steps.filter.outputs.pofiles == 'true'
uses: actions/checkout@v3
- name: Install gettext
if: steps.filter.outputs.pofiles == 'true'
run: |
sudo apt install -y gettext
- name: setup python
if: steps.filter.outputs.pofiles == 'true'
uses: actions/setup-python@v4
id: setup_python
with:
python-version: '3.8'
cache: pip
cache-dependency-path: |
requirements/translations.txt
- name: Install requirements
if: steps.filter.outputs.pofiles == 'true'
run: |
python --version
make translations_scripts_requirements
- name: Validate translation files
id: validate_translation_files
if: steps.filter.outputs.pofiles == 'true'
run: |
has_validation_errors=0
python scripts/validate_translation_files.py 2>validation_errors.txt || has_validation_errors=1
cat validation_errors.txt
{
echo 'VALIDATION_ERRORS<<EOF'
fold -w 100 -s validation_errors.txt
echo EOF
} >> "$GITHUB_OUTPUT"
exit $has_validation_errors
- name: Post translation validation results as a comment
# Due to GitHub Actions security reasons posting a comment isn't possible on fork pull requests.
# This shouldn't be an issue, because bots writes directly to this repository.
if: ${{ always() && !github.event.pull_request.head.repo.fork }}
uses: mshick/add-pr-comment@7c0890544fb33b0bdd2e59467fbacb62e028a096
with:
message: |
:white_check_mark: All translation files are valid.
This comment has been posted by the `validate-translation-files.yml` GitHub Actions workflow.
message-failure: |
:warning: There are errors in the translation files:
```
${{ steps.validate_translation_files.outputs.VALIDATION_ERRORS || 'No errors were reported.' }}
```
This comment has been posted by the `validate-translation-files.yml` GitHub Actions workflow.