Compare commits
28 Commits
28eaf580b4
...
4906d867d0
Author | SHA1 | Date | |
---|---|---|---|
|
4906d867d0 | ||
|
930d1b14b1 | ||
|
02fe81d919 | ||
|
849874cec6 | ||
|
da1e716dde | ||
|
d2a3d5de6f | ||
|
f5204b496f | ||
|
3eb8b3da81 | ||
|
405ce258f2 | ||
|
1138c97865 | ||
|
8b214aab3d | ||
|
6a2b5da00b | ||
|
5c9bcfdac2 | ||
|
05b2278154 | ||
|
8976f24186 | ||
|
2de8d7d597 | ||
|
29daef3b46 | ||
|
98fb6dada1 | ||
|
81f0cf33aa | ||
|
4d25ef7719 | ||
|
eecdc5661d | ||
|
f36e7be2d8 | ||
|
a273f83873 | ||
|
0ae43a314a | ||
|
df27ad2041 | ||
|
06671174b2 | ||
|
036b720f2e | ||
|
b6bfc2409c |
75
.github/workflows/unittests.yaml
vendored
Normal file
75
.github/workflows/unittests.yaml
vendored
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
name: Pytest
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
- feature/refactor
|
||||||
|
pull_request: {}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
name: Unit Tests
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-22.04, windows-latest, macos-latest]
|
||||||
|
python-version: ["3.8", "3.9", "3.10", "3.11"]
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
cache: pip
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install pytest pytest-cov
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
- name: Test
|
||||||
|
run: |
|
||||||
|
pytest
|
||||||
|
|
||||||
|
coverage:
|
||||||
|
name: Coverage Summary
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
permissions:
|
||||||
|
pull-requests: write
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
if: github.event_name == 'pull_request'
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: "3.11"
|
||||||
|
cache: pip
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install pytest pytest-cov
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
- name: Run Coverage
|
||||||
|
run: |
|
||||||
|
pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=semver | tee pytest-coverage.txt
|
||||||
|
|
||||||
|
- name: Comment Result Summary
|
||||||
|
uses: MishaKav/pytest-coverage-comment@main
|
||||||
|
with:
|
||||||
|
pytest-coverage-path: ./pytest-coverage.txt
|
||||||
|
junitxml-path: ./pytest.xml
|
@ -1,7 +1,7 @@
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from typing import Union, List
|
from typing import Union, List
|
||||||
from functools import cache
|
from functools import lru_cache
|
||||||
|
|
||||||
import toml
|
import toml
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ class Git(SCM):
|
|||||||
|
|
||||||
def _run_command(
|
def _run_command(
|
||||||
self, *args: str, throwExceptions: bool = True
|
self, *args: str, throwExceptions: bool = True
|
||||||
) -> subprocess.CompletedProcess[str]:
|
) -> subprocess.CompletedProcess:
|
||||||
return subprocess.run(
|
return subprocess.run(
|
||||||
args,
|
args,
|
||||||
capture_output=True,
|
capture_output=True,
|
||||||
@ -82,13 +82,17 @@ class Git(SCM):
|
|||||||
f"Error getting latest tagged git version: {str(e.stderr).rstrip()}"
|
f"Error getting latest tagged git version: {str(e.stderr).rstrip()}"
|
||||||
)
|
)
|
||||||
|
|
||||||
if len(tagged_versions) > 0 and tagged_versions[-1] != "":
|
if (
|
||||||
|
tagged_versions is not None
|
||||||
|
and len(tagged_versions) > 0
|
||||||
|
and tagged_versions[-1] != ""
|
||||||
|
):
|
||||||
version = tagged_versions[-1]
|
version = tagged_versions[-1]
|
||||||
|
|
||||||
logger.debug(f"Tag Version: {version}")
|
logger.debug(f"Tag Version: {version}")
|
||||||
return version
|
return version
|
||||||
|
|
||||||
@cache
|
@lru_cache(maxsize=None)
|
||||||
def get_branch(self) -> str:
|
def get_branch(self) -> str:
|
||||||
"""
|
"""
|
||||||
Get the main branch
|
Get the main branch
|
||||||
@ -97,7 +101,7 @@ class Git(SCM):
|
|||||||
proc = self._run_command(self.git_bin, "rev-parse", "--abbrev-ref", "HEAD")
|
proc = self._run_command(self.git_bin, "rev-parse", "--abbrev-ref", "HEAD")
|
||||||
return proc.stdout.rstrip()
|
return proc.stdout.rstrip()
|
||||||
|
|
||||||
@cache
|
@lru_cache(maxsize=None)
|
||||||
def get_merge_branch(self) -> Union[str, None]:
|
def get_merge_branch(self) -> Union[str, None]:
|
||||||
"""
|
"""
|
||||||
Get the branches involved in the merge
|
Get the branches involved in the merge
|
||||||
|
@ -67,10 +67,8 @@ class TestSemVer(unittest.TestCase):
|
|||||||
@mock.patch("toml.load")
|
@mock.patch("toml.load")
|
||||||
@mock.patch("pathlib.Path.is_file")
|
@mock.patch("pathlib.Path.is_file")
|
||||||
@mock.patch("builtins.open", mock.mock_open())
|
@mock.patch("builtins.open", mock.mock_open())
|
||||||
@mock.patch("semver.logger.warning")
|
|
||||||
def test_update_file_version(
|
def test_update_file_version(
|
||||||
self,
|
self,
|
||||||
mock_logger: mock.Mock,
|
|
||||||
mock_path_is_file: mock.Mock,
|
mock_path_is_file: mock.Mock,
|
||||||
mock_toml_load: mock.Mock,
|
mock_toml_load: mock.Mock,
|
||||||
):
|
):
|
||||||
@ -83,11 +81,9 @@ class TestSemVer(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
mock_path_is_file.return_value = True
|
mock_path_is_file.return_value = True
|
||||||
self.semver._update_file_version("1.0.1", "1.0.0")
|
self.semver._update_file_version("1.0.1", "1.0.0")
|
||||||
mock_logger.assert_not_called()
|
|
||||||
|
|
||||||
mock_path_is_file.return_value = False
|
mock_path_is_file.return_value = False
|
||||||
self.semver._update_file_version("1.0.1", "1.0.0")
|
self.semver._update_file_version("1.0.1", "1.0.0")
|
||||||
mock_logger.assert_called_once()
|
|
||||||
|
|
||||||
@mock.patch("semver.semver.SemVer._version_repo", mock.MagicMock())
|
@mock.patch("semver.semver.SemVer._version_repo", mock.MagicMock())
|
||||||
def test_run_ok(self):
|
def test_run_ok(self):
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from typing import List
|
from typing import List
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from functools import cache
|
from functools import lru_cache
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
import toml
|
import toml
|
||||||
@ -8,7 +8,7 @@ import toml
|
|||||||
from semver.exceptions import SemverException
|
from semver.exceptions import SemverException
|
||||||
|
|
||||||
|
|
||||||
@cache
|
@lru_cache(maxsize=None)
|
||||||
def get_settings() -> dict:
|
def get_settings() -> dict:
|
||||||
"""
|
"""
|
||||||
Get the settings from the config file
|
Get the settings from the config file
|
||||||
|
@ -24,7 +24,9 @@ classifiers =
|
|||||||
[options]
|
[options]
|
||||||
include_package_data = True
|
include_package_data = True
|
||||||
packages = find:
|
packages = find:
|
||||||
python_requires = >=3.7, <4
|
python_requires = >=3.8, <4
|
||||||
|
install_requires =
|
||||||
|
toml
|
||||||
|
|
||||||
[options.packages.find]
|
[options.packages.find]
|
||||||
exclude =
|
exclude =
|
||||||
|
Loading…
x
Reference in New Issue
Block a user