From fa9ef8dbadd4d6ae26a846f2cbff65bdf8412dc4 Mon Sep 17 00:00:00 2001 From: Maciej Urbanski Date: Sat, 27 Jan 2024 10:13:22 +0100 Subject: [PATCH] autodetect CI python --- .github/workflows/ci.yml | 4 ++-- noxfile.py | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09204408..6616ed14 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -105,10 +105,10 @@ jobs: - name: Install dependencies run: python -m pip install --upgrade nox pdm - name: Run unit tests - run: nox -vs unit -p ${{ matrix.python-version }} -- -v + run: nox -vs unit -- -v - name: Run integration tests if: ${{ env.B2_TEST_APPLICATION_KEY != '' && env.B2_TEST_APPLICATION_KEY_ID != '' }} - run: nox -vs integration -p ${{ matrix.python-version }} -- --dont-cleanup-old-buckets -v + run: nox -vs integration -- --dont-cleanup-old-buckets -v doc: needs: build runs-on: ubuntu-latest diff --git a/noxfile.py b/noxfile.py index dbc25683..cc4c9e3b 100644 --- a/noxfile.py +++ b/noxfile.py @@ -11,6 +11,7 @@ import os import pathlib +import platform import re import subprocess @@ -22,6 +23,12 @@ CI = os.environ.get('CI') is not None NOX_PYTHONS = os.environ.get('NOX_PYTHONS') +if CI and not NOX_PYTHONS: + NOX_PYTHONS = "" + print( + f"CI job mode; using provided interpreter only; equivalent to NOX_PYTHONS={NOX_PYTHONS!r}" + ) + PYTHON_VERSIONS = [ 'pypy3.9', 'pypy3.10', @@ -31,9 +38,13 @@ '3.10', '3.11', '3.12', -] if NOX_PYTHONS is None else NOX_PYTHONS.split(',') +] +if NOX_PYTHONS: + PYTHON_VERSIONS = NOX_PYTHONS.split(',') +elif NOX_PYTHONS == "": + PYTHON_VERSIONS = None -PYTHON_DEFAULT_VERSION = PYTHON_VERSIONS[-1] +PYTHON_DEFAULT_VERSION = PYTHON_VERSIONS[-1] if PYTHON_VERSIONS else None PY_PATHS = ['b2sdk', 'test', 'noxfile.py'] @@ -53,8 +64,8 @@ def pdm_install(session: nox.Session, *args: str, dev: bool = True) -> None: session.run('pdm', 'install', *prod_args, *group_args, external=True) -def skip_coverage(python_version: str) -> bool: - return python_version.startswith('pypy') +def skip_coverage(python_version: str | None) -> bool: + return (python_version or platform.python_implementation()).lower().startswith('pypy') @nox.session(name='format', python=PYTHON_DEFAULT_VERSION)