From 91ac4386650b8971ea714ccefa69c9f265151348 Mon Sep 17 00:00:00 2001 From: Mateusz Bysiek Date: Fri, 17 Mar 2023 12:46:20 +0900 Subject: [PATCH 1/6] build: update installation step for a tests asset --- .github/workflows/python.yml | 2 +- Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index d68415d..5f67c99 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -26,7 +26,7 @@ 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 diff --git a/Dockerfile b/Dockerfile index 550a2fc..253899e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -64,7 +64,7 @@ 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 && \ From 953b598b6f2d558b105e0e51bd7c4a26c7eb299f Mon Sep 17 00:00:00 2001 From: Mateusz Bysiek Date: Fri, 17 Mar 2023 13:06:49 +0900 Subject: [PATCH 2/6] build: update installation step for another tests asset --- .github/workflows/python.yml | 3 +-- Dockerfile | 2 +- requirements_ci.txt | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 5f67c99..e66b77d 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -28,8 +28,7 @@ jobs: - run: git clone https://github.com/mbdevpl/argunparse ../argunparse - 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 report --show-missing diff --git a/Dockerfile b/Dockerfile index 253899e..eb21eb8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -69,7 +69,7 @@ RUN set -Eeuxo pipefail && \ 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 From f6e5b0c50414a808e4c9c72d541d08e72cc83b8f Mon Sep 17 00:00:00 2001 From: Mateusz Bysiek Date: Fri, 17 Mar 2023 13:18:42 +0900 Subject: [PATCH 3/6] chore: avoid problematic version string --- test/examples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(), From e5761f65a41b5ebaaf83e9eda3546fcd8ed916b3 Mon Sep 17 00:00:00 2001 From: Mateusz Bysiek Date: Fri, 17 Mar 2023 13:26:15 +0900 Subject: [PATCH 4/6] build(github): test with custom logging level --- .github/workflows/python.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index e66b77d..4c59e63 100644 --- a/.github/workflows/python.yml +++ b/.github/workflows/python.yml @@ -30,7 +30,9 @@ jobs: - run: git clone https://github.com/python-semver/python-semver ../semver - 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: From 5430a57a32069a2ffc96768797fa1a73ed2884ba Mon Sep 17 00:00:00 2001 From: Mateusz Bysiek Date: Fri, 17 Mar 2023 13:29:51 +0900 Subject: [PATCH 5/6] build(github): update action versions --- .github/workflows/python.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml index 4c59e63..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 @@ -40,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 From e971ad3a9e0ee0e5be0bc43deee6bb9e4eaa340a Mon Sep 17 00:00:00 2001 From: Mateusz Bysiek Date: Fri, 17 Mar 2023 13:34:48 +0900 Subject: [PATCH 6/6] chore: update boilerplate --- setup_boilerplate.py | 10 ++-------- test/test_setup.py | 30 +++++++++++++++++++++++------- 2 files changed, 25 insertions(+), 15 deletions(-) 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/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()