From 38100805bf0d42877d6e321047595a87e859f18b Mon Sep 17 00:00:00 2001 From: Mauricio Alvarez Leon <65101411+BBBmau@users.noreply.github.com> Date: Sun, 2 Mar 2025 10:20:03 -0800 Subject: [PATCH] move update_translations from scons to GHA (#34481) * remove update_translations from scons * update_translations GHA * working GHA * fix scons fails * job name * remove test_update_translations * cleanup * move to repo-maintenance * Update .github/workflows/repo-maintenance.yaml * bring that back --------- Co-authored-by: Shane Smiskol Co-authored-by: Adeeb Shihadeh --- .github/workflows/repo-maintenance.yaml | 26 +++++++++++++++++++++++++ selfdrive/ui/SConscript | 3 --- selfdrive/ui/tests/test_translations.py | 14 +------------ 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/.github/workflows/repo-maintenance.yaml b/.github/workflows/repo-maintenance.yaml index ab0f3c1bee..3bcb143825 100644 --- a/.github/workflows/repo-maintenance.yaml +++ b/.github/workflows/repo-maintenance.yaml @@ -5,7 +5,33 @@ on: - cron: "0 14 * * 1" # every Monday at 2am UTC (6am PST) workflow_dispatch: +env: + BASE_IMAGE: openpilot-base + BUILD: selfdrive/test/docker_build.sh base + RUN: docker run --shm-size 2G -v $PWD:/tmp/openpilot -w /tmp/openpilot -e CI=1 -e PYTHONWARNINGS=error -e FILEREADER_CACHE=1 -e PYTHONPATH=/tmp/openpilot -e NUM_JOBS -e JOB_ID -e GITHUB_ACTION -e GITHUB_REF -e GITHUB_HEAD_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_RUN_ID -v $GITHUB_WORKSPACE/.ci_cache/scons_cache:/tmp/scons_cache -v $GITHUB_WORKSPACE/.ci_cache/comma_download_cache:/tmp/comma_download_cache -v $GITHUB_WORKSPACE/.ci_cache/openpilot_cache:/tmp/openpilot_cache $BASE_IMAGE /bin/bash -c + jobs: + update_translations: + runs-on: ubuntu-latest + if: github.repository == 'commaai/openpilot' + steps: + - uses: actions/checkout@v4 + - uses: ./.github/workflows/setup-with-retry + - name: Update translations + run: | + ${{ env.RUN }} "python3 selfdrive/ui/update_translations.py --vanish" + - name: Create Pull Request + uses: peter-evans/create-pull-request@9153d834b60caba6d51c9b9510b087acf9f33f83 + with: + author: Vehicle Researcher + commit-message: "Update translations" + title: "[bot] Update translations" + body: "Automatic PR from repo-maintenance -> update_translations" + branch: "update-translations" + base: "master" + delete-branch: true + labels: bot + package_updates: name: package_updates runs-on: ubuntu-latest diff --git a/selfdrive/ui/SConscript b/selfdrive/ui/SConscript index 60c82fa645..8fa4b55ea7 100644 --- a/selfdrive/ui/SConscript +++ b/selfdrive/ui/SConscript @@ -40,12 +40,9 @@ translation_sources = [f"#selfdrive/ui/translations/{l}.ts" for l in languages.v translation_targets = [src.replace(".ts", ".qm") for src in translation_sources] lrelease_bin = 'third_party/qt5/larch64/bin/lrelease' if arch == 'larch64' else 'lrelease' -lupdate = qt_env.Command(translation_sources + ["translations/alerts_generated.h"], qt_src + widgets_src, "selfdrive/ui/update_translations.py") lrelease = qt_env.Command(translation_targets, translation_sources, f"{lrelease_bin} $SOURCES") -qt_env.Depends(lrelease, lupdate) qt_env.NoClean(translation_sources) qt_env.Precious(translation_sources) -qt_env.NoCache(lupdate) # create qrc file for compiled translations to include with assets translations_assets_src = "#selfdrive/assets/translations_assets.qrc" diff --git a/selfdrive/ui/tests/test_translations.py b/selfdrive/ui/tests/test_translations.py index 0967152fa4..09dd7c5d8b 100644 --- a/selfdrive/ui/tests/test_translations.py +++ b/selfdrive/ui/tests/test_translations.py @@ -2,14 +2,12 @@ import pytest import json import os import re -import shutil -import tempfile import xml.etree.ElementTree as ET import string import requests from parameterized import parameterized_class -from openpilot.selfdrive.ui.update_translations import TRANSLATIONS_DIR, LANGUAGES_FILE, update_translations +from openpilot.selfdrive.ui.update_translations import TRANSLATIONS_DIR, LANGUAGES_FILE with open(LANGUAGES_FILE) as f: translation_files = json.load(f) @@ -34,16 +32,6 @@ class TestTranslations: assert os.path.exists(os.path.join(TRANSLATIONS_DIR, f"{self.file}.ts")), \ f"{self.name} has no XML translation file, run selfdrive/ui/update_translations.py" - def test_translations_updated(self): - with tempfile.TemporaryDirectory() as tmpdir: - shutil.copytree(TRANSLATIONS_DIR, tmpdir, dirs_exist_ok=True) - update_translations(translation_files=[self.file], translations_dir=tmpdir) - - cur_translations = self._read_translation_file(TRANSLATIONS_DIR, self.file) - new_translations = self._read_translation_file(tmpdir, self.file) - assert cur_translations == new_translations, \ - f"{self.file} ({self.name}) XML translation file out of date. Run selfdrive/ui/update_translations.py to update the translation files" - @pytest.mark.skip("Only test unfinished translations before going to release") def test_unfinished_translations(self): cur_translations = self._read_translation_file(TRANSLATIONS_DIR, self.file)