mirror of
https://github.com/openai/codex.git
synced 2026-10-18 17:18:52 +00:00
Allow overriding Codex package versions (#39298)
## What changed - Add `--package-version` to set the version written to `codex-package.json`, while retaining the workspace package version as the default. - Reject values that are not runtime-compatible semantic versions, including overflowing numeric components and numeric prerelease identifiers with leading zeroes. - Document the new option. ## Testing - Add unit coverage for valid release, prerelease, and build versions, plus malformed and out-of-range values. GitOrigin-RevId: cee996a6721e3fac9bd88f0bc0302a7ec7d2b2fb
This commit is contained in:
committed by
copyberry
parent
87070a7792
commit
45528c5132
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
|
||||
from codex_package.cli import parse_package_version
|
||||
|
||||
|
||||
class PackageVersionTest(unittest.TestCase):
|
||||
def test_accepts_release_prerelease_and_build_versions(self) -> None:
|
||||
for version in (
|
||||
"0.0.0",
|
||||
"1.2.3",
|
||||
"0.0.0-internal.deadbeef",
|
||||
"1.2.3-alpha.1+build.01",
|
||||
"18446744073709551615.0.0",
|
||||
):
|
||||
with self.subTest(version=version):
|
||||
self.assertEqual(parse_package_version(version), version)
|
||||
|
||||
def test_rejects_versions_the_runtime_cannot_parse(self) -> None:
|
||||
for version in (
|
||||
"",
|
||||
"1",
|
||||
"1.2",
|
||||
"1.2.3.4",
|
||||
"v1.2.3",
|
||||
"01.2.3",
|
||||
"1.02.3",
|
||||
"1.2.03",
|
||||
"1.2.3-",
|
||||
"1.2.3-alpha..1",
|
||||
"1.2.3-01",
|
||||
"1.2.3+",
|
||||
"1.2.3+build..1",
|
||||
"18446744073709551616.0.0",
|
||||
):
|
||||
with self.subTest(version=version):
|
||||
with self.assertRaises(argparse.ArgumentTypeError):
|
||||
parse_package_version(version)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user