Compare commits

..

No commits in common. "4906d867d0c4df975d3ca2cac10109abb1cce1ef" and "28eaf580b46d9c079fda0efe223d97eec548e6d8" have entirely different histories.

5 changed files with 12 additions and 89 deletions

View File

@ -1,75 +0,0 @@
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

View File

@ -1,7 +1,7 @@
import re
import subprocess
from typing import Union, List
from functools import lru_cache
from functools import cache
import toml
@ -29,7 +29,7 @@ class Git(SCM):
def _run_command(
self, *args: str, throwExceptions: bool = True
) -> subprocess.CompletedProcess:
) -> subprocess.CompletedProcess[str]:
return subprocess.run(
args,
capture_output=True,
@ -82,17 +82,13 @@ class Git(SCM):
f"Error getting latest tagged git version: {str(e.stderr).rstrip()}"
)
if (
tagged_versions is not None
and len(tagged_versions) > 0
and tagged_versions[-1] != ""
):
if len(tagged_versions) > 0 and tagged_versions[-1] != "":
version = tagged_versions[-1]
logger.debug(f"Tag Version: {version}")
return version
@lru_cache(maxsize=None)
@cache
def get_branch(self) -> str:
"""
Get the main branch
@ -101,7 +97,7 @@ class Git(SCM):
proc = self._run_command(self.git_bin, "rev-parse", "--abbrev-ref", "HEAD")
return proc.stdout.rstrip()
@lru_cache(maxsize=None)
@cache
def get_merge_branch(self) -> Union[str, None]:
"""
Get the branches involved in the merge

View File

@ -67,8 +67,10 @@ class TestSemVer(unittest.TestCase):
@mock.patch("toml.load")
@mock.patch("pathlib.Path.is_file")
@mock.patch("builtins.open", mock.mock_open())
@mock.patch("semver.logger.warning")
def test_update_file_version(
self,
mock_logger: mock.Mock,
mock_path_is_file: mock.Mock,
mock_toml_load: mock.Mock,
):
@ -81,9 +83,11 @@ class TestSemVer(unittest.TestCase):
}
mock_path_is_file.return_value = True
self.semver._update_file_version("1.0.1", "1.0.0")
mock_logger.assert_not_called()
mock_path_is_file.return_value = False
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())
def test_run_ok(self):

View File

@ -1,6 +1,6 @@
from typing import List
from pathlib import Path
from functools import lru_cache
from functools import cache
import configparser
import toml
@ -8,7 +8,7 @@ import toml
from semver.exceptions import SemverException
@lru_cache(maxsize=None)
@cache
def get_settings() -> dict:
"""
Get the settings from the config file

View File

@ -24,9 +24,7 @@ classifiers =
[options]
include_package_data = True
packages = find:
python_requires = >=3.8, <4
install_requires =
toml
python_requires = >=3.7, <4
[options.packages.find]
exclude =