Skip to content
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
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.git
.github
.mypy_cache
.pytest_cache
.ruff_cache
.venv
__pycache__
build
dist
50 changes: 50 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]

steps:
- uses: actions/checkout@v4

- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --group dev

- name: Run tests
run: uv run pytest

- name: Lint
run: uv run ruff check .

- name: Type-check
run: uv run mypy

- name: Build distribution artifacts
run: uv build

- name: Validate built package
run: uv run twine check dist/*

- name: Verify install from wheel
run: |
uv venv .venv-install
uv pip install --python .venv-install/bin/python dist/*.whl
.venv-install/bin/python -c "from datemath import datemath; print(datemath('now-1d'))"
.venv-install/bin/python -c "import datemath; print(datemath.__version__)"
39 changes: 24 additions & 15 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,29 @@
name: Release Packages

on:
release:
types:
- released
types:
- published

jobs:
release-to-pypi:
runs-on: ubuntu-20.04
publish:
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- uses: actions/checkout@v2
- name: install requirements for python3
run: pip3 install -r requirements.txt
- name: package and upload python3
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
PYTHON_DATEMATH_VERSION: ${{ github.event.release.tag_name }}
run: |
python3 setup.py sdist bdist_wheel
twine upload dist/*
- uses: actions/checkout@v4

- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
python-version: "3.14"

- name: Build artifacts
run: uv build

- name: Validate distribution metadata
run: uv run --with twine twine check dist/*

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
31 changes: 31 additions & 0 deletions .github/workflows/semantic-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Semantic Release

on:
push:
branches:
- master

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up uv
uses: astral-sh/setup-uv@v6
with:
python-version: "3.14"

- name: Install development dependencies
run: uv sync --group dev

- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: uv run semantic-release -c .releaserc.toml version
27 changes: 0 additions & 27 deletions .github/workflows/tests.yaml

This file was deleted.

1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ __pycache__/
# due to using tox and pytest
.tox
.cache

32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
hooks:
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.5
hooks:
- id: ruff-check
args: [--fix]
- id: ruff-format

- repo: local
hooks:
- id: mypy
name: mypy
entry: uv run mypy
language: system
pass_filenames: false
stages: [pre-push]

- id: pytest
name: pytest
entry: uv run pytest
language: system
pass_filenames: false
stages: [pre-push]
40 changes: 40 additions & 0 deletions .releaserc.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[semantic_release]
version_variables = ["datemath/_version.py:__version__"]
commit_message = "chore(release): {version} [skip ci]"
commit_parser = "conventional"
major_on_zero = false
tag_format = "v{version}"

[semantic_release.branches.main]
match = "(main|master)"
prerelease = false
prerelease_token = "rc"

[semantic_release.changelog]
mode = "update"

[semantic_release.changelog.default_templates]
changelog_file = "CHANGELOG.md"
output_format = "md"
mask_initial_release = false

[semantic_release.commit_author]
env = "GIT_COMMIT_AUTHOR"
default = "github-actions <actions@github.com>"

[semantic_release.commit_parser_options]
minor_tags = ["feat"]
patch_tags = ["fix", "perf"]
other_allowed_tags = ["build", "chore", "ci", "docs", "refactor", "style", "test"]
allowed_tags = ["feat", "fix", "perf", "build", "chore", "ci", "docs", "refactor", "style", "test"]
default_bump_level = 0
parse_squash_commits = true
ignore_merge_commits = true

[semantic_release.remote]
name = "origin"
type = "github"

[semantic_release.publish]
dist_glob_patterns = ["dist/*"]
upload_to_vcs_release = true
37 changes: 25 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
### changed
- Modernized packaging and developer workflow around `pyproject.toml`, `uv`, `pytest`, `ruff`, and `mypy`
- Updated CI and release automation to use the new build and verification flow
- Replaced the legacy single-file `unittest` suite with a `pytest` test layout while preserving the existing behavior coverage
- Updated the Docker image to a current Python base image and removed the old `requirements.txt` and `setup.py` install path

### compatibility
- Support remains Python `3.10+`
- During the modernization pass, the floor was briefly evaluated at `3.11+`, but it was set to `3.10+` instead because the library and tooling still work cleanly there and it keeps a broader install base without adding meaningful maintenance overhead
- Previous published support before this change was Python `3.8+`; this update intentionally drops `3.8` and `3.9` to align the project with a more current 2026 baseline while keeping `3.10` available
- `zoneinfo` is now used in tests instead of `pytz`, but this does not require raising the runtime floor beyond Python `3.10`

## [3.0.3] - 2024-09-12
Please use 3.0.3 going forward! 3.0.2 has a breaking bug.

Expand All @@ -16,7 +29,7 @@ Please use 3.0.3 going forward! 3.0.2 has a breaking bug.
## [3.0.2] - 2024-09-11
### added
- Feat: Complete typing with strict type-checking [#43](https://github.com/nickmaccarthy/python-datemath/pull/43) Thank you @Avasam!
- Feat: Added `__version__` to verify the version of the module.
- Feat: Added `__version__` to verify the version of the module.
- Feat: Added Dockerfile and relevant verify.py to help with local development and testing

### chore
Expand All @@ -31,15 +44,15 @@ Please use 3.0.3 going forward! 3.0.2 has a breaking bug.
- Fix: move more pypi configurations to setup.cfg and out of setup.py


## [3.0.1] - 2024-08-23
## [3.0.1] - 2024-08-23
### fixed
- Fix: Race condition in timezone tests: https://github.com/nickmaccarthy/python-datemath/issues/36
- Fix: Updated arrow version: https://github.com/nickmaccarthy/python-datemath/issues/32
- Fix: mypy type hint checking in tests: https://github.com/nickmaccarthy/python-datemath/issues/31
- Fix: mypy type hint checking in tests: https://github.com/nickmaccarthy/python-datemath/issues/31
- Fix: SyntaxWarning: invalid escape sequence in `re.match()`: https://github.com/nickmaccarthy/python-datemath/pull/39
- Fix: Licence Classifier: https://github.com/nickmaccarthy/python-datemath/pull/34
- Fix: Bump certifi to latest: https://github.com/nickmaccarthy/python-datemath/pull/38
### added
### added
- Feat: Typehint support: https://github.com/nickmaccarthy/python-datemath/issues/31
- Feat: Renamed CHANGELOG.md to keepachangelog.org format

Expand All @@ -50,13 +63,13 @@ Please use 3.0.3 going forward! 3.0.2 has a breaking bug.
- python 2.7 support. Python 3.8+ will only be supported going forward

## [1.5.5] - 2021-04-26
### fixed
### fixed
- fix: [Issue #28](https://github.com/nickmaccarthy/python-datemath/issues/28)
* `datemath()` object now returns the expected `datetime` object instead of an `Arrow` object
* added tests to catch invalid object types of helpers

## [1.5.4] - 2021-04-20
### Unused
### Unused
- skipped due to name conflict on pypi, all changes in this are from `1.5.3`

## [1.5.3] - 2021-04-16
Expand All @@ -72,7 +85,7 @@ Please use 3.0.3 going forward! 3.0.2 has a breaking bug.
### fixed
- FIX: [Issue #15](https://github.com/nickmaccarthy/python-datemath/issues/15) - Fixed issue with parser finding invalid timeunits and throwing correct errors
### added
- Feat: [Issue #16](https://github.com/nickmaccarthy/python-datemath/issues/16) - Added support for parser to accecpt a epoch/unix timestamp but throw an error on epoch milli's since arrow can't support that.
- Feat: [Issue #16](https://github.com/nickmaccarthy/python-datemath/issues/16) - Added support for parser to accecpt a epoch/unix timestamp but throw an error on epoch milli's since arrow can't support that.

## [1.5.0] - 2019-11-09

Expand All @@ -84,7 +97,7 @@ Please use 3.0.3 going forward! 3.0.2 has a breaking bug.

** PLEASE DO NOT USE THIS VERSION, use `1.5.0+` instead. This may not compile on your system due to a missing VERSION.txt which was fixed in `1.5.0+` **

### fixed
### fixed
- [FIX] [Issue #9](https://github.com/nickmaccarthy/python-datemath/issues/9) && [Issue #8](https://github.com/nickmaccarthy/python-datemath/issues/8) - Fixing deprecated arrow `replace()` function with `shift()`.
- [FIX] Arrow upgrade to `0.15.2` to fix the above mentioned issues
- [FIX] Modifed `tests.py` to account for the timestamp change (tz is now `+0000`, instead of `-0000`)
Expand All @@ -101,7 +114,7 @@ Please use 3.0.3 going forward! 3.0.2 has a breaking bug.
* skipped due to name conflict on pypi, all changes are in `1.4.9`

## [1.4.7] - 2017-11-10
### fixed
### fixed
- [FIX] Fixed timezone for date strings: [Issue #6](https://github.com/nickmaccarthy/python-datemath/issues/6)

## [1.4.5] - 2017-03-21
Expand All @@ -114,12 +127,12 @@ Please use 3.0.3 going forward! 3.0.2 has a breaking bug.
<Arrow [2016-01-01T23:59:00+00:00]>
>>> dm('now/d')
<Arrow [2016-01-01T00:00:00+00:00]>
```
```

## [1.4.4] - 2016-12-28
### fixed
- [FIX] Fixed bug with expression logic and rounding: https://github.com/nickmaccarthy/python-datemath/pull/2

## [1.4.3] - 2016-03-31
### added
[NEW] Floats are now supported for days, hours, and seconds units. Example ```now-2.5d```, ```now-3.2h```. Any other unit other than days, hours, or seconds that is a float will be converted to an int and floored due to the datetime() module not being able to handle them.
### added
[NEW] Floats are now supported for days, hours, and seconds units. Example ```now-2.5d```, ```now-3.2h```. Any other unit other than days, hours, or seconds that is a float will be converted to an int and floored due to the datetime() module not being able to handle them.
28 changes: 14 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# Use an official Python runtime as the base image
FROM python:3.9
FROM python:3.14-slim

# Set the working directory in the container
WORKDIR /app
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=1

# Copy the contents of your project to the working directory
COPY . .
WORKDIR /app

# Install the required dependencies
RUN pip install -r requirements.txt
COPY pyproject.toml uv.lock README.md LICENSE ./
COPY datemath ./datemath
COPY tests ./tests
COPY verify.py ./

# Run setup.py to install your module
RUN python3 setup.py install
RUN pip install --upgrade pip \
&& pip install uv \
&& uv sync --group dev --frozen

# Run your tests to ensure everything works as expected
RUN python3 -m unittest discover
RUN uv run pytest

# Set the entrypoint command to run your module
CMD ["python3", "verify.py"]
CMD ["uv", "run", "python", "verify.py"]
1 change: 0 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,3 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Loading
Loading