Skip to content

Commit 556ea3e

Browse files
authored
Configure bump-my-version for Concourse release pipeline (#3882)
1 parent bfcc83c commit 556ea3e

3 files changed

Lines changed: 50 additions & 10 deletions

File tree

mitxpro/settings_test.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
Validate that our settings functions work
33
"""
44

5+
import re
56
import sys
7+
import tomllib
68
from types import SimpleNamespace
79

810
import pytest
9-
import semantic_version
1011
from django.core import mail
1112
from django.core.exceptions import ImproperlyConfigured
1213
from mitol.common import envs
@@ -158,13 +159,6 @@ def test_db_ssl_enable(monkeypatch, settings_sandbox):
158159
assert settings_vars["DATABASES"]["default"]["OPTIONS"] == {"sslmode": "require"}
159160

160161

161-
def test_semantic_version(settings):
162-
"""
163-
Verify that we have a semantic compatible version.
164-
"""
165-
semantic_version.Version(settings.VERSION)
166-
167-
168162
def test_server_side_cursors_disabled(settings_sandbox):
169163
"""DISABLE_SERVER_SIDE_CURSORS should be true by default"""
170164
settings_vars = settings_sandbox.get()
@@ -179,3 +173,16 @@ def test_server_side_cursors_enabled(settings_sandbox):
179173
assert (
180174
settings_vars["DEFAULT_DATABASE_CONFIG"]["DISABLE_SERVER_SIDE_CURSORS"] is False
181175
)
176+
177+
178+
def test_bump_my_version_format(settings):
179+
"""Verify VERSION is in sync with pyproject.toml and matches a version format."""
180+
with open("pyproject.toml", "rb") as f: # noqa: PTH123
181+
pyproject = tomllib.load(f)
182+
version_pattern = pyproject["tool"]["bumpversion"]["parse"]
183+
package_version = pyproject["project"]["version"]
184+
assert package_version == settings.VERSION
185+
semver_pattern = r"[0-9]+\.[0-9]+\.[0-9]+"
186+
assert re.fullmatch(version_pattern, settings.VERSION) or re.fullmatch(
187+
semver_pattern, settings.VERSION
188+
), f'VERSION "{settings.VERSION}" does not match calver or semver format'

pyproject.toml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "mitxpro"
3-
version = "0.1.0"
3+
version = "0.194.2"
44
description = "MITx Pro"
55
authors = [{ name = "MIT ODL" }]
66
requires-python = ">=3.13,<4"
@@ -157,3 +157,36 @@ env = [
157157
"WAGTAIL_CACHE_URL=",
158158
"POSTHOG_ENABLED=True",
159159
]
160+
161+
[tool.bumpversion]
162+
commit = false
163+
tag = false
164+
parse = "(?P<release>(?:[1-9][0-9]{3})\\.(?:1[0-2]|[1-9])\\.(?:3[0-1]|[12][0-9]|[1-9]))\\.(?P<build>\\d+)"
165+
serialize = ["{release}.{build}"]
166+
167+
[tool.bumpversion.parts.release]
168+
calver_format = "{YYYY}.{MM}.{DD}"
169+
170+
[tool.bumpversion.parts.build]
171+
first_value = "1"
172+
173+
[[tool.bumpversion.files]]
174+
filename = "mitxpro/settings.py"
175+
search = 'VERSION = "{current_version}"'
176+
replace = 'VERSION = "{new_version}"'
177+
178+
[[tool.bumpversion.files]]
179+
filename = "pyproject.toml"
180+
search = 'version = "{current_version}"'
181+
replace = 'version = "{new_version}"'
182+
183+
[[tool.bumpversion.files]]
184+
filename = "uv.lock"
185+
search = """
186+
name = "mitxpro"
187+
version = "{current_version}"
188+
source = {{ virtual = "." }}"""
189+
replace = """
190+
name = "mitxpro"
191+
version = "{new_version}"
192+
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)