Skip to content

Commit

Permalink
Verify translations are compiled in the CI
Browse files Browse the repository at this point in the history
Avoids manually running compilemessages locally to check if the compiled
message files are up to date.

Reviewed-by: thedrow
Reviewed-by: stefanfoulis
  • Loading branch information
francoisfreitag committed May 27, 2021
1 parent bcd0608 commit e653a09
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ jobs:
TOXENV: ${{ matrix.tox-environment }}

steps:
- name: Install gettext
run: |
sudo apt-get update
sudo apt-get install -y gettext
- uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
exclude .gitignore
exclude check-translations
exclude sonar-project.properties
prune .github
34 changes: 34 additions & 0 deletions check-translations
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env python

import os
import subprocess
import sys

import django
from django.core.management import call_command


def main():
kwargs = {} if django.VERSION < (3,) else {"ignore": ".tox"}
with open(os.devnull, "w") as devnull:
call_command("compilemessages", **kwargs, stdout=devnull)

result = subprocess.run(
["git", "status", "--porcelain"],
check=True,
stdout=subprocess.PIPE,
)
stdout = result.stdout.decode()
if stdout != "":
print(
f"Unexpected changes found in the workspace:\n\n{stdout}",
file=sys.stderr,
)
sys.exit(1)
assert result.stderr is None


if __name__ == "__main__":
os.environ["DJANGO_SETTINGS_MODULE"] = "tests.settings"
django.setup()
main()
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ commands =
coverage xml -o coverage-reports/coverage.xml
coverage html -d coverage-reports/html
coverage report
python check-translations

[testenv:black]
basepython = python3
Expand Down

0 comments on commit e653a09

Please sign in to comment.