Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch from dev to rc #512

Merged
merged 1 commit into from
Oct 31, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/bump_version_pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
- major
- minor
- patch
- dev
- rc

jobs:
publish:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ where = ["src"]
# https://pypi.org/project/bumpver
[tool.bumpver]
current_version = "0.1.16"
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
commit_message = "Bump version {old_version} -> {new_version}"
commit = true
tag = false # no longer useful to tag here, must happen in create_publish_pr.yaml
Expand Down
2 changes: 1 addition & 1 deletion src/allencell_ml_segmenter/_tests/scripts/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.0.1"
# https://pypi.org/project/bumpver
[tool.bumpver]
current_version = "0.0.1"
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
commit = false
tag = false # no longer useful to tag here, must happen in create_publish_pr.yaml
push = false
Expand Down
52 changes: 26 additions & 26 deletions src/allencell_ml_segmenter/_tests/scripts/test_bumpver_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,20 @@ def test_bump_major() -> None:
navigate_back_to_root_dir()


def test_bump_dev() -> None:
def test_bump_rc() -> None:
navigate_to_test_dir_and_reset_version()
# ASSERT (sanity check)
assert_curr_version_number(DEFAULT_START_VERSION)
# ACT (create new patch version with .dev0 tag)
sys.argv = ["bumpver_handler.py", "dev"]
# ACT (create new patch version with .rc0 tag)
sys.argv = ["bumpver_handler.py", "rc"]
bumpver_handler.main()
# ASSERT
assert_curr_version_number("0.0.2.dev0")
assert_curr_version_number("0.0.2rc0")
# ACT
sys.argv = ["bumpver_handler.py", "dev"]
sys.argv = ["bumpver_handler.py", "rc"]
bumpver_handler.main()
# ASSERT
assert_curr_version_number("0.0.2.dev1")
assert_curr_version_number("0.0.2rc1")
# ACT (finalize the new patch version)
sys.argv = ["bumpver_handler.py", "patch"]
bumpver_handler.main()
Expand All @@ -133,24 +133,24 @@ def test_bump_post() -> None:
sys.argv = ["bumpver_handler.py", "post"]
bumpver_handler.main()
# ASSERT
assert_curr_version_number("0.0.1.post0")
assert_curr_version_number("0.0.1post0")
# ACT
sys.argv = ["bumpver_handler.py", "post"]
bumpver_handler.main()
# ASSERT
assert_curr_version_number("0.0.1.post1")
assert_curr_version_number("0.0.1post1")
navigate_back_to_root_dir()


def test_bump_minor_fails_when_dev_current() -> None:
def test_bump_minor_fails_when_rc_current() -> None:
navigate_to_test_dir_and_reset_version()
# ASSERT (sanity check)
assert_curr_version_number(DEFAULT_START_VERSION)
# ACT (create new dev version with .dev0 tag)
sys.argv = ["bumpver_handler.py", "dev"]
# ACT (create new rc version with .rc0 tag)
sys.argv = ["bumpver_handler.py", "rc"]
bumpver_handler.main()
# ASSERT (sanity check)
assert_curr_version_number("0.0.2.dev0")
assert_curr_version_number("0.0.2rc0")

got_expected_exception: bool = False
try:
Expand All @@ -166,15 +166,15 @@ def test_bump_minor_fails_when_dev_current() -> None:
navigate_back_to_root_dir()


def test_bump_major_fails_when_dev_current() -> None:
def test_bump_major_fails_when_rc_current() -> None:
navigate_to_test_dir_and_reset_version()
# ASSERT (sanity check)
assert_curr_version_number(DEFAULT_START_VERSION)
# ACT (create new dev version with .dev0 tag)
sys.argv = ["bumpver_handler.py", "dev"]
# ACT (create new rc version with .rc0 tag)
sys.argv = ["bumpver_handler.py", "rc"]
bumpver_handler.main()
# ASSERT (sanity check)
assert_curr_version_number("0.0.2.dev0")
assert_curr_version_number("0.0.2rc0")

got_expected_exception: bool = False
try:
Expand All @@ -190,15 +190,15 @@ def test_bump_major_fails_when_dev_current() -> None:
navigate_back_to_root_dir()


def test_bump_post_fails_when_dev_current() -> None:
def test_bump_post_fails_when_rc_current() -> None:
navigate_to_test_dir_and_reset_version()
# ASSERT (sanity check)
assert_curr_version_number(DEFAULT_START_VERSION)
# ACT (create new dev version with .dev0 tag)
sys.argv = ["bumpver_handler.py", "dev"]
# ACT (create new rc version with .rc0 tag)
sys.argv = ["bumpver_handler.py", "rc"]
bumpver_handler.main()
# ASSERT (sanity check)
assert_curr_version_number("0.0.2.dev0")
assert_curr_version_number("0.0.2rc0")

got_expected_exception: bool = False
try:
Expand All @@ -222,7 +222,7 @@ def test_bump_minor_fails_when_post_current() -> None:
sys.argv = ["bumpver_handler.py", "post"]
bumpver_handler.main()
# ASSERT (sanity check)
assert_curr_version_number("0.0.1.post0")
assert_curr_version_number("0.0.1post0")

