Skip to content

Commit 590d003

Browse files
authored
Merge pull request #11 from mbdevpl/feature/test-assets-installation-update
Update the testing environment
2 parents 2300568 + e971ad3 commit 590d003

File tree

6 files changed

+38
-26
lines changed

6 files changed

+38
-26
lines changed

.github/workflows/python.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,34 +15,35 @@ jobs:
1515
python-version: ['3.8', '3.9', '3.10']
1616

1717
steps:
18-
- uses: actions/checkout@v2
18+
- uses: actions/checkout@v3
1919
with:
2020
fetch-depth: 0
21-
- uses: actions/setup-python@v2
21+
- uses: actions/setup-python@v4
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424
architecture: x64
2525
- run: pip install -r requirements_ci.txt
2626
- run: git clone https://github.com/PyCQA/pycodestyle ../pycodestyle
2727
- run: cd ../pycodestyle && python setup.py build && cd -
2828
- run: git clone https://github.com/mbdevpl/argunparse ../argunparse
29-
- run: cd ../argunparse && pip install -r test_requirements.txt && python setup.py build && cd -
29+
- run: cd ../argunparse && pip install -r requirements_test.txt && python setup.py build && cd -
3030
- run: git clone https://github.com/python-semver/python-semver ../semver
31-
- run: cd ../semver && python setup.py build && cd -
32-
- run: pip install jupyter
31+
- run: cd ../semver && python -m build && cd -
3332
- run: python -m coverage run --branch --source . -m unittest -v
34-
# - run: LOGGING_LEVEL=critical python -m coverage run --append --branch --source . -m unittest -v test.test_version
33+
- run: python -m coverage run --append --branch --source . -m unittest -v test.test_version
34+
env:
35+
LOGGING_LEVEL: critical
3536
- run: python -m coverage report --show-missing
3637
- run: codecov
3738
publish:
3839
if: startsWith(github.ref, 'refs/tags/v')
3940
needs: build
4041
runs-on: ubuntu-latest
4142
steps:
42-
- uses: actions/checkout@v2
43+
- uses: actions/checkout@v3
4344
with:
4445
fetch-depth: 0
45-
- uses: actions/setup-python@v2
46+
- uses: actions/setup-python@v4
4647
with:
4748
python-version: '3.10'
4849
architecture: x64

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ RUN set -Eeuxo pipefail && \
6464
cd - && \
6565
git clone https://github.com/mbdevpl/argunparse argunparse && \
6666
cd argunparse && \
67-
pip install -r test_requirements.txt && \
67+
pip install -r requirements_test.txt && \
6868
python setup.py build && \
6969
cd - && \
7070
git clone https://github.com/python-semver/python-semver semver && \
7171
cd semver && \
72-
python setup.py build && \
72+
python -m build && \
7373
cd - && \
7474
pip install jupyter
7575

requirements_ci.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
build ~= 0.10
12
codecov ~= 2.1
23
coverage ~= 6.2
34
flake518 ~= 1.2

setup_boilerplate.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Package(setup_boilerplate.Package):
4444
import docutils.utils
4545
import setuptools
4646

47-
__version__ = '2022.08.27'
47+
__version__ = '2023.03.09'
4848

4949
_LOG = logging.getLogger(__name__)
5050

@@ -202,15 +202,9 @@ def visit_reference(self, node: docutils.nodes.reference) -> None:
202202
# we ignore the section part when checking if file exists
203203
path = path.with_name(path.name[:path.name.index('#')])
204204
try:
205-
resolved_path = path.resolve(strict=True)
205+
self.root_dir.joinpath(path).resolve(strict=True)
206206
except FileNotFoundError:
207207
return
208-
try:
209-
resolved_path.relative_to(self.root_dir)
210-
except ValueError:
211-
return
212-
if not path.is_file():
213-
return
214208
_LOG.debug('RelativeRefFinder: reference points to existing file')
215209
self.references.append(node)
216210

test/examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _remove_version_suffixes(path: pathlib.Path) -> t.Optional[pathlib.Path]:
133133

134134
INCOMPATIBLE_STR_CASES: t.Dict[str, t.Tuple[tuple, dict]] = {
135135
'1.0.0-2': ((1, 0, 0, '-', None, 2), {}),
136-
'1.0.0-0.2': ((1, 0, 0, '-', None, 0, '.', None, 2), {}),
136+
# '1.0.0-0.2': ((1, 0, 0, '-', None, 0, '.', None, 2), {}),
137137
'4.5.0.dev': ((4, 5, 0, '.', 'dev', None), {})}
138138

139139
STR_CASES = dict(itertools.chain(COMPATIBLE_STR_CASES.items(),

test/test_setup.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import importlib
44
import itertools
5+
import logging
56
import os
67
import pathlib
78
import runpy
@@ -12,16 +13,31 @@
1213
import typing as t
1314
import unittest
1415

15-
__version__ = '2022.08.27'
16+
__version__ = '2023.03.09'
17+
18+
_LOG = logging.getLogger(__name__)
19+
20+
21+
def expand_args_by_globbing_items(*args: str) -> t.Tuple[str, ...]:
22+
"""Expand a list of glob expressions."""
23+
cwd = pathlib.Path.cwd()
24+
expanded_args = []
25+
for arg in args:
26+
if '*' not in arg:
27+
expanded_args.append(arg)
28+
continue
29+
expanded_arg = [str(_.relative_to(cwd)) for _ in cwd.glob(arg)]
30+
assert expanded_arg, arg
31+
_LOG.debug('expanded arg "%s" to %s', arg, expanded_arg)
32+
expanded_args += expanded_arg
33+
_LOG.debug('expanded args to %s', expanded_args)
34+
return tuple(expanded_args)
1635

1736

1837
def run_program(*args, glob: bool = False) -> None:
1938
"""Run subprocess with given args. Use path globbing for each arg that contains an asterisk."""
2039
if glob:
21-
cwd = pathlib.Path.cwd()
22-
args = tuple(itertools.chain.from_iterable(
23-
list(str(_.relative_to(cwd)) for _ in cwd.glob(arg)) if '*' in arg else [arg]
24-
for arg in args))
40+
args = expand_args_by_globbing_items(*args)
2541
try:
2642
subprocess.run(args, check=True)
2743
except subprocess.CalledProcessError as err:
@@ -97,7 +113,7 @@ def import_module_member(module_name: str, member_name: str) -> t.Any:
97113
(None, 'setup.py', True), ('this file', 'setup.py', True), (None, 'test/test_setup.py', True),
98114
(None, 'test/test_setup.py#L98', True), ('line 5 of this file', 'setup.py#L5', True),
99115
(None, 'http://site.com', False), (None, '../something/else', False), (None, 'no.thing', False),
100-
(None, '/my/abs/path', False)]
116+
(None, '/my/abs/path', False), ('test dir', 'test', True)]
101117

102118

103119
def get_package_folder_name():
@@ -293,7 +309,7 @@ class Package(package): # pylint: disable=too-few-public-methods, missing-docst
293309

294310
@unittest.skipUnless(os.environ.get('TEST_PACKAGING') or os.environ.get('CI'),
295311
'skipping packaging tests for actual package')
296-
class IntergrationTests(unittest.TestCase):
312+
class IntegrationTests(unittest.TestCase):
297313
"""Test if the boilerplate can actually create a valid package."""
298314

299315
pkg_name = get_package_folder_name()

0 commit comments

Comments
 (0)