From cb729a02eebf04bccbe4bd22a74c9b49050a4060 Mon Sep 17 00:00:00 2001 From: Nischay Date: Tue, 22 Oct 2024 20:49:32 +0530 Subject: [PATCH] feat: Function to run all i18n tests locally Added centralized script to run all i18n tests and configured pre-commit hook to ensure these tests are run and checks are passed before opening a PR. --- .pre-commit-config.yaml | 8 ++++++++ frontend/i18n/check/run_i18n_checks.py | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 frontend/i18n/check/run_i18n_checks.py diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 7acc8ddd3..ba4361b80 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,6 +15,14 @@ repos: args: [--fix, --exit-non-zero-on-fix] - id: ruff-format + - repo: local + hooks: + - id: run-i18n-checks + name: Run i18n Checks + entry: python frontend/i18n/check/run_i18n_checks.py + language: python + stages: [pre-commit] + # - repo: https://github.com/pre-commit/mirrors-prettier # rev: "v4.0.0-alpha.8" # hooks: diff --git a/frontend/i18n/check/run_i18n_checks.py b/frontend/i18n/check/run_i18n_checks.py new file mode 100644 index 000000000..49a01b3c4 --- /dev/null +++ b/frontend/i18n/check/run_i18n_checks.py @@ -0,0 +1,26 @@ +import subprocess + + +def run_check(script_name): + try: + subprocess.run(["python", f"./frontend/i18n/check/{script_name}"], check=True) + print(f"{script_name} ran successfully.") + except subprocess.CalledProcessError as e: + print(f"Error running {script_name}: {e}") + raise + + +def main(): + checks = [ + "i18n_check_key_identifiers.py", + "i18n_check_non_source_keys.py", + "i18n_check_repeat_values.py", + "i18n_check_unused_keys.py", + ] + + for check in checks: + run_check(check) + + +if __name__ == "__main__": + main()