Skip to content

Commit 57d034d

Browse files
committed
[DEV] Code Coverage CI fix & Docs Testing
Release Cookiecutter Python Package v1.5.2
2 parents 6567662 + 3905647 commit 57d034d

File tree

9 files changed

+96
-96
lines changed

9 files changed

+96
-96
lines changed

.github/workflows/test.yaml

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ jobs:
2323
matrix:
2424
platform: [ubuntu-latest, macos-latest]
2525
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
26+
2627
steps:
2728
- uses: actions/checkout@v3
2829
- name: Set up Python ${{ matrix.python-version }}
2930
uses: actions/setup-python@v2
3031
with:
3132
python-version: ${{ matrix.python-version }}
33+
3234
- name: Install dependencies
3335
run: |
3436
python -m pip install --upgrade pip
@@ -45,25 +47,49 @@ jobs:
4547
- name: Specify current package version to assist build tool
4648
run: |
4749
PARSER="src/cookiecutter_python/{{ cookiecutter.project_slug }}/scripts/parse_version.py"
48-
A=$(python "${PARSER}")
49-
echo $A
50-
echo "PKG_VERSION=$A" >> $GITHUB_ENV
50+
PARSED_VERSION=$(python "${PARSER}")
51+
echo $PARSED_VERSION
52+
echo "PKG_VERSION=$PARSED_VERSION" >> $GITHUB_ENV
5153
5254
- name: Run Test Suite
53-
run: tox -vv -s false -- --run-network_bound
55+
run: tox --sitepackages -vv -s false -- -n auto --run-network_bound
5456
env:
5557
PLATFORM: ${{ matrix.platform }}
5658

5759
- name: Check for compliance with Python Best Practices
5860
run: |
5961
DIST_DIR=dist
6062
echo "DIST_DIR=dist" >> $GITHUB_ENV
61-
62-
mkdir "$DIST_DIR"
63+
ls -l ./
64+
mkdir ${DIST_DIR}
6365
mv ".tox/${DIST_DIR}/cookiecutter_python-${PKG_VERSION}.tar.gz" "${DIST_DIR}"
6466
mv ".tox/${DIST_DIR}/cookiecutter_python-${PKG_VERSION}-py3-none-any.whl" "${DIST_DIR}"
6567
tox -e check -vv -s false
6668
69+
- name: Aggregate Test Coverage Data
70+
run: tox -e coverage --sitepackages -vv -s false
71+
72+
- run: pip install coverage[toml]>=5.1
73+
74+
- name: Send Coverage Data to Codecov
75+
uses: codecov/codecov-action@v2
76+
with:
77+
directory: ./.tox
78+
env_vars: OS,PYTHON
79+
fail_ci_if_error: true
80+
files: ./.tox/coverage.xml
81+
flags: unittests
82+
name: codecov-umbrella
83+
verbose: true
84+
85+
- name: Install documentation test dependencies
86+
if: ${{ matrix.platform == 'macos-latest' && matrix.python-version != '3.6' }}
87+
run: brew install enchant
88+
89+
- name: Run Documentation Tests
90+
if: ${{ matrix.platform == 'ubuntu-latest' || matrix.python-version != '3.6' }}
91+
run: tox -e docs --sitepackages -vv -s false
92+
6793
- name: Upload Source & Wheel distributions as Artefacts
6894
uses: actions/upload-artifact@v2
6995
with:
@@ -72,33 +98,14 @@ jobs:
7298
path: ${{ env.DIST_DIR }}
7399
if-no-files-found: error
74100

75-
- name: Aggregate Test Coverage Data
76-
run: |
77-
python -m pip install coverage
78-
tox -e coverage --sitepackages -vv -s false
79-
80101
- name: Upload Coverage Data as Artefacts
81102
uses: actions/upload-artifact@v2
82103
with:
83104
name: coverage-xml-data
84105
path: ./.tox/coverage.xml
85106
if-no-files-found: error
86107

87-
host_coverage_results:
88-
needs: test_suite
89-
runs-on: ubuntu-latest
90-
steps:
91-
- name: Download Coverage Data
92-
uses: actions/download-artifact@v2
93-
with:
94-
name: coverage-xml-data
95-
- name: Send Coverage Data to Codecov
96-
uses: codecov/codecov-action@v2
97-
with:
98-
directory: .
99-
env_vars: OS,PYTHON
100-
fail_ci_if_error: true
101-
files: coverage.xml
102-
flags: unittests
103-
name: codecov-umbrella
104-
verbose: true
108+
# - name: Download Coverage Data
109+
# uses: actions/download-artifact@v2
110+
# with:
111+
# name: coverage-xml-data

CHANGELOG.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,23 @@
22
Changelog
33
=========
44

5+
1.5.2 (2022-06-22)
6+
==================
7+
8+
Development Update fixing the communication between the CI server and the Test
9+
Coverage Hosting Service. It also enable CI tests for the Documentation
10+
side of the project.
11+
12+
Changes
13+
^^^^^^^
14+
15+
ci
16+
""
17+
- install pyenchant on macos using homebrew
18+
- test documentation tests and building command
19+
- upload code coverage data to codecov.io from within the 'test_suite' job
20+
21+
522
1.5.1 (2022-06-20)
623
==================
724

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ For more complex use cases, you can modify the Template and also leverage all of
196196

