mirror of
https://github.com/openai/codex.git
synced 2026-11-12 21:20:34 +00:00
ci(v8): decouple artifact tags from bindings
This commit is contained in:
@@ -27,6 +27,10 @@ RUSTY_V8_CHECKSUMS_DIR = ROOT / "third_party" / "v8"
|
||||
RELEASE_ARTIFACT_PROFILE = "release"
|
||||
SANDBOX_ARTIFACT_PROFILE = "ptrcomp_sandbox_release"
|
||||
ARTIFACT_BAZEL_CONFIGS = ["rusty-v8-upstream-libcxx"]
|
||||
V8_SOURCE_ARCHIVE_PATTERN = re.compile(
|
||||
r"https://github\.com/v8/v8/archive/refs/tags/"
|
||||
r"([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)\.tar\.gz"
|
||||
)
|
||||
|
||||
|
||||
def bazel_execroot() -> Path:
|
||||
@@ -170,6 +174,26 @@ def resolved_v8_crate_version() -> str:
|
||||
return matches[0]
|
||||
|
||||
|
||||
def resolved_v8_source_version(module_bazel: Path | None = None) -> str:
|
||||
module_bazel = module_bazel or MODULE_BAZEL
|
||||
matches = sorted(set(V8_SOURCE_ARCHIVE_PATTERN.findall(module_bazel.read_text())))
|
||||
if len(matches) != 1:
|
||||
raise SystemExit(
|
||||
"expected exactly one pinned V8 source version in MODULE.bazel, "
|
||||
f"found: {matches}"
|
||||
)
|
||||
return matches[0]
|
||||
|
||||
|
||||
def rusty_v8_release_tag(
|
||||
crate_version: str | None = None,
|
||||
source_version: str | None = None,
|
||||
) -> str:
|
||||
crate_version = crate_version or resolved_v8_crate_version()
|
||||
source_version = source_version or resolved_v8_source_version()
|
||||
return f"rusty-v8-v{crate_version}-v8-{source_version}"
|
||||
|
||||
|
||||
def rusty_v8_checksum_manifest_path(version: str) -> Path:
|
||||
return RUSTY_V8_CHECKSUMS_DIR / f"rusty_v8_{version.replace('.', '_')}.sha256"
|
||||
|
||||
@@ -258,6 +282,53 @@ def stage_artifacts(
|
||||
print(staged_checksums)
|
||||
|
||||
|
||||
def v8_checkout_version(source_root: Path) -> str:
|
||||
version_header = source_root / "v8" / "include" / "v8-version.h"
|
||||
values: dict[str, str] = {}
|
||||
for name, value in re.findall(
|
||||
r"^#define V8_(MAJOR_VERSION|MINOR_VERSION|BUILD_NUMBER|PATCH_LEVEL) ([0-9]+)$",
|
||||
version_header.read_text(),
|
||||
flags=re.MULTILINE,
|
||||
):
|
||||
values[name] = value
|
||||
expected_names = {"MAJOR_VERSION", "MINOR_VERSION", "BUILD_NUMBER", "PATCH_LEVEL"}
|
||||
if values.keys() != expected_names:
|
||||
raise SystemExit(f"could not resolve V8 version from {version_header}")
|
||||
return ".".join(
|
||||
values[name]
|
||||
for name in ["MAJOR_VERSION", "MINOR_VERSION", "BUILD_NUMBER", "PATCH_LEVEL"]
|
||||
)
|
||||
|
||||
|
||||
def sync_upstream_v8_source(
|
||||
source_root: Path,
|
||||
source_version: str | None = None,
|
||||
) -> None:
|
||||
source_root = source_root.resolve()
|
||||
source_version = source_version or resolved_v8_source_version()
|
||||
v8_root = source_root / "v8"
|
||||
subprocess.run(
|
||||
["git", "fetch", "--depth=1", "origin", f"refs/tags/{source_version}"],
|
||||
cwd=v8_root,
|
||||
check=True,
|
||||
)
|
||||
subprocess.run(
|
||||
["git", "checkout", "--detach", "FETCH_HEAD"],
|
||||
cwd=v8_root,
|
||||
check=True,
|
||||
)
|
||||
subprocess.run(
|
||||
[sys.executable, "tools/update_deps.py"],
|
||||
cwd=source_root,
|
||||
check=True,
|
||||
)
|
||||
actual_version = v8_checkout_version(source_root)
|
||||
if actual_version != source_version:
|
||||
raise SystemExit(
|
||||
f"expected V8 {source_version} after source sync, found {actual_version}"
|
||||
)
|
||||
|
||||
|
||||
def upstream_release_pair_paths(source_root: Path, target: str) -> tuple[Path, Path]:
|
||||
lib_name = (
|
||||
"rusty_v8.lib" if target.endswith("-pc-windows-msvc") else "librusty_v8.a"
|
||||
@@ -336,7 +407,15 @@ def parse_args() -> argparse.Namespace:
|
||||
stage_upstream_release_pair_parser.add_argument("--output-dir", required=True)
|
||||
stage_upstream_release_pair_parser.add_argument("--sandbox", action="store_true")
|
||||
|
||||
sync_upstream_source_parser = subparsers.add_parser("sync-upstream-source")
|
||||
sync_upstream_source_parser.add_argument(
|
||||
"--source-root", type=Path, required=True
|
||||
)
|
||||
sync_upstream_source_parser.add_argument("--v8-version")
|
||||
|
||||
subparsers.add_parser("resolved-v8-crate-version")
|
||||
subparsers.add_parser("resolved-v8-source-version")
|
||||
subparsers.add_parser("rusty-v8-release-tag")
|
||||
|
||||
check_module_bazel_parser = subparsers.add_parser("check-module-bazel")
|
||||
check_module_bazel_parser.add_argument("--version")
|
||||
@@ -379,9 +458,21 @@ def main() -> int:
|
||||
sandbox=args.sandbox,
|
||||
)
|
||||
return 0
|
||||
if args.command == "sync-upstream-source":
|
||||
sync_upstream_v8_source(
|
||||
source_root=args.source_root,
|
||||
source_version=args.v8_version,
|
||||
)
|
||||
return 0
|
||||
if args.command == "resolved-v8-crate-version":
|
||||
print(resolved_v8_crate_version())
|
||||
return 0
|
||||
if args.command == "resolved-v8-source-version":
|
||||
print(resolved_v8_source_version())
|
||||
return 0
|
||||
if args.command == "rusty-v8-release-tag":
|
||||
print(rusty_v8_release_tag())
|
||||
return 0
|
||||
if args.command == "check-module-bazel":
|
||||
version = command_version(args.version)
|
||||
manifest_path = command_manifest_path(args.manifest, version)
|
||||
|
||||
Reference in New Issue
Block a user