Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update version handeling #7

Merged
merged 7 commits into from
Apr 19, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
BUMP_TYPE: ${{ github.event.inputs.bump_type }}
run: |
echo "Bumping type: ${{ env.BUMP_TYPE }}"
new_version=$(python -m semvergit -t ${{ env.BUMP_TYPE }} -v)
new_version=$(python -m semvergit -v -t ${{ env.BUMP_TYPE }} -f xls_updater/__about__.py)
echo "new_version=$new_version" >> $GITHUB_OUTPUT

- name: Download Binary Artifact
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ check-lint:
python3 -m pylint --reports=True xls_updater

pytest:
python3 -m pytest -v
python3 -m pytest -v --durations=0

coverage:
python3 -m coverage run --source=xls_updater --module pytest \
Expand Down
27 changes: 6 additions & 21 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "xls-updater"
description = "Convert legacy xls data to newer xlsx format."
readme = "README.md"
requires-python = ">=3.10"
dynamic = ["version"]
keywords = [
"converter",
"xls",
Expand All @@ -25,6 +24,7 @@ classifiers = [
"Topic :: Office/Business :: Financial :: Spreadsheet",
"Topic :: File Formats",
]
dynamic = ["version"]
dependencies = [
"click==8.1.7",
"openpyxl==3.1.2",
Expand Down Expand Up @@ -65,22 +65,11 @@ homepage = "https://github.com/Tranquility2/xls_updater"
repository = "https://github.com/Tranquility2/xls_updater"

[build-system]
requires = [
"hatchling",
"versioningit",
]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.hatch.version]
source = "versioningit"

[tool.versioningit.vcs]
default-tag = "0.0.0"
match = ["v*", ]
method = "git"

[tool.versioningit.tag2version]
rmprefix = "v"
path = "xls_updater/__about__.py"

[tool.pip-tools]
quiet = true
Expand All @@ -100,24 +89,20 @@ include_trailing_comma = true

[tool.black]
line-length = 120
target_version = ["py311"]
include = '\.pyi?$'
exclude = '''
(
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
\.eggs
| \.git
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
)/
| foo.py # also separately exclude a file named foo.py in
# the root of the project
| version.py
)
'''

Expand Down
10 changes: 9 additions & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def mock_convert_xls_to_xlsx(mocker: MockerFixture) -> MagicMock:
return mocker.patch("xls_updater.cli.convert_xls_to_xlsx")


def test_cli(convert_xls_to_xlsx: MagicMock) -> None:
def test_cli_convert(convert_xls_to_xlsx: MagicMock) -> None:
"""Test app."""
runner = CliRunner()
with runner.isolated_filesystem():
Expand All @@ -26,3 +26,11 @@ def test_cli(convert_xls_to_xlsx: MagicMock) -> None:
assert result.exit_code == 0, result.output
convert_xls_to_xlsx.assert_called_once_with(Path("sample.xls"))
Path("sample.xls").unlink()


def test_cli_version() -> None:
"""Test app."""
runner = CliRunner()
result = runner.invoke(cli, ["--version"])
assert result.exit_code == 0, result.output
assert "version" in result.output
3 changes: 3 additions & 0 deletions xls_updater/__about__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Version of the package."""

__version__ = "0.1.12"
3 changes: 2 additions & 1 deletion xls_updater/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

import click

from xls_updater.__about__ import __version__
from xls_updater.app import convert_xls_to_xlsx


@click.group(invoke_without_command=True, no_args_is_help=True)
@click.version_option()
@click.version_option(__version__, "-v", "--version", is_flag=True, help="Show the version.")
@click.argument("src_file_path", type=click.Path(exists=True, path_type=pathlib.Path), required=True)
def cli(src_file_path: pathlib.Path) -> None:
"""Convert an xls file to xlsx."""
Expand Down
Loading