diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..e98ef21 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,12 @@ +.git +.github +.mypy_cache +.pre-commit-config.yaml +.pytest_cache +.venv +.tox +*.egg-info +build +dist +requirements-dev.txt +test diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 44fee0d..b148d56 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -26,3 +26,30 @@ jobs: with: user: __token__ password: ${{ secrets.PYPI_API_TOKEN }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: bledy/timezone-converter + tags: type=semver,pattern={{version}} + + - name: Login to Docker Hub + id: login-dockerhub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and push + uses: docker/build-push-action@v3 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 7a5fc2d..bd00206 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 @@ -37,7 +37,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 @@ -59,7 +59,7 @@ jobs: strategy: fail-fast: false matrix: - python-version: [3.6, 3.7, 3.8, 3.9] + python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 53c150d..aa170b0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -31,35 +31,40 @@ repos: - id: end-of-file-fixer - id: fix-byte-order-marker - id: fix-encoding-pragma - args: ["--remove"] + args: + - "--remove" - id: mixed-line-ending - id: name-tests-test - id: pretty-format-json - args: ["--autofix"] + args: + - "--autofix" - id: requirements-txt-fixer - id: trailing-whitespace - repo: https://github.com/asottile/reorder_python_imports - rev: v3.3.0 + rev: v3.9.0 hooks: - id: reorder-python-imports - repo: https://github.com/asottile/add-trailing-comma - rev: v2.2.3 + rev: v2.3.0 hooks: - id: add-trailing-comma - args: ["--py36-plus"] + args: + - "--py36-plus" - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.2.0 + rev: v1.3.1 hooks: - id: remove-crlf - id: remove-tabs - repo: https://github.com/asottile/setup-cfg-fmt - rev: v1.20.1 + rev: v2.2.0 hooks: - id: setup-cfg-fmt + args: + - "--include-version-classifiers" - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.9.0 @@ -72,24 +77,26 @@ repos: - id: text-unicode-replacement-char - repo: https://github.com/psf/black - rev: 22.6.0 + rev: 22.10.0 hooks: - id: black - args: ["--skip-string-normalization"] + args: + - "--skip-string-normalization" - repo: https://github.com/pycqa/flake8 - rev: 4.0.1 + rev: 5.0.4 hooks: - id: flake8 - args: ["--max-line-length=88"] + args: + - "--max-line-length=88" - repo: https://github.com/asottile/yesqa - rev: v1.3.0 + rev: v1.4.0 hooks: - id: yesqa - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.961 + rev: v0.982 hooks: - id: mypy additional_dependencies: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..cb60ecf --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM python:3.12-slim-bullseye + +ENV PYTHONUNBUFFERED 1 + +LABEL maintainer="deejaynof@gmail.com" + +RUN : \ + && groupadd --gid 1001 timezone-converter \ + && useradd --uid 1001 --gid timezone-converter --system --create-home --home-dir /home/timezone-converter timezone-converter \ + && : +USER timezone-converter + +WORKDIR /opt +COPY --chown=timezone-converter:timezone-converter . . + +ENV PATH="/home/timezone-converter/.local/bin:$PATH" +RUN : \ + && python3 -m pip --no-cache-dir install . \ + && : + +ENTRYPOINT [ "timezone-converter" ] diff --git a/README.md b/README.md index 536ba2a..0d8d0c2 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,12 @@ pip install -U timezone-converter timezone-converter [ ...] ``` +### Docker + +```bash +docker run --rm -t bledy/timezone-converter [ ...] +``` + ## Features ### Comparison between multiple timezones diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..aa0dc4e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,106 @@ +[build-system] +requires = [ + "hatchling>=1.10.0", +] +build-backend = "hatchling.build" + +[project] +name = "timezone-converter" +version = "0.12.1" +description = "Compare your local timezone with foreign ones." +license = "MIT" +license-files = { paths = ["LICENSE"] } +readme = "README.md" +authors = [ + { name = "Iago Alonso", email = "deejaynof@gmail.com" }, +] +classifiers = [ + "Development Status :: 4 - Beta", + "Environment :: Console", + "Intended Audience :: End Users/Desktop", + "License :: OSI Approved :: MIT License", + "Operating System :: MacOS", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Topic :: Terminals", + "Topic :: Utilities", + "Typing :: Typed", +] +requires-python = ">=3.8" +dependencies = [ + "importlib-metadata", + "pytz>=2022.6", + "rich>=12.6.0", +] + +[project.scripts] +timezone-converter = "timezone_converter.main:main" + +[project.urls] +Homepage = "https://github.com/ibLeDy/timezone-converter" + +[tool.hatch.build.targets.sdist] +include = [ + "timezone_converter", +] +exclude = [ + "tests*", +] + +[tool.hatch.build.targets.wheel] +packages = [ + "timezone_converter", +] + +[tool.mypy] +check_untyped_defs = true +warn_redundant_casts = true +warn_unused_ignores = true +disallow_any_generics = true +disallow_incomplete_defs = true +disallow_untyped_defs = true +no_implicit_optional = true +no_implicit_reexport = true + +[[tool.mypy.overrides]] +module = "tests.*" +disallow_untyped_defs = false + +[tool.coverage.run] +plugins = "covdefaults" + +[tool.tox] +legacy_tox_ini = """ +[tox] +envlist = py38, py39, py310, py311, py312 +isolated_build = True + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 + 3.12: py312 + +[testenv] +commands = + timezone-converter + timezone-converter --help + timezone-converter tijuana + timezone-converter tijuana --single + timezone-converter tijuana --single 14 + timezone-converter tijuana new_york + timezone-converter tijuana new_york --single + timezone-converter tijuana --zone + timezone-converter tijuana --list + timezone-converter tijuana --list tbd +""" diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 820f177..0000000 --- a/setup.cfg +++ /dev/null @@ -1,85 +0,0 @@ -[metadata] -name = timezone_converter -version = 0.10.0 -description = Compare your local timezone with foreign ones. -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/ibLeDy/timezone-converter -author = Iago Alonso -author_email = deejaynof@gmail.com -license = MIT -license_file = LICENSE -classifiers = - Development Status :: 4 - Beta - Environment :: Console - Intended Audience :: End Users/Desktop - License :: OSI Approved :: MIT License - Operating System :: MacOS - Operating System :: Microsoft :: Windows - Operating System :: POSIX :: Linux - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 - Programming Language :: Python :: 3.10 - Programming Language :: Python :: Implementation :: CPython - Topic :: Terminals - Topic :: Utilities - Typing :: Typed - -[options] -packages = find: -install_requires = - pytz>=2021.1 - rich>=10.0.1 - importlib-metadata;python_version<"3.8" -python_requires = >=3.6.1 - -[options.packages.find] -exclude = - tests* - -[options.entry_points] -console_scripts = - timezone-converter = timezone_converter.main:main - -[coverage:run] -plugins = covdefaults - -[tox:tox] -envlist = py36, py37, py38, py39 - -[gh-actions] -python = - 3.6: py36 - 3.7: py37 - 3.8: py38 - 3.9: py39 - -[testenv] -commands = - timezone-converter - timezone-converter --help - timezone-converter tijuana - timezone-converter tijuana --single - timezone-converter tijuana --single 14 - timezone-converter tijuana new_york - timezone-converter tijuana new_york --single - timezone-converter tijuana --zone - timezone-converter tijuana --list - timezone-converter tijuana --list tbd - -[mypy] -check_untyped_defs = true -warn_redundant_casts = true -warn_unused_ignores = true -disallow_any_generics = true -disallow_incomplete_defs = true -disallow_untyped_defs = true -no_implicit_optional = true -no_implicit_reexport = true - -[mypy-tests.*] -disallow_untyped_defs = false diff --git a/setup.py b/setup.py deleted file mode 100644 index 6068493..0000000 --- a/setup.py +++ /dev/null @@ -1,3 +0,0 @@ -from setuptools import setup - -setup() diff --git a/timezone_converter/constants.py b/timezone_converter/constants.py index 7347f7a..f599181 100644 --- a/timezone_converter/constants.py +++ b/timezone_converter/constants.py @@ -1,8 +1,3 @@ -import sys - -if sys.version_info < (3, 8): - import importlib_metadata as metadata -else: - from importlib import metadata +from importlib import metadata VERSION = metadata.version('timezone-converter')