Skip to content

Commit 2e0df78

Browse files
authored
Configure bump-my-version for Concourse release pipeline (#492)
1 parent f086fa2 commit 2e0df78

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
@@ -92,12 +93,17 @@ def test_db_ssl_enable(self):
9293
"sslmode": "require"
9394
}
9495

95-
@staticmethod
96-
def test_semantic_version():
97-
"""
98-
Verify that we have a semantic compatible version.
99-
"""
100-
semantic_version.Version(settings.VERSION)
96+
def test_bump_my_version_format(self):
97+
"""Verify VERSION is in sync with pyproject.toml and matches a version format."""
98+
with open("pyproject.toml", "rb") as f: # noqa: PTH123
99+
pyproject = tomllib.load(f)
100+
version_pattern = pyproject["tool"]["bumpversion"]["parse"]
101+
package_version = pyproject["project"]["version"]
102+
assert package_version == settings.VERSION
103+
semver_pattern = r"[0-9]+\.[0-9]+\.[0-9]+"
104+
assert re.fullmatch(version_pattern, settings.VERSION) or re.fullmatch(
105+
semver_pattern, settings.VERSION
106+
), f'VERSION "{settings.VERSION}" does not match calver or semver format'
101107

102108
def test_required_settings(self):
103109
"""

pyproject.toml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "learn-ai"
3-
version = "0.71.0"
3+
version = "0.32.0"
44
description = "AI applications for MIT Open Learning."
55
authors = [{ name = "MIT ODL" }]
66
requires-python = ">=3.14.5,<3.15"
@@ -213,3 +213,36 @@ inline-quotes = "double"
213213
"*_test.py" = ["ARG001", "E501", "S101", "PLR2004"]
214214
"test_*.py" = ["ARG001", "E501", "S101", "PLR2004"]
215215
"**/migrations/**" = ["ARG001"]
216+
217+
[tool.bumpversion]
218+
commit = false
219+
tag = false
220+
parse = "(?P<release>(?:[1-9][0-9]{3})\\.(?:1[0-2]|[1-9])\\.(?:3[0-1]|[12][0-9]|[1-9]))\\.(?P<build>\\d+)"
221+
serialize = ["{release}.{build}"]
222+
223+
[tool.bumpversion.parts.release]
224+
calver_format = "{YYYY}.{MM}.{DD}"
225+
226+
[tool.bumpversion.parts.build]
227+
first_value = "1"
228+
229+
[[tool.bumpversion.files]]
230+
filename = "main/settings.py"
231+
search = 'VERSION = "{current_version}"'
232+
replace = 'VERSION = "{new_version}"'
233+
234+
[[tool.bumpversion.files]]
235+
filename = "pyproject.toml"
236+
search = 'version = "{current_version}"'
237+
replace = 'version = "{new_version}"'
238+
239+
[[tool.bumpversion.files]]
240+
filename = "uv.lock"
241+
search = """
242+
name = "learn-ai"
243+
version = "{current_version}"
244+
source = {{ virtual = "." }}"""
245+
replace = """
246+
name = "learn-ai"
247+
version = "{new_version}"
248+
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)