diff --git a/main/settings_test.py b/main/settings_test.py index a0cb955199..2cfdf042ce 100644 --- a/main/settings_test.py +++ b/main/settings_test.py @@ -3,11 +3,12 @@ """ import importlib +import re import sys +import tomllib from unittest import mock import pytest -import semantic_version from django.conf import settings from django.core import mail from django.core.exceptions import ImproperlyConfigured @@ -162,12 +163,17 @@ def test_opensearch_index_pr_build(self): settings_vars = self.reload_settings() assert settings_vars["OPENSEARCH_INDEX"] == index_name - @staticmethod - def test_semantic_version(): - """ - Verify that we have a semantic compatible version. - """ - semantic_version.Version(settings.VERSION) + def test_bump_my_version_format(self): + """Verify VERSION is in sync with pyproject.toml and matches a version format.""" + with open("pyproject.toml", "rb") as f: # noqa: PTH123 + pyproject = tomllib.load(f) + version_pattern = pyproject["tool"]["bumpversion"]["parse"] + package_version = pyproject["project"]["version"] + assert package_version == settings.VERSION + semver_pattern = r"[0-9]+\.[0-9]+\.[0-9]+" + assert re.fullmatch(version_pattern, settings.VERSION) or re.fullmatch( + semver_pattern, settings.VERSION + ), f'VERSION "{settings.VERSION}" does not match calver or semver format' def test_required_settings(self): """ diff --git a/pyproject.toml b/pyproject.toml index 4f6bcec3e9..7c28488e0c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mit-learn" -version = "0.71.0" +version = "0.70.10" description = "Search index for use with other MIT applications." authors = [{ name = "MIT ODL" }] requires-python = ">=3.12,<3.13" @@ -263,3 +263,36 @@ inline-quotes = "double" "*_test.py" = ["ARG001", "E501", "S101", "PLR2004"] "test_*.py" = ["ARG001", "E501", "S101", "PLR2004"] "**/migrations/**" = ["ARG001"] + +[tool.bumpversion] +commit = false +tag = false +parse = "(?P(?:[1-9][0-9]{3})\\.(?:1[0-2]|[1-9])\\.(?:3[0-1]|[12][0-9]|[1-9]))\\.(?P\\d+)" +serialize = ["{release}.{build}"] + +[tool.bumpversion.parts.release] +calver_format = "{YYYY}.{MM}.{DD}" + +[tool.bumpversion.parts.build] +first_value = "1" + +[[tool.bumpversion.files]] +filename = "main/settings.py" +search = 'VERSION = "{current_version}"' +replace = 'VERSION = "{new_version}"' + +[[tool.bumpversion.files]] +filename = "pyproject.toml" +search = 'version = "{current_version}"' +replace = 'version = "{new_version}"' + +[[tool.bumpversion.files]] +filename = "uv.lock" +search = """ +name = "mit-learn" +version = "{current_version}" +source = {{ virtual = "." }}""" +replace = """ +name = "mit-learn" +version = "{new_version}" +source = {{ virtual = "." }}""" diff --git a/uv.lock b/uv.lock index f40be07155..f9d62dacb3 100644 --- a/uv.lock +++ b/uv.lock @@ -2484,7 +2484,7 @@ wheels = [ [[package]] name = "mit-learn" -version = "0.71.0" +version = "0.70.10" source = { virtual = "." } dependencies = [ { name = "attrs" },