got_expected_exception: bool = False
try:
Expand All @@ -246,7 +246,7 @@ def test_bump_major_fails_when_post_current() -> None:
sys.argv = ["bumpver_handler.py", "post"]
bumpver_handler.main()
# ASSERT (sanity check)
assert_curr_version_number("0.0.1.post0")
assert_curr_version_number("0.0.1post0")

got_expected_exception: bool = False
try:
Expand All @@ -270,7 +270,7 @@ def test_bump_patch_fails_when_post_current() -> None:
sys.argv = ["bumpver_handler.py", "post"]
bumpver_handler.main()
# ASSERT (sanity check)
assert_curr_version_number("0.0.1.post0")
assert_curr_version_number("0.0.1post0")

got_expected_exception: bool = False
try:
Expand All @@ -286,19 +286,19 @@ def test_bump_patch_fails_when_post_current() -> None:
navigate_back_to_root_dir()


def test_bump_dev_fails_when_post_current() -> None:
def test_bump_rc_fails_when_post_current() -> None:
navigate_to_test_dir_and_reset_version()
# ASSERT (sanity check)
assert_curr_version_number(DEFAULT_START_VERSION)
# ACT (create new post version with .post0 tag)
sys.argv = ["bumpver_handler.py", "post"]
bumpver_handler.main()
# ASSERT (sanity check)
assert_curr_version_number("0.0.1.post0")
assert_curr_version_number("0.0.1post0")

got_expected_exception: bool = False
try:
sys.argv = ["bumpver_handler.py", "dev"]
sys.argv = ["bumpver_handler.py", "rc"]
bumpver_handler.main()
except ValueError as e:
got_expected_exception = True
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.0.1"
# https://pypi.org/project/bumpver
[tool.bumpver]
current_version = "0.0.1"
version_pattern = "MAJOR.MINOR.PATCH[.PYTAGNUM]"
version_pattern = "MAJOR.MINOR.PATCH[PYTAGNUM]"
commit = false
tag = false # no longer useful to tag here, must happen in create_publish_pr.yaml
push = false
Expand Down
30 changes: 11 additions & 19 deletions src/allencell_ml_segmenter/scripts/bumpver_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def main() -> None:
raise ValueError("No component specified for bumping version")

component: str = sys.argv[1].lower()
valid_options: set[str] = {"major", "minor", "patch", "dev", "post"}
valid_options: set[str] = {"major", "minor", "patch", "rc", "post"}

if component not in valid_options:
raise ValueError(f"Component must be one of {valid_options}")
Expand All @@ -20,36 +20,33 @@ def main() -> None:
version_components: list[str] = version.split(".")

update_output: subprocess.CompletedProcess
# 4 components means we currently have a dev or post version
if len(version_components) == 4 and version_components[-1].startswith(
"dev"
):
if component == "dev":
# increment the dev tag (e.g. 1.0.0.dev0 -> 1.0.0.dev1)
if "rc" in version_components[-1]:
hughes036 marked this conversation as resolved.
Show resolved Hide resolved
if component == "rc":
# increment the rc tag (e.g. 1.0.0rc0 -> 1.0.0rc1)
update_output = subprocess.run(
["bumpver", "update", "--tag-num", "-n"]
)
elif component == "patch":
# finalize the patch by removing dev tag (e.g. 1.0.0.dev1 -> 1.0.0)
# finalize the patch by removing rc tag (e.g. 1.0.0rc1 -> 1.0.0)
update_output = subprocess.run(
["bumpver", "update", "--tag=final", "-n"]
)
else:
raise ValueError(
"Cannot update major or minor version while dev version is current"
"Cannot update major or minor version while rc version is current"
)
elif len(version_components) == 4: # current version must be post
elif "post" in version_components[-1]:
if component == "post":
update_output = subprocess.run(
["bumpver", "update", "--tag-num", "-n"]
)
else:
raise ValueError("Cannot change post version to standard version")
elif len(version_components) == 3:
if component == "dev":
# increment patch and begin at dev0 (e.g. 1.0.0 -> 1.0.1.dev0)
else:
if component == "rc":
# increment patch and begin at rc0 (e.g. 1.0.0 -> 1.0.1rc0)
update_output = subprocess.run(
["bumpver", "update", "--patch", "--tag=dev", "-n"]
["bumpver", "update", "--patch", "--tag=rc", "-n"]
)
elif component == "post":
update_output = subprocess.run(
Expand All @@ -60,11 +57,6 @@ def main() -> None:
["bumpver", "update", f"--{component}", "-n"]
)

else:
raise ValueError(
hughes036 marked this conversation as resolved.
Show resolved Hide resolved
f"Unknown version format: {version}. Expected MAJOR.MINOR.PATCH[.PYTAGNUM]"
)

if update_output.returncode != 0:
raise RuntimeError(
f"bumpver exited with code {update_output.returncode}"
Expand Down