mirror of
https://github.com/openai/codex.git
synced 2026-09-28 08:43:01 +08:00
## Why Publishing a hotfix for an older release line or alpha can replace a newer prerelease pointer. Release pointers should advance according to version order. ## What changed - Share release version validation and numeric comparison across publishing scripts, including alpha hotfix suffixes and alpha, beta, and stable ordering. - Read the prerelease pointer directly from R2 and update it only for a newer version or missing or invalid version metadata. - Restrict `latest-alpha-cli` updates to alpha releases with successful R2 and npm publishing, and compare against the branch's Cargo version before advancing it. Allow replacement when the manifest version cannot be parsed or validated. ## Testing Add 15 passing unit tests covering version validation, older release lines and alphas, numeric hotfix ordering, prerelease precedence, equal versions, and missing or invalid versions. GitOrigin-RevId: 6bee3906a47f613b662ef2b2224cfcbd1b56650c
57 lines
2.2 KiB
Python
57 lines
2.2 KiB
Python
import unittest
|
|
|
|
from releases import is_valid_release_version, should_update_version
|
|
|
|
|
|
class VersionComparisonTest(unittest.TestCase):
|
|
def test_validation_accepts_alpha_hotfix(self) -> None:
|
|
self.assertTrue(is_valid_release_version("0.123.0-alpha.5.2"))
|
|
|
|
def test_validation_rejects_extra_component(self) -> None:
|
|
self.assertFalse(is_valid_release_version("0.123.0-alpha.5.2.3"))
|
|
|
|
def test_next_alpha_after_public_release(self) -> None:
|
|
self.assertTrue(should_update_version("0.124.0-alpha.1", "0.123.0"))
|
|
|
|
def test_public_release_after_next_alpha(self) -> None:
|
|
self.assertFalse(should_update_version("0.123.0", "0.124.0-alpha.1"))
|
|
|
|
def test_hotfix_for_an_older_release_line(self) -> None:
|
|
self.assertFalse(should_update_version("0.100.0-alpha.1.2", "0.123.0-alpha.5"))
|
|
|
|
def test_hotfix_for_an_older_alpha(self) -> None:
|
|
self.assertFalse(should_update_version("0.123.0-alpha.2.3", "0.123.0-alpha.10"))
|
|
|
|
def test_hotfix_for_the_current_alpha(self) -> None:
|
|
self.assertTrue(should_update_version("0.123.0-alpha.5.2", "0.123.0-alpha.5"))
|
|
|
|
def test_hotfix_numbers_compare_numerically(self) -> None:
|
|
self.assertTrue(
|
|
should_update_version("0.123.0-alpha.5.10", "0.123.0-alpha.5.2")
|
|
)
|
|
|
|
def test_numbered_alpha_after_bare_alpha(self) -> None:
|
|
self.assertTrue(should_update_version("0.123.0-alpha.1", "0.123.0-alpha"))
|
|
|
|
def test_beta_after_alpha(self) -> None:
|
|
self.assertTrue(should_update_version("0.123.0-beta", "0.123.0-alpha.10"))
|
|
|
|
def test_public_release_after_beta(self) -> None:
|
|
self.assertTrue(should_update_version("0.123.0", "0.123.0-beta.2"))
|
|
|
|
def test_equal_version(self) -> None:
|
|
self.assertFalse(should_update_version("0.123.0-alpha.5", "0.123.0-alpha.5"))
|
|
|
|
def test_missing_current_version(self) -> None:
|
|
self.assertTrue(should_update_version("0.123.0-alpha.5", ""))
|
|
|
|
def test_invalid_current_version(self) -> None:
|
|
self.assertTrue(should_update_version("0.123.0-alpha.5", "0.123"))
|
|
|
|
def test_invalid_release_version(self) -> None:
|
|
self.assertRaises(ValueError, should_update_version, "0.123", "")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|