From 6b87c32a71b639ee26bf785a43d67da62982aee2 Mon Sep 17 00:00:00 2001 From: M Bussonnier Date: Tue, 20 Aug 2024 10:27:35 +0200 Subject: [PATCH] Fix a number of nox -s translate issues. Really all the `nox -s translate -- ` should be tested. At least with mypy, it woudl catch most errors --- .github/workflows/CI.yml | 18 ++++++++++++++++++ noxfile.py | 21 +++++++++++++++------ 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0eef947b2..94a6b907a 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -108,6 +108,24 @@ jobs: - name: "Run accessibility tests with playwright 🎭" # build PST, build docs, then run a11y-tests run: python -Im tox run -e py312-docs,a11y-tests + nox-tests: + name: "nox tests (ubuntu-latest, 3.12)" + runs-on: ubuntu-latest + steps: + - name: "Checkout repository 🛎" + uses: actions/checkout@v4 + - name: "Setup CI environment 🛠" + uses: ./.github/actions/set-dev-env + with: + python-version: ${{ env.DEFAULT_PYTHON_VERSION }} + - name: "Run various nox commands" + # build PST, build docs, then run a11y-tests + run: | + pip install nox + nox -s translate -- init + nox -s translate -- extract + nox -s translate -- update + nox -s translate -- compile # Build our docs (PST) on major OSes and check for warnings build-site: diff --git a/noxfile.py b/noxfile.py index c4b2b0fdf..535a4ac87 100644 --- a/noxfile.py +++ b/noxfile.py @@ -155,7 +155,7 @@ def translate(session: nox.Session) -> None: pybabel_cmd, found = (c, True) if found is False: - print( + raise ValueError( "No translate command found. Use like: `nox -s translate -- COMMAND`." "\ndefaulting to `update`" "\nAvailable commands: extract, update, compile, init" @@ -166,18 +166,28 @@ def translate(session: nox.Session) -> None: lan = "en" if len(session.posargs) < 2 else session.posargs[-1] # get the path to the differnet local related pieces - locale_dir = str(ROOT / "src" / "pydata_sphinx_theme" / "locale") + locale_dir_p = ROOT / "src" / "pydata_sphinx_theme" / "locale" + locale_dir = str(locale_dir_p) babel_cfg = str(ROOT / "babel.cfg") - pot_file = str(locale_dir / "sphinx.pot") + pot_file = str(locale_dir_p / "sphinx.pot") # install deps session.install("Babel") + session.install("jinja2") # build the command from the parameters cmd = ["pybabel", pybabel_cmd] if pybabel_cmd == "extract": - cmd += [ROOT, "-F", babel_cfg, "-o", pot_file, "-k", "_ __ l_ lazy_gettext"] + cmd += [ + str(ROOT), + "-F", + babel_cfg, + "-o", + pot_file, + "-k", + "_ __ l_ lazy_gettext", + ] elif pybabel_cmd == "update": cmd += ["-i", pot_file, "-d", locale_dir, "-D", "sphinx"] @@ -187,8 +197,7 @@ def translate(session: nox.Session) -> None: elif pybabel_cmd == "init": cmd += ["-i", pot_file, "-d", locale_dir, "-D", "sphinx", "-l", lan] - - session.run(cmd) + session.run(*cmd) @nox.session()