From 996e17ef47467087970fc9d15181d8dcf4f6225d Mon Sep 17 00:00:00 2001 From: Serhii Tereshchenko Date: Sat, 1 Jun 2024 16:09:16 +0300 Subject: [PATCH] fix: Fix CI; Use latest python versions; drop old pythons --- .github/workflows/base.yml | 24 ++++++++++---------- ci_tools/nox_utils.py | 13 +++++------ noxfile-requirements.txt | 2 +- noxfile.py | 19 +++++++--------- setup.cfg | 23 +++++++------------ tests/pyright/__snapshots__/test_typing.ambr | 10 ++++---- 6 files changed, 39 insertions(+), 52 deletions(-) diff --git a/.github/workflows/base.yml b/.github/workflows/base.yml index 1ba4d3a..3409177 100644 --- a/.github/workflows/base.yml +++ b/.github/workflows/base.yml @@ -17,10 +17,10 @@ jobs: list_nox_test_sessions: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v1 + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5 with: - python-version: 3.7 + python-version: 3.12 architecture: x64 - name: Install noxfile requirements @@ -49,11 +49,11 @@ jobs: - uses: actions/checkout@v2 # Conda install - - name: Install conda v3.7 - uses: conda-incubator/setup-miniconda@v2 + - name: Install conda v3.12 + uses: conda-incubator/setup-miniconda@v3 with: # auto-update-conda: true - python-version: 3.7 + python-version: 3.12 activate-environment: noxenv - run: conda info shell: bash -l {0} # so that conda works @@ -85,10 +85,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Install conda v3.7 - uses: conda-incubator/setup-miniconda@v2 + - name: Install conda v3.12 + uses: conda-incubator/setup-miniconda@v3 with: - python-version: '3.10' + python-version: '3.12' activate-environment: noxenv - name: Install noxfile requirements @@ -118,11 +118,11 @@ jobs: path: ./docs/reports # Conda install - - name: Install conda v3.7 - uses: conda-incubator/setup-miniconda@v2 + - name: Install conda v3.12 + uses: conda-incubator/setup-miniconda@v3 with: # auto-update-conda: true - python-version: 3.7 + python-version: 3.12 activate-environment: noxenv - run: conda info shell: bash -l {0} # so that conda works diff --git a/ci_tools/nox_utils.py b/ci_tools/nox_utils.py index 4cb8d7d..d7afa25 100644 --- a/ci_tools/nox_utils.py +++ b/ci_tools/nox_utils.py @@ -21,7 +21,7 @@ nox_logger = logging.getLogger("nox") -PY27, PY35, PY36, PY37, PY38, PY39, PY310 = "2.7", "3.5", "3.6", "3.7", "3.8", "3.9", "3.10" +PY38, PY39, PY310, PY311, PY312 = "3.8", "3.9", "3.10", "3.11", "3.12" DONT_INSTALL = "dont_install" @@ -713,14 +713,13 @@ async def async_popen(): # bind the out and err streams - see https://stackoverflow.com/a/59041913/7262247 # to mimic nox behaviour we only use a single capturing list outlines = [] - await asyncio.wait([ + async with asyncio.TaskGroup() as tg: # process out is only redirected to STDOUT if not silent - _read_stream(process.stdout, lambda l: tee(l, sinklist=outlines, sinkstream=log_file_stream, - quiet=silent, verbosepipe=sys.stdout)), + tg.create_task(_read_stream(process.stdout, lambda l: tee(l, sinklist=outlines, sinkstream=log_file_stream, + quiet=silent, verbosepipe=sys.stdout))) # process err is always redirected to STDOUT (quiet=False) with a specific label - _read_stream(process.stderr, lambda l: tee(l, sinklist=outlines, sinkstream=log_file_stream, - quiet=False, verbosepipe=sys.stdout, label="ERR:")) - ]) + tg.create_task(_read_stream(process.stderr, lambda l: tee(l, sinklist=outlines, sinkstream=log_file_stream, + quiet=False, verbosepipe=sys.stdout, label="ERR:"))) return_code = await process.wait() # make sur the process has ended and retrieve its return code return return_code, outlines diff --git a/noxfile-requirements.txt b/noxfile-requirements.txt index 6fb3e1c..dccba12 100644 --- a/noxfile-requirements.txt +++ b/noxfile-requirements.txt @@ -1,4 +1,4 @@ -nox +nox~=2023.4.22 toml makefun setuptools_scm # used in 'release' diff --git a/noxfile.py b/noxfile.py index fa195a2..8e03f90 100644 --- a/noxfile.py +++ b/noxfile.py @@ -10,7 +10,7 @@ # add parent folder to python path so that we can import noxfile_utils.py # note that you need to "pip install -r noxfile-requiterements.txt" for this file to work. sys.path.append(str(Path(__file__).parent / "ci_tools")) -from nox_utils import PY27, PY37, PY36, PY35, PY38, PY39, PY310, power_session, rm_folder, rm_file, PowerSession # noqa +from nox_utils import PY38, PY39, PY310, PY311, PY312, power_session, rm_folder, rm_file, PowerSession # noqa pkg_name = "decopatch" @@ -18,15 +18,12 @@ gh_repo = "python-decopatch" ENVS = { - # python 3.10 is not available on conda yet - # PY310: {"coverage": False, "pkg_specs": {"pip": ">19"}}, + PY312: {"coverage": False, "pkg_specs": {"pip": ">19"}}, + PY311: {"coverage": False, "pkg_specs": {"pip": ">19"}}, + PY310: {"coverage": False, "pkg_specs": {"pip": ">19"}}, PY39: {"coverage": False, "pkg_specs": {"pip": ">19"}}, - PY38: {"coverage": False, "pkg_specs": {"pip": ">19"}}, - PY27: {"coverage": False, "pkg_specs": {"pip": ">10"}}, - PY35: {"coverage": False, "pkg_specs": {"pip": ">10"}}, - PY36: {"coverage": False, "pkg_specs": {"pip": ">19"}}, # IMPORTANT: this should be last so that the folder docs/reports is not deleted afterwards - PY37: {"coverage": True, "pkg_specs": {"pip": ">19"}}, # , "pytest-html": "1.9.0" + PY38: {"coverage": True, "pkg_specs": {"pip": ">19"}}, # , "pytest-html": "1.9.0" } # set the default activated sessions, minimal for CI @@ -176,7 +173,7 @@ def flake8(session: PowerSession): rm_file(Folders.flake8_intermediate_file) -@power_session(python=[PY37]) +@power_session(python=[PY38]) def docs(session: PowerSession): """Generates the doc and serves it on a local http server. Pass '-- build' to build statically instead.""" @@ -189,7 +186,7 @@ def docs(session: PowerSession): session.run2("mkdocs serve") -@power_session(python=[PY37]) +@power_session(python=[PY38]) def publish(session: PowerSession): """Deploy the docs+reports on github pages. Note: this rebuilds the docs""" @@ -214,7 +211,7 @@ def publish(session: PowerSession): # session.run2('codecov -t %s -f %s' % (codecov_token, Folders.coverage_xml)) -@power_session(python=[PY37]) +@power_session(python=[PY38]) def release(session: PowerSession): """Create a release on github corresponding to the latest tag""" diff --git a/setup.cfg b/setup.cfg index 936e613..af334c6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -19,14 +19,11 @@ classifiers = License :: OSI Approved :: BSD License Topic :: Software Development :: Libraries :: Python Modules Programming Language :: Python - Programming Language :: Python :: 2 - Programming Language :: Python :: 2.7 - Programming Language :: Python :: 3 - Programming Language :: Python :: 3.5 - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 + Programming Language :: Python :: 3.12 [options] # one day these will be able to come from requirement files, see https://github.com/pypa/setuptools/issues/1951. But will it be better ? @@ -40,16 +37,12 @@ install_requires = funcsigs;python_version<'3.3' enum34;python_version<'3.4' tests_require = - pytest - pytest_cases + pytest~=8.2.1 + pytest_cases~=3.8.5 # syrupy, pyright and mypy is used for testing type correctness. - syrupy>2;python_version>'3.6' - pyright;python_version>'3.6' - mypy;python_version>'3.6' - # for some reason these pytest dependencies were not declared in old versions of pytest - six;python_version<'3.6' - attr;python_version<'3.6' - pluggy;python_version<'3.6' + syrupy~=4.6.1 + pyright==1.1.365 + mypy~=1.10.0 # test_suite = tests --> no need apparently # diff --git a/tests/pyright/__snapshots__/test_typing.ambr b/tests/pyright/__snapshots__/test_typing.ambr index d1c328c..f77a8aa 100644 --- a/tests/pyright/__snapshots__/test_typing.ambr +++ b/tests/pyright/__snapshots__/test_typing.ambr @@ -1,6 +1,4 @@ -# This file is generated by [syrupy](https://github.com/tophat/syrupy), -# do not edit manually. -# To update - run `pytest --snapshot-update` +# serializer version: 1 # name: test_typing list([ dict({ @@ -18,7 +16,7 @@ 'line': 15, }), }), - 'rule': 'reportGeneralTypeIssues', + 'rule': 'reportCallIssue', 'severity': 'error', }), dict({ @@ -36,7 +34,7 @@ 'line': 36, }), }), - 'rule': 'reportGeneralTypeIssues', + 'rule': 'reportArgumentType', 'severity': 'error', }), dict({ @@ -54,7 +52,7 @@ 'line': 52, }), }), - 'rule': 'reportGeneralTypeIssues', + 'rule': 'reportArgumentType', 'severity': 'error', }), ])