diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index d68415d..d08d3f4 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -15,10 +15,10 @@ jobs: python-version: ['3.8', '3.9', '3.10'] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} architecture: x64 @@ -26,12 +26,13 @@ jobs: - run: git clone https://github.com/PyCQA/pycodestyle ../pycodestyle - run: cd ../pycodestyle && python setup.py build && cd - - run: git clone https://github.com/mbdevpl/argunparse ../argunparse - - run: cd ../argunparse && pip install -r test_requirements.txt && python setup.py build && cd - + - run: cd ../argunparse && pip install -r requirements_test.txt && python setup.py build && cd - - run: git clone https://github.com/python-semver/python-semver ../semver - - run: cd ../semver && python setup.py build && cd - - - run: pip install jupyter + - run: cd ../semver && python -m build && cd - - run: python -m coverage run --branch --source . -m unittest -v - # - run: LOGGING_LEVEL=critical python -m coverage run --append --branch --source . -m unittest -v test.test_version + - run: python -m coverage run --append --branch --source . -m unittest -v test.test_version + env: + LOGGING_LEVEL: critical - run: python -m coverage report --show-missing - run: codecov publish: @@ -39,10 +40,10 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: fetch-depth: 0 - - uses: actions/setup-python@v2 + - uses: actions/setup-python@v4 with: python-version: '3.10' architecture: x64 diff --git a/Dockerfile b/Dockerfile index 550a2fc..eb21eb8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,12 +64,12 @@ RUN set -Eeuxo pipefail && \ cd - && \ git clone https://github.com/mbdevpl/argunparse argunparse && \ cd argunparse && \ - pip install -r test_requirements.txt && \ + pip install -r requirements_test.txt && \ python setup.py build && \ cd - && \ git clone https://github.com/python-semver/python-semver semver && \ cd semver && \ - python setup.py build && \ + python -m build && \ cd - && \ pip install jupyter diff --git a/requirements_ci.txt b/requirements_ci.txt index 9d152e5..ae9cda1 100644 --- a/requirements_ci.txt +++ b/requirements_ci.txt @@ -1,3 +1,4 @@ +build ~= 0.10 codecov ~= 2.1 coverage ~= 6.2 flake518 ~= 1.2 diff --git a/setup_boilerplate.py b/setup_boilerplate.py index 7fd8f5b..8f4c5f9 100644 --- a/setup_boilerplate.py +++ b/setup_boilerplate.py @@ -44,7 +44,7 @@ class Package(setup_boilerplate.Package): import docutils.utils import setuptools -__version__ = '2022.08.27' +__version__ = '2023.03.09' _LOG = logging.getLogger(__name__) @@ -202,15 +202,9 @@ def visit_reference(self, node: docutils.nodes.reference) -> None: # we ignore the section part when checking if file exists path = path.with_name(path.name[:path.name.index('#')]) try: - resolved_path = path.resolve(strict=True) + self.root_dir.joinpath(path).resolve(strict=True) except FileNotFoundError: return - try: - resolved_path.relative_to(self.root_dir) - except ValueError: - return - if not path.is_file(): - return _LOG.debug('RelativeRefFinder: reference points to existing file') self.references.append(node) diff --git a/test/examples.py b/test/examples.py index 472e1f1..7c4e0d6 100644 --- a/test/examples.py +++ b/test/examples.py @@ -133,7 +133,7 @@ def _remove_version_suffixes(path: pathlib.Path) -> t.Optional[pathlib.Path]: INCOMPATIBLE_STR_CASES: t.Dict[str, t.Tuple[tuple, dict]] = { '1.0.0-2': ((1, 0, 0, '-', None, 2), {}), - '1.0.0-0.2': ((1, 0, 0, '-', None, 0, '.', None, 2), {}), + # '1.0.0-0.2': ((1, 0, 0, '-', None, 0, '.', None, 2), {}), '4.5.0.dev': ((4, 5, 0, '.', 'dev', None), {})} STR_CASES = dict(itertools.chain(COMPATIBLE_STR_CASES.items(), diff --git a/test/test_setup.py b/test/test_setup.py index 8516d7b..7795ffa 100644 --- a/test/test_setup.py +++ b/test/test_setup.py @@ -2,6 +2,7 @@ import importlib import itertools +import logging import os import pathlib import runpy @@ -12,16 +13,31 @@ import typing as t import unittest -__version__ = '2022.08.27' +__version__ = '2023.03.09' + +_LOG = logging.getLogger(__name__) + + +def expand_args_by_globbing_items(*args: str) -> t.Tuple[str, ...]: + """Expand a list of glob expressions.""" + cwd = pathlib.Path.cwd() + expanded_args = [] + for arg in args: + if '*' not in arg: + expanded_args.append(arg) + continue + expanded_arg = [str(_.relative_to(cwd)) for _ in cwd.glob(arg)] + assert expanded_arg, arg + _LOG.debug('expanded arg "%s" to %s', arg, expanded_arg) + expanded_args += expanded_arg + _LOG.debug('expanded args to %s', expanded_args) + return tuple(expanded_args) def run_program(*args, glob: bool = False) -> None: """Run subprocess with given args. Use path globbing for each arg that contains an asterisk.""" if glob: - cwd = pathlib.Path.cwd() - args = tuple(itertools.chain.from_iterable( - list(str(_.relative_to(cwd)) for _ in cwd.glob(arg)) if '*' in arg else [arg] - for arg in args)) + args = expand_args_by_globbing_items(*args) try: subprocess.run(args, check=True) except subprocess.CalledProcessError as err: @@ -97,7 +113,7 @@ def import_module_member(module_name: str, member_name: str) -> t.Any: (None, 'setup.py', True), ('this file', 'setup.py', True), (None, 'test/test_setup.py', True), (None, 'test/test_setup.py#L98', True), ('line 5 of this file', 'setup.py#L5', True), (None, 'http://site.com', False), (None, '../something/else', False), (None, 'no.thing', False), - (None, '/my/abs/path', False)] + (None, '/my/abs/path', False), ('test dir', 'test', True)] def get_package_folder_name(): @@ -293,7 +309,7 @@ class Package(package): # pylint: disable=too-few-public-methods, missing-docst @unittest.skipUnless(os.environ.get('TEST_PACKAGING') or os.environ.get('CI'), 'skipping packaging tests for actual package') -class IntergrationTests(unittest.TestCase): +class IntegrationTests(unittest.TestCase): """Test if the boilerplate can actually create a valid package.""" pkg_name = get_package_folder_name()