From 4ff07792320d69516d79659342464958700bc1f8 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Mon, 26 Aug 2024 12:46:55 +0100 Subject: [PATCH] ci: update ci files according to pymplate --- .github/workflows/main.yml | 13 ++++++++----- conftest.py | 11 ++++++++++- ruff.toml | 2 +- src/orger/modules/auto.py | 2 +- tox.ini | 13 +++++++------ 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a4dfe6e..2724186 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,15 +31,18 @@ jobs: runs-on: ${{ matrix.platform }} + # useful for 'optional' pipelines + # continue-on-error: ${{ matrix.platform == 'windows-latest' }} + steps: # ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation - run: echo "$HOME/.local/bin" >> $GITHUB_PATH - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive fetch-depth: 0 # nicer to have all git history when debugging/for tests @@ -51,7 +54,7 @@ jobs: - run: bash .ci/run - if: matrix.platform == 'ubuntu-latest' # no need to compute coverage for other platforms - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: .coverage.mypy_${{ matrix.platform }}_${{ matrix.python-version }} path: .coverage.mypy/ @@ -65,11 +68,11 @@ jobs: # ugh https://github.com/actions/toolkit/blob/main/docs/commands.md#path-manipulation - run: echo "$HOME/.local/bin" >> $GITHUB_PATH - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.8' - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: submodules: recursive diff --git a/conftest.py b/conftest.py index 466da24..91a43a3 100644 --- a/conftest.py +++ b/conftest.py @@ -2,6 +2,7 @@ # without it, pytest can't discover the package root for some reason # also see https://github.com/karlicoss/pytest_namespace_pkgs for more +import os import pathlib from typing import Optional @@ -24,6 +25,10 @@ def resolve_package_path(path: pathlib.Path) -> Optional[pathlib.Path]: for parent in result.parents: if str(parent) in namespace_pkg_dirs: return parent + if os.name == 'nt': + # ??? for some reason on windows it is trying to call this against conftest? but not on linux/osx + if path.name == 'conftest.py': + return resolve_pkg_path_orig(path) raise RuntimeError("Couldn't determine path for ", path) _pytest.pathlib.resolve_package_path = resolve_package_path @@ -34,5 +39,9 @@ def resolve_package_path(path: pathlib.Path) -> Optional[pathlib.Path]: # not sure what are the consequences.. maybe it wouldn't be able to run against installed packages? not sure.. search_pypath_orig = _pytest.main.search_pypath def search_pypath(module_name: str) -> str: - return str(root_dir) + mpath = root_dir / module_name.replace('.', os.sep) + if not mpath.is_dir(): + mpath = mpath.with_suffix('.py') + assert mpath.exists(), mpath # just in case + return str(mpath) _pytest.main.search_pypath = search_pypath diff --git a/ruff.toml b/ruff.toml index 0be93e0..54f621c 100644 --- a/ruff.toml +++ b/ruff.toml @@ -1,4 +1,4 @@ -ignore = [ +lint.ignore = [ ### too opinionated style checks "E501", # too long lines "E702", # Multiple statements on one line (semicolon) diff --git a/src/orger/modules/auto.py b/src/orger/modules/auto.py index 5c2acbc..3648f61 100755 --- a/src/orger/modules/auto.py +++ b/src/orger/modules/auto.py @@ -10,7 +10,7 @@ from more_itertools import bucket -from my.core.common import asdict +from my.core.types import asdict def pp_item(i, **kwargs) -> str: diff --git a/tox.ini b/tox.ini index 20e80ac..ce9dd52 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ passenv = [testenv:ruff] commands = {envpython} -m pip install --use-pep517 -e .[testing] - {envpython} -m ruff src/ + {envpython} -m ruff check src/ # note: --use-pep517 here is necessary for tox --parallel flag to work properly @@ -54,11 +54,12 @@ commands = commands = {envpython} -m pip install --use-pep517 -e .[testing,optional] {envpython} -m pip install HPI - {envpython} -m my.core module install my.pocket - {envpython} -m my.core module install my.reddit - {envpython} -m my.core module install my.instapaper - {envpython} -m my.core module install my.pinboard - {envpython} -m my.core module install my.kobo + {envpython} -m my.core module install \ + my.pocket \ + my.reddit \ + my.instapaper \ + my.pinboard \ + my.kobo {envpython} -m mypy --install-types --non-interactive \ -p {[testenv]package_name}.modules \