mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
npm: ship platform packages in Codex package layout (#23637)
## Summary
The npm platform packages should stop carrying a bespoke native layout
now that the release workflow builds canonical Codex package archives.
Keeping npm on the same `bin/`, `codex-resources/`, and `codex-path/`
structure lets the Rust package-layout detection behave consistently
across standalone, npm, and future DotSlash installs.
This changes platform npm packages to stage the `codex-package` artifact
for each target under `vendor/<target>`. The Node launcher now resolves
`bin/codex` and prepends `codex-path`, while retaining legacy
`vendor/<target>/codex` and `vendor/<target>/path` fallback support for
local development and migration. The npm staging helper downloads
`codex-package` archives instead of rebuilding the CLI payload from
individual `codex`, `rg`, `bwrap`, and sandbox helper artifacts.
CI still needs to stage npm packages from historical rust-release
workflow artifacts that predate package archives, so the staging scripts
expose an explicit `--allow-legacy-codex-package` fallback. That
fallback synthesizes the canonical package layout from legacy per-binary
artifacts and is wired only into the CI smoke path; release staging
remains strict and continues to require real package archives.
For direct local use, `install_native_deps.py` now points its built-in
default workflow at the same recent artifact run used by CI and
automatically enables legacy package synthesis only when
`--workflow-url` is omitted. Explicit workflow URLs remain strict unless
callers opt in with `--allow-legacy-codex-package`.
## Test plan
- `python3 -m py_compile codex-cli/scripts/build_npm_package.py
codex-cli/scripts/install_native_deps.py scripts/stage_npm_packages.py
scripts/codex_package/cli.py`
- `node --check codex-cli/bin/codex.js`
- `ruby -e 'require "yaml";
YAML.load_file(".github/workflows/rust-release.yml");
YAML.load_file(".github/workflows/ci.yml"); puts "ok"'`
- Staged a synthetic `codex-linux-x64` platform package from a canonical
vendor tree and verified it copied only `bin/`, `codex-path/`,
`codex-resources/`, and `codex-package.json`.
- Imported `install_native_deps.py` and extracted a synthetic
`codex-package-x86_64-unknown-linux-musl.tar.gz` into `vendor/<target>`.
- Ran legacy-layout conversion smokes for Linux, Windows, and unsigned
macOS artifact naming.
- Ran a synthetic `install_native_deps.py` default-workflow smoke that
verifies legacy package synthesis is automatic only when
`--workflow-url` is omitted.
- `NPM_CONFIG_CACHE="$tmp_dir/npm-cache" python3
./scripts/stage_npm_packages.py --release-version 0.125.0 --workflow-url
https://github.com/openai/codex/actions/runs/26131514935 --package codex
--allow-legacy-codex-package --output-dir "$tmp_dir"`
- `node codex-cli/bin/codex.js --version`
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/openai/codex/pull/23637).
* #23638
* __->__ #23637
This commit is contained in:
committed by
GitHub
Unverified
parent
7c3cc1db81
commit
e389e01f83
@@ -1,8 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Stage one or more Codex npm packages for release."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import importlib.util
|
||||
import json
|
||||
@@ -68,6 +66,15 @@ def parse_args() -> argparse.Namespace:
|
||||
"Intended for CI compatibility only; release staging should not use this."
|
||||
),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--allow-legacy-codex-package",
|
||||
action="store_true",
|
||||
help=(
|
||||
"Allow codex-package layouts to be synthesized from legacy per-binary "
|
||||
"workflow artifacts. Intended for CI compatibility only; release staging "
|
||||
"should not use this."
|
||||
),
|
||||
)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
@@ -124,11 +131,15 @@ def install_native_components(
|
||||
workflow_url: str,
|
||||
components: set[str],
|
||||
vendor_root: Path,
|
||||
*,
|
||||
allow_legacy_codex_package: bool,
|
||||
) -> None:
|
||||
if not components:
|
||||
return
|
||||
|
||||
cmd = [str(INSTALL_NATIVE_DEPS), "--workflow-url", workflow_url]
|
||||
if allow_legacy_codex_package:
|
||||
cmd.append("--allow-legacy-codex-package")
|
||||
for component in sorted(components):
|
||||
cmd.extend(["--component", component])
|
||||
cmd.append(str(vendor_root))
|
||||
@@ -172,7 +183,12 @@ def main() -> int:
|
||||
args.release_version, args.workflow_url
|
||||
)
|
||||
vendor_temp_root = Path(tempfile.mkdtemp(prefix="npm-native-", dir=runner_temp))
|
||||
install_native_components(workflow_url, native_components_to_install, vendor_temp_root)
|
||||
install_native_components(
|
||||
workflow_url,
|
||||
native_components_to_install,
|
||||
vendor_temp_root,
|
||||
allow_legacy_codex_package=args.allow_legacy_codex_package,
|
||||
)
|
||||
vendor_src = vendor_temp_root / "vendor"
|
||||
|
||||
if resolved_head_sha:
|
||||
|
||||
Reference in New Issue
Block a user