Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,35 @@ 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
- run: pip install -r requirements_ci.txt
- 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:
if: startsWith(github.ref, 'refs/tags/v')
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
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions requirements_ci.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build ~= 0.10
codecov ~= 2.1
coverage ~= 6.2
flake518 ~= 1.2
Expand Down
10 changes: 2 additions & 8 deletions setup_boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion test/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
30 changes: 23 additions & 7 deletions test/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import importlib
import itertools
import logging
import os
import pathlib
import runpy
Expand All @@ -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:
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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()
Expand Down