Skip to content

Commit

Permalink
Merge pull request #21 from dryan/change-to-uv
Browse files Browse the repository at this point in the history
Change to uv
  • Loading branch information
dryan authored Nov 13, 2024
2 parents f7365bd + f4f360c commit 7c58a7a
Show file tree
Hide file tree
Showing 10 changed files with 224 additions and 565 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release_new_tags.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ jobs:
pypi:
name: Publish
runs-on: ubuntu-latest
permissions:
id-token: write
steps:
- uses: actions/checkout@v4
- name: Setup Python 3.13
uses: actions/setup-python@v5
with:
python-version: "3.13"
python-version-file: "pyproject.toml"
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Build & Publish
run: |
uv build
uv publish
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
5 changes: 1 addition & 4 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,4 @@ jobs:
run: uv run ruff check d3ploy
- name: Run Python Unit Tests
run: |
uv run coverage erase
uv run coverage run --source='d3ploy' tests/test.py "$@"
uv run coverage html
uv run coverage report --fail-under=100 --skip-covered
uv run pytest
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,10 @@ repos:
- id: ruff-format
repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
- hooks:
- entry: bash -c './check-versions-match.py'
id: check-versions-match
language: system
name: Check versions match
pass_filenames: false
repo: local
66 changes: 66 additions & 0 deletions bump-version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
#! /usr/bin/env python3

import argparse
import pathlib
import re

from packaging.version import Version
from packaging.version import parse


def main():
args_parser = argparse.ArgumentParser()
args_parser.add_argument(
"version_type",
choices=["major", "minor", "patch"],
default="patch",
nargs="?",
)
args_parser.add_argument("--prerelease", action="store_true")
args = args_parser.parse_args()
version_type = args.version_type
prerelease = args.prerelease
pyproject_content = pathlib.Path("pyproject.toml").read_text()
pyproject_version = re.search(r'version = "(.+)"', pyproject_content).group(1)
pyproject_version = parse(pyproject_version)
new_version = Version(str(pyproject_version))
match version_type:
case "major":
new_version = Version(f'{".".join([str(new_version.major + 1), "0", "0"])}')
case "minor":
new_version = Version(
f'{".".join([str(new_version.major), str(new_version.minor + 1), "0"])}'
)
case "patch":
if pyproject_version.pre and prerelease:
new_version = Version(
f'{".".join([str(new_version.major), str(new_version.minor), str(new_version.micro)])}{new_version.pre[0]}{new_version.pre[1] + 1}'
)
else:
new_version = Version(
f'{".".join([str(new_version.major), str(new_version.minor), str(new_version.micro + 1)])}'
)
if prerelease and not new_version.pre:
new_version = Version(
f"{new_version}{new_version.pre[0] or 'a' if new_version.pre else 'a'}{new_version.pre[1] + 1 if new_version.pre else 1}"
)

if new_version != pyproject_version:
print(f"Updating version from {pyproject_version} to {new_version}")
pyproject_content = re.sub(
r'version = "(.+)"',
f'version = "{new_version}"',
pyproject_content,
)
pathlib.Path("pyproject.toml").write_text(pyproject_content)
d3ploy_content = pathlib.Path("d3ploy/d3ploy.py").read_text()
d3ploy_content = re.sub(
r'VERSION = "(.+)"',
f'VERSION = "{new_version}"',
d3ploy_content,
)
pathlib.Path("d3ploy/d3ploy.py").write_text(d3ploy_content)


if __name__ == "__main__":
main()
24 changes: 24 additions & 0 deletions check-versions-match.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#! /usr/bin/env python3

import os
import pathlib
import re
import sys


def main():
d3ploy_content = pathlib.Path("d3ploy/d3ploy.py").read_text()
d3ploy_version = re.search(r'VERSION = "(.+)"', d3ploy_content)
pyproject_content = pathlib.Path("pyproject.toml").read_text()
pyproject_version = re.search(r'version = "(.+)"', pyproject_content)

if d3ploy_version.group(1) != pyproject_version.group(1):
print(
f"Versions do not match: {d3ploy_version.group(1)} != {pyproject_version.group(1)}",
file=sys.stderr,
)
sys.exit(os.EX_DATAERR)


if __name__ == "__main__":
main()
8 changes: 4 additions & 4 deletions d3ploy/d3ploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from colorama import init as colorama_init
from tqdm import tqdm

VERSION = "4.3.0"
VERSION = "4.4.2"

VALID_ACLS = [
"private",
Expand Down Expand Up @@ -96,7 +96,7 @@ def display_output():
while len(OUTPUT):
text, is_error = OUTPUT.pop()
if QUIET and not is_error:
continue
continue # pragma: no cover
buffer = sys.stderr if is_error else sys.stdout
buffer.write(f"{text}\n")
buffer.flush()
Expand Down Expand Up @@ -336,7 +336,7 @@ def determine_files_to_sync(
for root, dir_names, file_names in os.walk(local_path):
for dir_name in dir_names:
if dir_name in svc_directories:
continue
continue # pragma: no cover
dir_name = os.path.join(root, dir_name)
gitignore_path = os.path.join(dir_name, ".gitignore")
if os.path.exists(gitignore_path):
Expand Down Expand Up @@ -365,7 +365,7 @@ def determine_files_to_sync(
files.append(file_name)
for svc_directory in svc_directories:
if svc_directory in dir_names:
dir_names.remove(svc_directory)
dir_names.remove(svc_directory) # pragma: no cover
elif local_path.is_file() or local_path.is_symlink():
if not gitignore_spec.match_file(local_path):
files.append(local_path)
Expand Down
17 changes: 10 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "d3ploy"
version = "4.4.1"
version = "4.4.2"
description = "Easily deploy to S3 with multiple environment support."
authors = [
{name = "dryan", email = "[email protected]"},
Expand Down Expand Up @@ -31,19 +31,22 @@ repository = "https://github.com/dryan/d3ploy"
documentation = "https://github.com/dryan/d3ploy#readme"

[project.scripts]
d3ploy = "d3ploy.cli"
d3ploy = "d3ploy:cli"

[tool.ruff.lint.isort]
force-single-line = true

[dependency-groups]
dev = [
"black>=24.10.0",
"coverage>=7.6.4",
"flake8>=7.1.1",
"ipython>=8.29.0",
"isort>=5.13.2",
"pytest-cov>=6.0.0",
"ruff>=0.7.3",
"twine>=5.1.1",
]

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

[tool.pytest.ini_options]
testpaths = ["tests/test*.py"]
addopts = ["--cov=d3ploy", "--cov-report=term-missing", "--cov-report=html", "--cov-fail-under=100"]
8 changes: 0 additions & 8 deletions run_tests.sh

This file was deleted.

Loading

0 comments on commit 7c58a7a

Please sign in to comment.