197197
.. Github Releases & Tags
198198
199-
.. |commits_since_specific_tag_on_master| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v1.5.1/master?color=blue&logo=github
199+
.. |commits_since_specific_tag_on_master| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v1.5.2/master?color=blue&logo=github
200200
:alt: GitHub commits since tagged version (branch)
201-
:target: https://github.com/boromir674/cookiecutter-python-package/compare/v1.5.1..master
201+
:target: https://github.com/boromir674/cookiecutter-python-package/compare/v1.5.2..master
202202

203203
.. |commits_since_latest_github_release| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/latest?color=blue&logo=semver&sort=semver
204204
:alt: GitHub commits since latest release (by SemVer)

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ build-backend = "poetry.core.masonry.api"
1010
## Also renders on pypi as 'subtitle'
1111
[tool.poetry]
1212
name = "cookiecutter_python"
13-
version = "1.5.1"
13+
version = "1.5.2"
1414
description = "Yet another modern Python Package (pypi) with emphasis in CI/CD and automation."
1515
authors = ["Konstantinos Lampridis <k.lampridis@hotmail.com>"]
1616
maintainers = ["Konstantinos Lampridis <k.lampridis@hotmail.com>"]
@@ -130,7 +130,6 @@ test = [
130130
"pytest-explicit",
131131
"pytest-xdist",
132132
"pytest-object-getter",
133-
"gitpython",
134133
]
135134
docs = [
136135
"sphinx",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.5.1'
1+
__version__ = '1.5.2'

src/cookiecutter_python/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
from cookiecutter.exceptions import (
32
CookiecutterException,
43
UndefinedVariableInTemplate,
@@ -9,8 +8,9 @@
98

109
cookiecutter_exceptions = load(CookiecutterException, 'cookiecutter')
1110

11+
1212
exceptions = {
13-
'critical': cookiecutter_exceptions + [ContextVariableDoesNotExist],
13+
'critical': cookiecutter_exceptions + [ContextVariableDoesNotExist], # type: ignore
1414
'non-critical': (
1515
CheckPypiError,
1616
)

src/cookiecutter_python/utils.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from os import path
22
import sys
3-
from typing import Optional, Type, TypeVar
3+
from typing import List, Optional, Type, TypeVar
44
from inspect import isclass
55
from pkgutil import iter_modules
66
from importlib import import_module
@@ -9,7 +9,7 @@
99
T = TypeVar('T')
1010

1111

12-
def load(interface: Type[T], dire: Optional[str] = None) -> None:
12+
def load(interface: Type[T], module: Optional[str] = None) -> List[Type[T]]:
1313
"""Dynamically import all class objects that implement the given interface.
1414
1515
The classes (class objects) are discovered and imported in the namespace, by
@@ -27,32 +27,30 @@ def load(interface: Type[T], dire: Optional[str] = None) -> None:
2727
Args:
2828
interface (Type[T]): the type (ie class) that the imported classes
2929
should 'inherit' (subclass) from
30-
dire (str): directory containing the modules to inspect. Defaults to the
31-
same directory as the one where the module of the invoking code
32-
resides.
30+
module (str): module containing the modules to inspect. Defaults to the
31+
same module (directory) as the one where the module of the invoking
32+
code resides.
3333
"""
3434
project_package_location = path.dirname(
3535
path.realpath(path.dirname(path.realpath(__file__))))
36-
37-
if not dire: # set as dir the directory path where the invoking code is
36+
if module is None: # set path as the dir where the invoking code is
3837
namespace = sys._getframe(1).f_globals # caller's globals
39-
dire = path.dirname(path.realpath(namespace['__file__']))
40-
# dot representation as in an import statement: ie software_release.utils
41-
_module = str(dire).replace(str(project_package_location), '')[1:].replace('/', '.')
38+
directory: str = path.dirname(path.realpath(namespace['__file__']))
39+
_module = directory.replace(str(project_package_location), '')[1:].replace('/', '.')
4240
else:
43-
_module = dire
41+
directory = str(module).replace('/', '.')
42+
_module = module
4443

4544
objects = []
46-
# iterate through the modules in the dire folder
47-
for (_, module_name, _) in iter_modules([dire]):
48-
49-
module = import_module('{package}.{module}'.format(
45+
# iterate through the modules inside the directory
46+
for (_, module_name, _) in iter_modules([directory]):
47+
module_object = import_module('{package}.{module}'.format(
5048
package=_module,
5149
module=module_name
5250
))
5351

54-
for attribute_name in dir(module):
55-
attribute = getattr(module, attribute_name)
52+
for attribute_name in dir(module_object):
53+
attribute = getattr(module_object, attribute_name)
5654

5755
if isclass(attribute) and issubclass(attribute, interface):
5856
# Add the class to this package's variables
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
1+
class CookiecutterException(Exception): ...
2+
3+
14
class InvalidConfiguration(Exception): ...
5+
6+
7+
class UndefinedVariableInTemplate(Exception): ...

0 commit comments

Comments
 (0)