Skip to content

Commit 9126e28

Browse files
committed
Configure bump-my-version for Concourse release pipeline
1 parent 5fb4afb commit 9126e28

3 files changed

Lines changed: 48 additions & 9 deletions

File tree

main/settings_test.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
"""
44

55
import importlib
6+
import re
67
import sys
8+
import tomllib
79
from unittest import mock
810

911
import pytest
10-
import semantic_version
1112
from django.conf import settings
1213
from django.core import mail
1314
from django.core.exceptions import ImproperlyConfigured
@@ -162,12 +163,17 @@ def test_opensearch_index_pr_build(self):
162163
settings_vars = self.reload_settings()
163164
assert settings_vars["OPENSEARCH_INDEX"] == index_name
164165

165-
@staticmethod
166-
def test_semantic_version():
167-
"""
168-
Verify that we have a semantic compatible version.
169-
"""
170-
semantic_version.Version(settings.VERSION)
166+
def test_bump_my_version_format(self):
167+
"""Verify VERSION is in sync with pyproject.toml and matches a version format."""
168+
with open("pyproject.toml", "rb") as f: # noqa: PTH123
169+
pyproject = tomllib.load(f)
170+
version_pattern = pyproject["tool"]["bumpversion"]["parse"]
171+
package_version = pyproject["project"]["version"]
172+
assert package_version == settings.VERSION
173+
semver_pattern = r"[0-9]+\.[0-9]+\.[0-9]+"
174+
assert re.fullmatch(version_pattern, settings.VERSION) or re.fullmatch(
175+
semver_pattern, settings.VERSION
176+
), f'VERSION "{settings.VERSION}" does not match calver or semver format'
171177

172178
def test_required_settings(self):
173179
"""

pyproject.toml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "mit-learn"
3-
version = "0.71.0"
3+
version = "0.70.10"
44
description = "Search index for use with other MIT applications."
55
authors = [{ name = "MIT ODL" }]
66
requires-python = ">=3.12,<3.13"
@@ -263,3 +263,36 @@ inline-quotes = "double"
263263
"*_test.py" = ["ARG001", "E501", "S101", "PLR2004"]
264264
"test_*.py" = ["ARG001", "E501", "S101", "PLR2004"]
265265
"**/migrations/**" = ["ARG001"]
266+
267+
[tool.bumpversion]
268+
commit = false
269+
tag = false
270+
parse = "(?P<release>(?:[1-9][0-9]{3})\\.(?:1[0-2]|[1-9])\\.(?:3[0-1]|[12][0-9]|[1-9]))\\.(?P<build>\\d+)"
271+
serialize = ["{release}.{build}"]
272+
273+
[tool.bumpversion.parts.release]
274+
calver_format = "{YYYY}.{MM}.{DD}"
275+
276+
[tool.bumpversion.parts.build]
277+
first_value = "1"
278+
279+
[[tool.bumpversion.files]]
280+
filename = "main/settings.py"
281+
search = 'VERSION = "{current_version}"'
282+
replace = 'VERSION = "{new_version}"'
283+
284+
[[tool.bumpversion.files]]
285+
filename = "pyproject.toml"
286+
search = 'version = "{current_version}"'
287+
replace = 'version = "{new_version}"'
288+
289+
[[tool.bumpversion.files]]
290+
filename = "uv.lock"
291+
search = """
292+
name = "mit-learn"
293+
version = "{current_version}"
294+
source = {{ virtual = "." }}"""
295+
replace = """
296+
name = "mit-learn"
297+
version = "{new_version}"
298+
source = {{ virtual = "." }}"""

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)