Base: codex-main originale (prima del fork aKode)
This commit is contained in:
119
.github/scripts/archive-release-symbols-and-strip-binaries.sh
vendored
Executable file
119
.github/scripts/archive-release-symbols-and-strip-binaries.sh
vendored
Executable file
@@ -0,0 +1,119 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: archive-release-symbols-and-strip-binaries.sh \
|
||||
--target <rust-target> \
|
||||
--artifact-name <artifact-name> \
|
||||
--release-dir <dir> \
|
||||
--archive-dir <dir> \
|
||||
--binaries "<space-delimited binary basenames>"
|
||||
EOF
|
||||
}
|
||||
|
||||
target=""
|
||||
artifact_name=""
|
||||
release_dir=""
|
||||
archive_dir=""
|
||||
binaries=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--target)
|
||||
target="${2:?--target requires a value}"
|
||||
shift 2
|
||||
;;
|
||||
--artifact-name)
|
||||
artifact_name="${2:?--artifact-name requires a value}"
|
||||
shift 2
|
||||
;;
|
||||
--release-dir)
|
||||
release_dir="${2:?--release-dir requires a value}"
|
||||
shift 2
|
||||
;;
|
||||
--archive-dir)
|
||||
archive_dir="${2:?--archive-dir requires a value}"
|
||||
shift 2
|
||||
;;
|
||||
--binaries)
|
||||
binaries="${2:?--binaries requires a value}"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unexpected argument: $1" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$target" || -z "$artifact_name" || -z "$release_dir" || -z "$archive_dir" || -z "$binaries" ]]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
symbols_root="${RUNNER_TEMP:-/tmp}/codex-symbols-${artifact_name}"
|
||||
symbols_dir="${symbols_root}/codex-symbols-${artifact_name}"
|
||||
archive_path="${archive_dir%/}/codex-symbols-${artifact_name}.tar.gz"
|
||||
rm -rf "$symbols_root"
|
||||
mkdir -p "$symbols_dir" "$archive_dir"
|
||||
read -r -a binary_names <<< "$binaries"
|
||||
|
||||
case "$target" in
|
||||
*apple-darwin)
|
||||
for binary in "${binary_names[@]}"; do
|
||||
binary_path="${release_dir%/}/${binary}"
|
||||
dsym_path="${binary_path}.dSYM"
|
||||
if [[ ! -f "$binary_path" ]]; then
|
||||
echo "Binary $binary_path not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ! -d "$dsym_path" ]]; then
|
||||
echo "dSYM $dsym_path not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp -RL "$dsym_path" "${symbols_dir}/${binary}.dSYM"
|
||||
strip -S -x "$binary_path"
|
||||
done
|
||||
;;
|
||||
*linux*)
|
||||
objcopy_bin="${OBJCOPY:-objcopy}"
|
||||
strip_bin="${STRIP:-strip}"
|
||||
for binary in "${binary_names[@]}"; do
|
||||
binary_path="${release_dir%/}/${binary}"
|
||||
debug_path="${symbols_dir}/${binary}.debug"
|
||||
if [[ ! -f "$binary_path" ]]; then
|
||||
echo "Binary $binary_path not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
"$objcopy_bin" --only-keep-debug "$binary_path" "$debug_path"
|
||||
"$strip_bin" --strip-debug --strip-unneeded "$binary_path"
|
||||
"$objcopy_bin" --add-gnu-debuglink="$debug_path" "$binary_path"
|
||||
done
|
||||
;;
|
||||
*windows*)
|
||||
for binary in "${binary_names[@]}"; do
|
||||
pdb_path="${release_dir%/}/${binary}.pdb"
|
||||
if [[ ! -f "$pdb_path" ]]; then
|
||||
echo "PDB $pdb_path not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cp "$pdb_path" "${symbols_dir}/${binary}.pdb"
|
||||
done
|
||||
;;
|
||||
*)
|
||||
echo "No symbols packaging support for target: $target" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
rm -f "$archive_path"
|
||||
tar -C "$symbols_root" -czf "$archive_path" "codex-symbols-${artifact_name}"
|
||||
235
.github/scripts/build-codex-package-archive.sh
vendored
Normal file
235
.github/scripts/build-codex-package-archive.sh
vendored
Normal file
@@ -0,0 +1,235 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage: build-codex-package-archive.sh \
|
||||
--target <rust-target> \
|
||||
--bundle <primary|app-server> \
|
||||
--entrypoint-dir <dir> \
|
||||
--archive-dir <dir> \
|
||||
[--bwrap-bin <path>] \
|
||||
[--code-mode-host-bin <path>] \
|
||||
[--rg-bin <path>] \
|
||||
[--codex-command-runner-bin <path>] \
|
||||
[--codex-windows-sandbox-setup-bin <path>] \
|
||||
[--voice-release-dir <path> --release-version <release-version>] \
|
||||
[--target-suffixed-entrypoint]
|
||||
EOF
|
||||
}
|
||||
|
||||
target=""
|
||||
bundle=""
|
||||
entrypoint_dir=""
|
||||
archive_dir=""
|
||||
target_suffixed_entrypoint="false"
|
||||
resource_args=()
|
||||
bwrap_bin_provided="false"
|
||||
code_mode_host_bin_provided="false"
|
||||
command_runner_bin_provided="false"
|
||||
sandbox_setup_bin_provided="false"
|
||||
voice_release_dir=""
|
||||
release_version=""
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--target)
|
||||
target="${2:?--target requires a value}"
|
||||
shift 2
|
||||
;;
|
||||
--bundle)
|
||||
bundle="${2:?--bundle requires a value}"
|
||||
shift 2
|
||||
;;
|
||||
--entrypoint-dir)
|
||||
entrypoint_dir="${2:?--entrypoint-dir requires a value}"
|
||||
shift 2
|
||||
;;
|
||||
--archive-dir)
|
||||
archive_dir="${2:?--archive-dir requires a value}"
|
||||
shift 2
|
||||
;;
|
||||
--bwrap-bin)
|
||||
resource_args+=(--bwrap-bin "${2:?--bwrap-bin requires a value}")
|
||||
bwrap_bin_provided="true"
|
||||
shift 2
|
||||
;;
|
||||
--code-mode-host-bin)
|
||||
resource_args+=(--code-mode-host-bin "${2:?--code-mode-host-bin requires a value}")
|
||||
code_mode_host_bin_provided="true"
|
||||
shift 2
|
||||
;;
|
||||
--rg-bin)
|
||||
resource_args+=(--rg-bin "${2:?--rg-bin requires a value}")
|
||||
shift 2
|
||||
;;
|
||||
--codex-command-runner-bin)
|
||||
resource_args+=(
|
||||
--codex-command-runner-bin
|
||||
"${2:?--codex-command-runner-bin requires a value}"
|
||||
)
|
||||
command_runner_bin_provided="true"
|
||||
shift 2
|
||||
;;
|
||||
--codex-windows-sandbox-setup-bin)
|
||||
resource_args+=(
|
||||
--codex-windows-sandbox-setup-bin
|
||||
"${2:?--codex-windows-sandbox-setup-bin requires a value}"
|
||||
)
|
||||
sandbox_setup_bin_provided="true"
|
||||
shift 2
|
||||
;;
|
||||
--target-suffixed-entrypoint)
|
||||
target_suffixed_entrypoint="true"
|
||||
shift
|
||||
;;
|
||||
--voice-release-dir)
|
||||
voice_release_dir="${2:?--voice-release-dir requires a value}"
|
||||
shift 2
|
||||
;;
|
||||
--release-version)
|
||||
release_version="${2:?--release-version requires a value}"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unexpected argument: $1" >&2
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$target" || -z "$bundle" || -z "$entrypoint_dir" || -z "$archive_dir" ]]; then
|
||||
usage >&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ ( -n "$voice_release_dir" || -n "$release_version" ) && ( -z "$voice_release_dir" || -z "$release_version" || "$bundle" != "primary" || ( "$target" != *-apple-darwin && "$target" != *-unknown-linux-musl && "$target" != *-pc-windows-msvc ) ) ]]; then
|
||||
echo "Voice resources require a primary supported release package version" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$bundle" in
|
||||
primary)
|
||||
variant="codex"
|
||||
entrypoint="codex"
|
||||
archive_stem="codex-package"
|
||||
;;
|
||||
app-server)
|
||||
variant="codex-app-server"
|
||||
entrypoint="codex-app-server"
|
||||
archive_stem="codex-app-server-package"
|
||||
;;
|
||||
*)
|
||||
echo "No Codex package variant for bundle: $bundle" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exe_suffix=""
|
||||
case "$target" in
|
||||
*windows*)
|
||||
exe_suffix=".exe"
|
||||
;;
|
||||
esac
|
||||
|
||||
resource_args+=(--exec-server-bin "${entrypoint_dir%/}/codex-exec-server${exe_suffix}")
|
||||
|
||||
code_mode_host_bin="${entrypoint_dir%/}/codex-code-mode-host${exe_suffix}"
|
||||
if [[ "$code_mode_host_bin_provided" == "false" && -f "$code_mode_host_bin" ]]; then
|
||||
resource_args+=(--code-mode-host-bin "$code_mode_host_bin")
|
||||
fi
|
||||
|
||||
entrypoint_name="$entrypoint"
|
||||
if [[ "$target_suffixed_entrypoint" == "true" ]]; then
|
||||
entrypoint_name="${entrypoint_name}-${target}"
|
||||
fi
|
||||
|
||||
case "$target" in
|
||||
*linux*)
|
||||
bwrap_bin="${entrypoint_dir%/}/bwrap"
|
||||
if [[ "$bwrap_bin_provided" == "false" && -f "$bwrap_bin" ]]; then
|
||||
resource_args+=(--bwrap-bin "$bwrap_bin")
|
||||
fi
|
||||
;;
|
||||
*windows*)
|
||||
command_runner_bin="${entrypoint_dir%/}/codex-command-runner.exe"
|
||||
sandbox_setup_bin="${entrypoint_dir%/}/codex-windows-sandbox-setup.exe"
|
||||
if [[ "$command_runner_bin_provided" == "false" && -f "$command_runner_bin" ]]; then
|
||||
resource_args+=(--codex-command-runner-bin "$command_runner_bin")
|
||||
fi
|
||||
if [[ "$sandbox_setup_bin_provided" == "false" && -f "$sandbox_setup_bin" ]]; then
|
||||
resource_args+=(--codex-windows-sandbox-setup-bin "$sandbox_setup_bin")
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
repo_root="${GITHUB_WORKSPACE:-}"
|
||||
if [[ -z "$repo_root" ]]; then
|
||||
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
fi
|
||||
|
||||
if command -v python3 >/dev/null 2>&1; then
|
||||
python_bin="python3"
|
||||
else
|
||||
python_bin="python"
|
||||
fi
|
||||
|
||||
if ! command -v zstd >/dev/null 2>&1 && [[ -x "${repo_root}/.github/workflows/zstd" ]]; then
|
||||
export PATH="${repo_root}/.github/workflows:${PATH}"
|
||||
fi
|
||||
|
||||
mkdir -p "$archive_dir"
|
||||
package_dir="${RUNNER_TEMP:-/tmp}/${archive_stem}-${target}"
|
||||
gzip_archive_path="${archive_dir}/${archive_stem}-${target}.tar.gz"
|
||||
zstd_archive_path="${archive_dir}/${archive_stem}-${target}.tar.zst"
|
||||
rm -rf "$package_dir"
|
||||
|
||||
python_args=(
|
||||
"${repo_root}/scripts/build_codex_package.py"
|
||||
--target "$target"
|
||||
--variant "$variant"
|
||||
--entrypoint-bin "${entrypoint_dir%/}/${entrypoint_name}${exe_suffix}"
|
||||
--cargo-profile release
|
||||
--package-dir "$package_dir"
|
||||
)
|
||||
if [[ -z "$voice_release_dir" ]]; then
|
||||
python_args+=(--archive-output "$gzip_archive_path" --archive-output "$zstd_archive_path")
|
||||
fi
|
||||
if ((${#resource_args[@]} > 0)); then
|
||||
python_args+=("${resource_args[@]}")
|
||||
fi
|
||||
python_args+=(--force)
|
||||
|
||||
"$python_bin" "${python_args[@]}"
|
||||
|
||||
if [[ -n "$voice_release_dir" ]]; then
|
||||
voice_target="$target"
|
||||
if [[ "$target" == *-unknown-linux-musl ]]; then
|
||||
voice_target="${target%-musl}-gnu"
|
||||
fi
|
||||
voice_package="${RUNNER_TEMP:-/tmp}/${archive_stem}-voice-${target}"
|
||||
rm -rf "$voice_package"
|
||||
voice_helper="${voice_release_dir%/}/codex-voice-host${exe_suffix}"
|
||||
"$python_bin" "${repo_root}/third_party/voice/assemble_package.py" \
|
||||
--package "$package_dir" \
|
||||
--helper "$voice_helper" \
|
||||
--runtime "${voice_release_dir%/}/runtime" \
|
||||
--voice-target "$voice_target" \
|
||||
--build-commit "$(git -C "$repo_root" rev-parse HEAD)" \
|
||||
--release-version "$release_version" \
|
||||
--output "$voice_package"
|
||||
PYTHONPATH="${repo_root}/scripts" "$python_bin" - \
|
||||
"$voice_package" "$gzip_archive_path" "$zstd_archive_path" <<'PY'
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from codex_package.archive import write_archive
|
||||
|
||||
package = Path(sys.argv[1])
|
||||
for archive in sys.argv[2:]:
|
||||
write_archive(package, Path(archive), force=True)
|
||||
PY
|
||||
fi
|
||||
34
.github/scripts/check_ci_results.py
vendored
Normal file
34
.github/scripts/check_ci_results.py
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Fail a terminal CI job unless every serialized dependency succeeded.
|
||||
|
||||
Parent workflows pass GitHub's `toJSON(needs)` object through the NEEDS
|
||||
environment variable. Treat skipped and cancelled dependencies as failures too:
|
||||
for a required fan-in job, only an explicit success is safe to accept.
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
||||
|
||||
def main() -> None:
|
||||
# Keep result policy in one script so blocking-ci and postmerge-ci cannot
|
||||
# drift in how they interpret dependency conclusions.
|
||||
needs = json.loads(os.environ["NEEDS"])
|
||||
failures = sorted(
|
||||
(name, dependency["result"])
|
||||
for name, dependency in needs.items()
|
||||
if dependency["result"] != "success"
|
||||
)
|
||||
|
||||
if failures:
|
||||
print("CI dependencies did not succeed:")
|
||||
for name, result in failures:
|
||||
print(f"{name}: {result}")
|
||||
raise SystemExit(1)
|
||||
|
||||
print("All CI dependencies succeeded.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
113
.github/scripts/compute-bazel-windows-path.ps1
vendored
Normal file
113
.github/scripts/compute-bazel-windows-path.ps1
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
<#
|
||||
BuildBuddy cache keys include the action and test environment, so Bazel should
|
||||
not inherit the full hosted-runner PATH on Windows. That PATH includes volatile
|
||||
tool entries, such as Maven, that can change independently of this repo and
|
||||
cause avoidable cache misses.
|
||||
|
||||
This script derives a smaller, cache-stable PATH that keeps the Windows
|
||||
toolchain entries Bazel-backed CI tasks need: MSVC and Windows SDK paths,
|
||||
MinGW runtime DLL paths for gnullvm-built tests, Git, PowerShell, Node, Python,
|
||||
DotSlash, and the standard Windows system directories.
|
||||
`prepare-bazel-ci` runs this after exporting the MSVC environment, and the script
|
||||
publishes the result via `GITHUB_ENV` as `CODEX_BAZEL_WINDOWS_PATH` so later
|
||||
steps can pass that explicit PATH to Bazel.
|
||||
#>
|
||||
|
||||
$stablePathEntries = New-Object System.Collections.Generic.List[string]
|
||||
$seenEntries = [System.Collections.Generic.HashSet[string]]::new([System.StringComparer]::OrdinalIgnoreCase)
|
||||
$windowsAppsPath = if ([string]::IsNullOrWhiteSpace($env:LOCALAPPDATA)) {
|
||||
$null
|
||||
} else {
|
||||
"$($env:LOCALAPPDATA)\Microsoft\WindowsApps"
|
||||
}
|
||||
$windowsDir = if ($env:WINDIR) {
|
||||
$env:WINDIR
|
||||
} elseif ($env:SystemRoot) {
|
||||
$env:SystemRoot
|
||||
} else {
|
||||
$null
|
||||
}
|
||||
|
||||
function Add-StablePathEntry {
|
||||
param([string]$PathEntry)
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($PathEntry)) {
|
||||
return
|
||||
}
|
||||
|
||||
if ($seenEntries.Add($PathEntry)) {
|
||||
[void]$stablePathEntries.Add($PathEntry)
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($pathEntry in ($env:PATH -split ';')) {
|
||||
if ([string]::IsNullOrWhiteSpace($pathEntry)) {
|
||||
continue
|
||||
}
|
||||
|
||||
if (
|
||||
$pathEntry -like '*Microsoft Visual Studio*' -or
|
||||
$pathEntry -like '*Windows Kits*' -or
|
||||
$pathEntry -like '*Microsoft SDKs*' -or
|
||||
$pathEntry -eq 'C:\mingw64\bin' -or
|
||||
$pathEntry -like 'C:\msys64\*\bin' -or
|
||||
$pathEntry -like 'C:\Program Files\Git\*' -or
|
||||
$pathEntry -like 'C:\Program Files\PowerShell\*' -or
|
||||
$pathEntry -like 'C:\hostedtoolcache\windows\node\*' -or
|
||||
$pathEntry -like 'C:\hostedtoolcache\windows\Python\*' -or
|
||||
$pathEntry -eq 'D:\a\_temp\install-dotslash\bin' -or
|
||||
($windowsDir -and ($pathEntry -eq $windowsDir -or $pathEntry -like "${windowsDir}\*"))
|
||||
) {
|
||||
Add-StablePathEntry $pathEntry
|
||||
}
|
||||
}
|
||||
|
||||
$gitCommand = Get-Command git -ErrorAction SilentlyContinue
|
||||
if ($gitCommand) {
|
||||
Add-StablePathEntry (Split-Path $gitCommand.Source -Parent)
|
||||
}
|
||||
|
||||
$nodeCommand = Get-Command node -ErrorAction SilentlyContinue
|
||||
if ($nodeCommand) {
|
||||
Add-StablePathEntry (Split-Path $nodeCommand.Source -Parent)
|
||||
}
|
||||
|
||||
$python3Command = Get-Command python3 -ErrorAction SilentlyContinue
|
||||
if ($python3Command) {
|
||||
Add-StablePathEntry (Split-Path $python3Command.Source -Parent)
|
||||
}
|
||||
|
||||
$pythonCommand = Get-Command python -ErrorAction SilentlyContinue
|
||||
if ($pythonCommand) {
|
||||
Add-StablePathEntry (Split-Path $pythonCommand.Source -Parent)
|
||||
}
|
||||
|
||||
$pwshCommand = Get-Command pwsh -ErrorAction SilentlyContinue
|
||||
if ($pwshCommand) {
|
||||
Add-StablePathEntry (Split-Path $pwshCommand.Source -Parent)
|
||||
}
|
||||
|
||||
foreach ($mingwPath in @('C:\mingw64\bin', 'C:\msys64\mingw64\bin', 'C:\msys64\ucrt64\bin')) {
|
||||
if (Test-Path $mingwPath) {
|
||||
Add-StablePathEntry $mingwPath
|
||||
}
|
||||
}
|
||||
|
||||
if ($windowsAppsPath) {
|
||||
Add-StablePathEntry $windowsAppsPath
|
||||
}
|
||||
|
||||
if ($stablePathEntries.Count -eq 0) {
|
||||
throw 'Failed to derive cache-stable Windows PATH.'
|
||||
}
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($env:GITHUB_ENV)) {
|
||||
throw 'GITHUB_ENV must be set.'
|
||||
}
|
||||
|
||||
$stablePath = $stablePathEntries -join ';'
|
||||
Write-Host 'Derived CODEX_BAZEL_WINDOWS_PATH entries:'
|
||||
foreach ($pathEntry in $stablePathEntries) {
|
||||
Write-Host " $pathEntry"
|
||||
}
|
||||
"CODEX_BAZEL_WINDOWS_PATH=$stablePath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
128
.github/scripts/contract_releases.py
vendored
Normal file
128
.github/scripts/contract_releases.py
vendored
Normal file
@@ -0,0 +1,128 @@
|
||||
"""Discover and download published Codex packages for contract runners."""
|
||||
|
||||
import json
|
||||
import random
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
ALPHA_TAG = re.compile(r"rust-v[0-9]+\.[0-9]+\.[0-9]+-alpha(?:\.[0-9]+){0,2}")
|
||||
RELEASE_TAG = re.compile(r"rust-v[0-9]+\.[0-9]+\.[0-9]+(?:-alpha(?:\.[0-9]+){0,2})?")
|
||||
STABLE_TAG = re.compile(r"rust-v[0-9]+\.[0-9]+\.[0-9]+")
|
||||
PACKAGE = "codex-package-x86_64-unknown-linux-musl.tar.gz"
|
||||
|
||||
|
||||
def github_read(args: list[str]) -> str:
|
||||
"""Retry release reads unless the error is known permanent; never retry verification."""
|
||||
for attempt, delay in enumerate((2, 5, 15, 45, 0), start=1):
|
||||
try:
|
||||
return subprocess.check_output(
|
||||
args, text=True, stderr=subprocess.PIPE, timeout=120
|
||||
)
|
||||
except (subprocess.CalledProcessError, subprocess.TimeoutExpired) as error:
|
||||
reason = "timeout"
|
||||
exit_code = None
|
||||
http_status = "unknown"
|
||||
retryable = True
|
||||
if isinstance(error, subprocess.CalledProcessError):
|
||||
message = error.stderr or ""
|
||||
status = re.search(r"\bHTTP (\d{3})\b", message)
|
||||
reason = "command_failed"
|
||||
exit_code = error.returncode
|
||||
http_status = status[1] if status else "unknown"
|
||||
# gh uses 1 for general failures, 2 for cancellation and 4 for auth.
|
||||
# Unknown transport/protocol wording should still get bounded retries.
|
||||
retryable = (
|
||||
error.returncode == 1
|
||||
and (status is None or status[1] in {"502", "503", "504"})
|
||||
and not any(
|
||||
marker in message.lower()
|
||||
for marker in (
|
||||
"release not found",
|
||||
"no assets match",
|
||||
"no assets to download",
|
||||
"unknown flag",
|
||||
"unknown command",
|
||||
)
|
||||
)
|
||||
)
|
||||
# Only emit classified fields; stderr can contain unknown credential formats.
|
||||
will_retry = retryable and bool(delay)
|
||||
print(
|
||||
f"GitHub release read failed: attempt={attempt} reason={reason} "
|
||||
f"exit_code={exit_code} http_status={http_status} "
|
||||
f"will_retry={str(will_retry).lower()}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
if not will_retry:
|
||||
raise
|
||||
delay += random.randint(0, delay // 2)
|
||||
print(f"Retrying GitHub release read in {delay}s.", file=sys.stderr)
|
||||
time.sleep(delay)
|
||||
|
||||
|
||||
def list_releases(*, exclude_prereleases: bool = False) -> list[dict]:
|
||||
# GraphQL-backed listing avoids fetching assets and release notes.
|
||||
args = [
|
||||
"gh",
|
||||
"release",
|
||||
"list",
|
||||
"--repo",
|
||||
"openai/codex",
|
||||
"--limit",
|
||||
"100",
|
||||
"--json",
|
||||
"tagName,publishedAt,isDraft,isPrerelease",
|
||||
]
|
||||
if exclude_prereleases:
|
||||
args.append("--exclude-pre-releases")
|
||||
return json.loads(github_read(args))
|
||||
|
||||
|
||||
def download_release(tag: str, directory: Path) -> Path:
|
||||
github_read(
|
||||
[
|
||||
"gh",
|
||||
"release",
|
||||
"download",
|
||||
tag,
|
||||
"--repo",
|
||||
"openai/codex",
|
||||
"--pattern",
|
||||
PACKAGE,
|
||||
"--dir",
|
||||
str(directory),
|
||||
# A failed download can leave a partial file in this temp directory.
|
||||
"--clobber",
|
||||
]
|
||||
)
|
||||
return directory / PACKAGE
|
||||
|
||||
|
||||
def select_stables(releases: list[dict], target_date: datetime) -> list[str]:
|
||||
stable = [
|
||||
release
|
||||
for release in releases
|
||||
if not release["isDraft"]
|
||||
and not release["isPrerelease"]
|
||||
and STABLE_TAG.fullmatch(release["tagName"])
|
||||
]
|
||||
stable.sort(
|
||||
key=lambda release: tuple(map(int, release["tagName"][6:].split("."))),
|
||||
reverse=True,
|
||||
)
|
||||
if not stable:
|
||||
raise ValueError("No stable releases available")
|
||||
# The descending version order breaks equal-distance ties deterministically.
|
||||
baseline = min(
|
||||
stable,
|
||||
key=lambda release: abs(
|
||||
datetime.fromisoformat(release["publishedAt"].replace("Z", "+00:00"))
|
||||
- target_date
|
||||
),
|
||||
)
|
||||
# A long release pause can make latest and historical resolve to one build.
|
||||
return list(dict.fromkeys([stable[0]["tagName"], baseline["tagName"]]))
|
||||
192
.github/scripts/fixtures/codex-0.167.0-alpha.2-assets.txt
vendored
Normal file
192
.github/scripts/fixtures/codex-0.167.0-alpha.2-assets.txt
vendored
Normal file
@@ -0,0 +1,192 @@
|
||||
argument-comment-lint-aarch64-apple-darwin.tar.gz
|
||||
argument-comment-lint-aarch64-unknown-linux-gnu.tar.gz
|
||||
argument-comment-lint-x86_64-pc-windows-msvc.zip
|
||||
argument-comment-lint-x86_64-unknown-linux-gnu.tar.gz
|
||||
bwrap
|
||||
bwrap-aarch64-unknown-linux-musl.sigstore
|
||||
bwrap-aarch64-unknown-linux-musl.tar.gz
|
||||
bwrap-aarch64-unknown-linux-musl.zst
|
||||
bwrap-x86_64-unknown-linux-musl.sigstore
|
||||
bwrap-x86_64-unknown-linux-musl.tar.gz
|
||||
bwrap-x86_64-unknown-linux-musl.zst
|
||||
codex
|
||||
codex-aarch64-apple-darwin.dmg
|
||||
codex-aarch64-apple-darwin.tar.gz
|
||||
codex-aarch64-apple-darwin.zst
|
||||
codex-aarch64-pc-windows-msvc.exe
|
||||
codex-aarch64-pc-windows-msvc.exe.tar.gz
|
||||
codex-aarch64-pc-windows-msvc.exe.zip
|
||||
codex-aarch64-pc-windows-msvc.exe.zst
|
||||
codex-aarch64-unknown-linux-musl.sigstore
|
||||
codex-aarch64-unknown-linux-musl.tar.gz
|
||||
codex-aarch64-unknown-linux-musl.zst
|
||||
codex-app-server
|
||||
codex-app-server-aarch64-apple-darwin.tar.gz
|
||||
codex-app-server-aarch64-apple-darwin.zst
|
||||
codex-app-server-aarch64-pc-windows-msvc.exe
|
||||
codex-app-server-aarch64-pc-windows-msvc.exe.tar.gz
|
||||
codex-app-server-aarch64-pc-windows-msvc.exe.zip
|
||||
codex-app-server-aarch64-pc-windows-msvc.exe.zst
|
||||
codex-app-server-aarch64-unknown-linux-musl.sigstore
|
||||
codex-app-server-aarch64-unknown-linux-musl.tar.gz
|
||||
codex-app-server-aarch64-unknown-linux-musl.zst
|
||||
codex-app-server-package-aarch64-apple-darwin.tar.gz
|
||||
codex-app-server-package-aarch64-apple-darwin.tar.zst
|
||||
codex-app-server-package-aarch64-pc-windows-msvc.tar.gz
|
||||
codex-app-server-package-aarch64-pc-windows-msvc.tar.zst
|
||||
codex-app-server-package-aarch64-unknown-linux-musl.tar.gz
|
||||
codex-app-server-package-aarch64-unknown-linux-musl.tar.zst
|
||||
codex-app-server-package-x86_64-apple-darwin.tar.gz
|
||||
codex-app-server-package-x86_64-apple-darwin.tar.zst
|
||||
codex-app-server-package-x86_64-pc-windows-msvc.tar.gz
|
||||
codex-app-server-package-x86_64-pc-windows-msvc.tar.zst
|
||||
codex-app-server-package-x86_64-unknown-linux-musl.tar.gz
|
||||
codex-app-server-package-x86_64-unknown-linux-musl.tar.zst
|
||||
codex-app-server-x86_64-apple-darwin.tar.gz
|
||||
codex-app-server-x86_64-apple-darwin.zst
|
||||
codex-app-server-x86_64-pc-windows-msvc.exe
|
||||
codex-app-server-x86_64-pc-windows-msvc.exe.tar.gz
|
||||
codex-app-server-x86_64-pc-windows-msvc.exe.zip
|
||||
codex-app-server-x86_64-pc-windows-msvc.exe.zst
|
||||
codex-app-server-x86_64-unknown-linux-musl.sigstore
|
||||
codex-app-server-x86_64-unknown-linux-musl.tar.gz
|
||||
codex-app-server-x86_64-unknown-linux-musl.zst
|
||||
codex-code-mode-host-aarch64-apple-darwin.tar.gz
|
||||
codex-code-mode-host-aarch64-apple-darwin.zst
|
||||
codex-code-mode-host-aarch64-pc-windows-msvc.exe
|
||||
codex-code-mode-host-aarch64-pc-windows-msvc.exe.tar.gz
|
||||
codex-code-mode-host-aarch64-pc-windows-msvc.exe.zip
|
||||
codex-code-mode-host-aarch64-pc-windows-msvc.exe.zst
|
||||
codex-code-mode-host-aarch64-unknown-linux-musl.sigstore
|
||||
codex-code-mode-host-aarch64-unknown-linux-musl.tar.gz
|
||||
codex-code-mode-host-aarch64-unknown-linux-musl.zst
|
||||
codex-code-mode-host-x86_64-apple-darwin.tar.gz
|
||||
codex-code-mode-host-x86_64-apple-darwin.zst
|
||||
codex-code-mode-host-x86_64-pc-windows-msvc.exe
|
||||
codex-code-mode-host-x86_64-pc-windows-msvc.exe.tar.gz
|
||||
codex-code-mode-host-x86_64-pc-windows-msvc.exe.zip
|
||||
codex-code-mode-host-x86_64-pc-windows-msvc.exe.zst
|
||||
codex-code-mode-host-x86_64-unknown-linux-musl.sigstore
|
||||
codex-code-mode-host-x86_64-unknown-linux-musl.tar.gz
|
||||
codex-code-mode-host-x86_64-unknown-linux-musl.zst
|
||||
codex-command-runner
|
||||
codex-command-runner-aarch64-pc-windows-msvc.exe
|
||||
codex-command-runner-aarch64-pc-windows-msvc.exe.tar.gz
|
||||
codex-command-runner-aarch64-pc-windows-msvc.exe.zip
|
||||
codex-command-runner-aarch64-pc-windows-msvc.exe.zst
|
||||
codex-command-runner-x86_64-pc-windows-msvc.exe
|
||||
codex-command-runner-x86_64-pc-windows-msvc.exe.tar.gz
|
||||
codex-command-runner-x86_64-pc-windows-msvc.exe.zip
|
||||
codex-command-runner-x86_64-pc-windows-msvc.exe.zst
|
||||
codex-exec-server-aarch64-apple-darwin.tar.gz
|
||||
codex-exec-server-aarch64-apple-darwin.zst
|
||||
codex-exec-server-aarch64-pc-windows-msvc.exe
|
||||
codex-exec-server-aarch64-pc-windows-msvc.exe.tar.gz
|
||||
codex-exec-server-aarch64-pc-windows-msvc.exe.zip
|
||||
codex-exec-server-aarch64-pc-windows-msvc.exe.zst
|
||||
codex-exec-server-aarch64-unknown-linux-musl.sigstore
|
||||
codex-exec-server-aarch64-unknown-linux-musl.tar.gz
|
||||
codex-exec-server-aarch64-unknown-linux-musl.zst
|
||||
codex-exec-server-x86_64-apple-darwin.tar.gz
|
||||
codex-exec-server-x86_64-apple-darwin.zst
|
||||
codex-exec-server-x86_64-pc-windows-msvc.exe
|
||||
codex-exec-server-x86_64-pc-windows-msvc.exe.tar.gz
|
||||
codex-exec-server-x86_64-pc-windows-msvc.exe.zip
|
||||
codex-exec-server-x86_64-pc-windows-msvc.exe.zst
|
||||
codex-exec-server-x86_64-unknown-linux-musl.sigstore
|
||||
codex-exec-server-x86_64-unknown-linux-musl.tar.gz
|
||||
codex-exec-server-x86_64-unknown-linux-musl.zst
|
||||
codex-npm-0.167.0-alpha.2.tgz
|
||||
codex-npm-darwin-arm64-0.167.0-alpha.2.tgz
|
||||
codex-npm-darwin-x64-0.167.0-alpha.2.tgz
|
||||
codex-npm-linux-arm64-0.167.0-alpha.2.tgz
|
||||
codex-npm-linux-x64-0.167.0-alpha.2.tgz
|
||||
codex-npm-win32-arm64-0.167.0-alpha.2.tgz
|
||||
codex-npm-win32-x64-0.167.0-alpha.2.tgz
|
||||
codex-package-aarch64-apple-darwin.tar.gz
|
||||
codex-package-aarch64-apple-darwin.tar.zst
|
||||
codex-package-aarch64-pc-windows-msvc.tar.gz
|
||||
codex-package-aarch64-pc-windows-msvc.tar.zst
|
||||
codex-package-aarch64-unknown-linux-musl.tar.gz
|
||||
codex-package-aarch64-unknown-linux-musl.tar.gz.sigstore
|
||||
codex-package-aarch64-unknown-linux-musl.tar.zst
|
||||
codex-package-aarch64-unknown-linux-musl.tar.zst.sigstore
|
||||
codex-package-x86_64-apple-darwin.tar.gz
|
||||
codex-package-x86_64-apple-darwin.tar.zst
|
||||
codex-package-x86_64-pc-windows-msvc.tar.gz
|
||||
codex-package-x86_64-pc-windows-msvc.tar.zst
|
||||
codex-package-x86_64-unknown-linux-musl.tar.gz
|
||||
codex-package-x86_64-unknown-linux-musl.tar.gz.sigstore
|
||||
codex-package-x86_64-unknown-linux-musl.tar.zst
|
||||
codex-package-x86_64-unknown-linux-musl.tar.zst.sigstore
|
||||
codex-package_SHA256SUMS
|
||||
codex-provisioned-package-aarch64-apple-darwin.tar.gz
|
||||
codex-provisioned-package-x86_64-apple-darwin.tar.gz
|
||||
codex-responses-api-proxy
|
||||
codex-responses-api-proxy-aarch64-apple-darwin.tar.gz
|
||||
codex-responses-api-proxy-aarch64-apple-darwin.zst
|
||||
codex-responses-api-proxy-aarch64-pc-windows-msvc.exe
|
||||
codex-responses-api-proxy-aarch64-pc-windows-msvc.exe.tar.gz
|
||||
codex-responses-api-proxy-aarch64-pc-windows-msvc.exe.zip
|
||||
codex-responses-api-proxy-aarch64-pc-windows-msvc.exe.zst
|
||||
codex-responses-api-proxy-aarch64-unknown-linux-musl.sigstore
|
||||
codex-responses-api-proxy-aarch64-unknown-linux-musl.tar.gz
|
||||
codex-responses-api-proxy-aarch64-unknown-linux-musl.zst
|
||||
codex-responses-api-proxy-npm-0.167.0-alpha.2.tgz
|
||||
codex-responses-api-proxy-x86_64-apple-darwin.tar.gz
|
||||
codex-responses-api-proxy-x86_64-apple-darwin.zst
|
||||
codex-responses-api-proxy-x86_64-pc-windows-msvc.exe
|
||||
codex-responses-api-proxy-x86_64-pc-windows-msvc.exe.tar.gz
|
||||
codex-responses-api-proxy-x86_64-pc-windows-msvc.exe.zip
|
||||
codex-responses-api-proxy-x86_64-pc-windows-msvc.exe.zst
|
||||
codex-responses-api-proxy-x86_64-unknown-linux-musl.sigstore
|
||||
codex-responses-api-proxy-x86_64-unknown-linux-musl.tar.gz
|
||||
codex-responses-api-proxy-x86_64-unknown-linux-musl.zst
|
||||
codex-sdk-npm-0.167.0-alpha.2.tgz
|
||||
codex-symbols-aarch64-apple-darwin-app-server.tar.gz
|
||||
codex-symbols-aarch64-apple-darwin.tar.gz
|
||||
codex-symbols-aarch64-pc-windows-msvc.tar.gz
|
||||
codex-symbols-aarch64-unknown-linux-musl-app-server.tar.gz
|
||||
codex-symbols-aarch64-unknown-linux-musl.tar.gz
|
||||
codex-symbols-x86_64-apple-darwin-app-server.tar.gz
|
||||
codex-symbols-x86_64-apple-darwin.tar.gz
|
||||
codex-symbols-x86_64-pc-windows-msvc.tar.gz
|
||||
codex-symbols-x86_64-unknown-linux-musl-app-server.tar.gz
|
||||
codex-symbols-x86_64-unknown-linux-musl.tar.gz
|
||||
codex-windows-sandbox-service
|
||||
codex-windows-sandbox-service-aarch64-pc-windows-msvc.exe
|
||||
codex-windows-sandbox-service-aarch64-pc-windows-msvc.exe.tar.gz
|
||||
codex-windows-sandbox-service-aarch64-pc-windows-msvc.exe.zip
|
||||
codex-windows-sandbox-service-aarch64-pc-windows-msvc.exe.zst
|
||||
codex-windows-sandbox-service-x86_64-pc-windows-msvc.exe
|
||||
codex-windows-sandbox-service-x86_64-pc-windows-msvc.exe.tar.gz
|
||||
codex-windows-sandbox-service-x86_64-pc-windows-msvc.exe.zip
|
||||
codex-windows-sandbox-service-x86_64-pc-windows-msvc.exe.zst
|
||||
codex-windows-sandbox-setup
|
||||
codex-windows-sandbox-setup-aarch64-pc-windows-msvc.exe
|
||||
codex-windows-sandbox-setup-aarch64-pc-windows-msvc.exe.tar.gz
|
||||
codex-windows-sandbox-setup-aarch64-pc-windows-msvc.exe.zip
|
||||
codex-windows-sandbox-setup-aarch64-pc-windows-msvc.exe.zst
|
||||
codex-windows-sandbox-setup-x86_64-pc-windows-msvc.exe
|
||||
codex-windows-sandbox-setup-x86_64-pc-windows-msvc.exe.tar.gz
|
||||
codex-windows-sandbox-setup-x86_64-pc-windows-msvc.exe.zip
|
||||
codex-windows-sandbox-setup-x86_64-pc-windows-msvc.exe.zst
|
||||
codex-x86_64-apple-darwin.dmg
|
||||
codex-x86_64-apple-darwin.tar.gz
|
||||
codex-x86_64-apple-darwin.zst
|
||||
codex-x86_64-pc-windows-msvc.exe
|
||||
codex-x86_64-pc-windows-msvc.exe.tar.gz
|
||||
codex-x86_64-pc-windows-msvc.exe.zip
|
||||
codex-x86_64-pc-windows-msvc.exe.zst
|
||||
codex-x86_64-unknown-linux-musl.sigstore
|
||||
codex-x86_64-unknown-linux-musl.tar.gz
|
||||
codex-x86_64-unknown-linux-musl.zst
|
||||
config-schema.json
|
||||
install.ps1
|
||||
install.sh
|
||||
openai_codex_cli_bin-0.167.0a2-py3-none-macosx_10_9_x86_64.whl
|
||||
openai_codex_cli_bin-0.167.0a2-py3-none-macosx_11_0_arm64.whl
|
||||
openai_codex_cli_bin-0.167.0a2-py3-none-manylinux_2_17_aarch64.whl
|
||||
openai_codex_cli_bin-0.167.0a2-py3-none-manylinux_2_17_x86_64.whl
|
||||
openai_codex_cli_bin-0.167.0a2-py3-none-win_amd64.whl
|
||||
openai_codex_cli_bin-0.167.0a2-py3-none-win_arm64.whl
|
||||
299
.github/scripts/install-musl-build-tools.sh
vendored
Normal file
299
.github/scripts/install-musl-build-tools.sh
vendored
Normal file
@@ -0,0 +1,299 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
: "${TARGET:?TARGET environment variable is required}"
|
||||
: "${GITHUB_ENV:?GITHUB_ENV environment variable is required}"
|
||||
|
||||
apt_update_args=()
|
||||
if [[ -n "${APT_UPDATE_ARGS:-}" ]]; then
|
||||
# shellcheck disable=SC2206
|
||||
apt_update_args=(${APT_UPDATE_ARGS})
|
||||
fi
|
||||
|
||||
apt_install_args=()
|
||||
if [[ -n "${APT_INSTALL_ARGS:-}" ]]; then
|
||||
# shellcheck disable=SC2206
|
||||
apt_install_args=(${APT_INSTALL_ARGS})
|
||||
fi
|
||||
|
||||
sudo apt-get update "${apt_update_args[@]}"
|
||||
sudo apt-get install -y "${apt_install_args[@]}" ca-certificates curl musl-tools pkg-config libcap-dev g++ clang libc++-dev libc++abi-dev lld xz-utils perl make
|
||||
|
||||
case "${TARGET}" in
|
||||
x86_64-unknown-linux-musl)
|
||||
arch="x86_64"
|
||||
;;
|
||||
aarch64-unknown-linux-musl)
|
||||
arch="aarch64"
|
||||
;;
|
||||
*)
|
||||
echo "Unexpected musl target: ${TARGET}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
libcap_version="2.75"
|
||||
libcap_sha256="de4e7e064c9ba451d5234dd46e897d7c71c96a9ebf9a0c445bc04f4742d83632"
|
||||
libcap_tarball_name="libcap-${libcap_version}.tar.xz"
|
||||
libcap_download_url="https://github.com/openai/codex/releases/download/libcap-v${libcap_version}/${libcap_tarball_name}"
|
||||
libcap_debian_url="https://deb.debian.org/debian/pool/main/libc/libcap2/libcap2_${libcap_version}.orig.tar.xz"
|
||||
|
||||
# Use the musl toolchain as the Rust linker to avoid Zig injecting its own CRT.
|
||||
if command -v "${arch}-linux-musl-gcc" >/dev/null; then
|
||||
musl_linker="$(command -v "${arch}-linux-musl-gcc")"
|
||||
elif command -v musl-gcc >/dev/null; then
|
||||
musl_linker="$(command -v musl-gcc)"
|
||||
else
|
||||
echo "musl gcc not found after install; arch=${arch}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OPENSSL_CC="${musl_linker}" bash "$(dirname "${BASH_SOURCE[0]}")/install-musl-openssl.sh"
|
||||
|
||||
zig_target="${TARGET/-unknown-linux-musl/-linux-musl}"
|
||||
runner_temp="${RUNNER_TEMP:-/tmp}"
|
||||
tool_root="${runner_temp}/codex-musl-tools-${TARGET}"
|
||||
mkdir -p "${tool_root}"
|
||||
|
||||
libcap_root="${tool_root}/libcap-${libcap_version}"
|
||||
libcap_src_root="${libcap_root}/src"
|
||||
libcap_prefix="${libcap_root}/prefix"
|
||||
libcap_pkgconfig_dir="${libcap_prefix}/lib/pkgconfig"
|
||||
|
||||
if [[ ! -f "${libcap_prefix}/lib/libcap.a" ]]; then
|
||||
mkdir -p "${libcap_src_root}" "${libcap_prefix}/lib" "${libcap_prefix}/include/sys" "${libcap_prefix}/include/linux" "${libcap_pkgconfig_dir}"
|
||||
libcap_tarball="${libcap_root}/${libcap_tarball_name}"
|
||||
|
||||
if ! curl -fsSL --connect-timeout 10 --max-time 60 "${libcap_download_url}" -o "${libcap_tarball}"; then
|
||||
curl -fsSL --connect-timeout 10 --max-time 60 --retry 2 "${libcap_debian_url}" -o "${libcap_tarball}"
|
||||
fi
|
||||
echo "${libcap_sha256} ${libcap_tarball}" | sha256sum -c -
|
||||
|
||||
tar -xJf "${libcap_tarball}" -C "${libcap_src_root}"
|
||||
libcap_source_dir="${libcap_src_root}/libcap-${libcap_version}"
|
||||
make -C "${libcap_source_dir}/libcap" -j"$(nproc)" \
|
||||
CC="${musl_linker}" \
|
||||
AR=ar \
|
||||
RANLIB=ranlib
|
||||
|
||||
cp "${libcap_source_dir}/libcap/libcap.a" "${libcap_prefix}/lib/libcap.a"
|
||||
cp "${libcap_source_dir}/libcap/include/uapi/linux/capability.h" "${libcap_prefix}/include/linux/capability.h"
|
||||
cp "${libcap_source_dir}/libcap/../libcap/include/sys/capability.h" "${libcap_prefix}/include/sys/capability.h"
|
||||
|
||||
cat > "${libcap_pkgconfig_dir}/libcap.pc" <<EOF
|
||||
prefix=${libcap_prefix}
|
||||
exec_prefix=\${prefix}
|
||||
libdir=\${prefix}/lib
|
||||
includedir=\${prefix}/include
|
||||
|
||||
Name: libcap
|
||||
Description: Linux capabilities
|
||||
Version: ${libcap_version}
|
||||
Libs: -L\${libdir} -lcap
|
||||
Cflags: -I\${includedir}
|
||||
EOF
|
||||
fi
|
||||
|
||||
sysroot=""
|
||||
if command -v zig >/dev/null; then
|
||||
zig_bin="$(command -v zig)"
|
||||
cc="${tool_root}/zigcc"
|
||||
cxx="${tool_root}/zigcxx"
|
||||
|
||||
cat >"${cc}" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
args=()
|
||||
skip_next=0
|
||||
pending_include=0
|
||||
for arg in "\$@"; do
|
||||
if [[ "\${pending_include}" -eq 1 ]]; then
|
||||
pending_include=0
|
||||
if [[ "\${arg}" == /usr/include || "\${arg}" == /usr/include/* ]]; then
|
||||
# Keep host-only headers available, but after the target sysroot headers.
|
||||
args+=("-idirafter" "\${arg}")
|
||||
else
|
||||
args+=("-I" "\${arg}")
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "\${skip_next}" -eq 1 ]]; then
|
||||
skip_next=0
|
||||
continue
|
||||
fi
|
||||
case "\${arg}" in
|
||||
--target)
|
||||
skip_next=1
|
||||
continue
|
||||
;;
|
||||
--target=*|-target=*|-target)
|
||||
# Drop any explicit --target/-target flags. Zig expects -target and
|
||||
# rejects Rust triples like *-unknown-linux-musl.
|
||||
if [[ "\${arg}" == "-target" ]]; then
|
||||
skip_next=1
|
||||
fi
|
||||
continue
|
||||
;;
|
||||
-I)
|
||||
pending_include=1
|
||||
continue
|
||||
;;
|
||||
-I/usr/include|-I/usr/include/*)
|
||||
# Avoid making glibc headers win over musl headers.
|
||||
args+=("-idirafter" "\${arg#-I}")
|
||||
continue
|
||||
;;
|
||||
-Wp,-U_FORTIFY_SOURCE)
|
||||
# aws-lc-sys emits this GCC preprocessor forwarding form in debug
|
||||
# builds, but zig cc expects the define flag directly.
|
||||
args+=("-U_FORTIFY_SOURCE")
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
args+=("\${arg}")
|
||||
done
|
||||
|
||||
# Zig enables UBSan for debug C builds by default. Rust links these objects
|
||||
# without Zig's sanitizer runtime, so keep native dependencies uninstrumented.
|
||||
exec "${zig_bin}" cc -target "${zig_target}" "\${args[@]}" -fno-sanitize=undefined
|
||||
EOF
|
||||
cat >"${cxx}" <<EOF
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
args=()
|
||||
skip_next=0
|
||||
pending_include=0
|
||||
for arg in "\$@"; do
|
||||
if [[ "\${pending_include}" -eq 1 ]]; then
|
||||
pending_include=0
|
||||
if [[ "\${arg}" == /usr/include || "\${arg}" == /usr/include/* ]]; then
|
||||
# Keep host-only headers available, but after the target sysroot headers.
|
||||
args+=("-idirafter" "\${arg}")
|
||||
else
|
||||
args+=("-I" "\${arg}")
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "\${skip_next}" -eq 1 ]]; then
|
||||
skip_next=0
|
||||
continue
|
||||
fi
|
||||
case "\${arg}" in
|
||||
--target)
|
||||
# Drop explicit --target and its value: we always pass zig's -target below.
|
||||
skip_next=1
|
||||
continue
|
||||
;;
|
||||
--target=*|-target=*|-target)
|
||||
# Zig expects -target and rejects Rust triples like *-unknown-linux-musl.
|
||||
if [[ "\${arg}" == "-target" ]]; then
|
||||
skip_next=1
|
||||
fi
|
||||
continue
|
||||
;;
|
||||
-I)
|
||||
pending_include=1
|
||||
continue
|
||||
;;
|
||||
-I/usr/include|-I/usr/include/*)
|
||||
# Avoid making glibc headers win over musl headers.
|
||||
args+=("-idirafter" "\${arg#-I}")
|
||||
continue
|
||||
;;
|
||||
-Wp,-U_FORTIFY_SOURCE)
|
||||
# aws-lc-sys emits this GCC forwarding form in debug builds; zig c++
|
||||
# expects the define flag directly.
|
||||
args+=("-U_FORTIFY_SOURCE")
|
||||
continue
|
||||
;;
|
||||
esac
|
||||
args+=("\${arg}")
|
||||
done
|
||||
|
||||
# Zig enables UBSan for debug C++ builds by default. Rust links these objects
|
||||
# without Zig's sanitizer runtime, so keep native dependencies uninstrumented.
|
||||
exec "${zig_bin}" c++ -target "${zig_target}" "\${args[@]}" -fno-sanitize=undefined
|
||||
EOF
|
||||
chmod +x "${cc}" "${cxx}"
|
||||
|
||||
sysroot="$("${zig_bin}" cc -target "${zig_target}" -print-sysroot 2>/dev/null || true)"
|
||||
else
|
||||
cc="${musl_linker}"
|
||||
|
||||
if command -v "${arch}-linux-musl-g++" >/dev/null; then
|
||||
cxx="$(command -v "${arch}-linux-musl-g++")"
|
||||
elif command -v musl-g++ >/dev/null; then
|
||||
cxx="$(command -v musl-g++)"
|
||||
else
|
||||
cxx="${cc}"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "${sysroot}" && "${sysroot}" != "/" ]]; then
|
||||
echo "BORING_BSSL_SYSROOT=${sysroot}" >> "$GITHUB_ENV"
|
||||
boring_sysroot_var="BORING_BSSL_SYSROOT_${TARGET}"
|
||||
boring_sysroot_var="${boring_sysroot_var//-/_}"
|
||||
echo "${boring_sysroot_var}=${sysroot}" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
cflags="-pthread"
|
||||
cxxflags="-pthread"
|
||||
if [[ "${TARGET}" == "aarch64-unknown-linux-musl" ]]; then
|
||||
# BoringSSL enables -Wframe-larger-than=25344 under clang and treats warnings as errors.
|
||||
cflags="${cflags} -Wno-error=frame-larger-than"
|
||||
cxxflags="${cxxflags} -Wno-error=frame-larger-than"
|
||||
fi
|
||||
|
||||
echo "CFLAGS=${cflags}" >> "$GITHUB_ENV"
|
||||
echo "CXXFLAGS=${cxxflags}" >> "$GITHUB_ENV"
|
||||
echo "CC=${cc}" >> "$GITHUB_ENV"
|
||||
echo "TARGET_CC=${cc}" >> "$GITHUB_ENV"
|
||||
target_cc_var="CC_${TARGET}"
|
||||
target_cc_var="${target_cc_var//-/_}"
|
||||
echo "${target_cc_var}=${cc}" >> "$GITHUB_ENV"
|
||||
echo "CXX=${cxx}" >> "$GITHUB_ENV"
|
||||
echo "TARGET_CXX=${cxx}" >> "$GITHUB_ENV"
|
||||
target_cxx_var="CXX_${TARGET}"
|
||||
target_cxx_var="${target_cxx_var//-/_}"
|
||||
echo "${target_cxx_var}=${cxx}" >> "$GITHUB_ENV"
|
||||
|
||||
# Fold identical code and pack relocations for x86-64 musl release packages.
|
||||
if [[ "${TARGET}" == "x86_64-unknown-linux-musl" && "${CODEX_MUSL_RELEASE_LINK_FLAGS:-}" == "1" ]]; then
|
||||
link_flags=(-Cllvm-args=--addrsig -Clink-arg=-fuse-ld=lld -Clink-arg=-Wl,--icf=safe,-z,pack-relative-relocs)
|
||||
echo "RUSTFLAGS=${RUSTFLAGS:+$RUSTFLAGS }${link_flags[*]}" >> "$GITHUB_ENV"
|
||||
fi
|
||||
|
||||
cargo_linker_var="CARGO_TARGET_${TARGET^^}_LINKER"
|
||||
cargo_linker_var="${cargo_linker_var//-/_}"
|
||||
echo "${cargo_linker_var}=${musl_linker}" >> "$GITHUB_ENV"
|
||||
|
||||
echo "CMAKE_C_COMPILER=${cc}" >> "$GITHUB_ENV"
|
||||
echo "CMAKE_CXX_COMPILER=${cxx}" >> "$GITHUB_ENV"
|
||||
echo "CMAKE_ARGS=-DCMAKE_HAVE_THREADS_LIBRARY=1 -DCMAKE_USE_PTHREADS_INIT=1 -DCMAKE_THREAD_LIBS_INIT=-pthread -DTHREADS_PREFER_PTHREAD_FLAG=ON" >> "$GITHUB_ENV"
|
||||
|
||||
# Allow pkg-config resolution during cross-compilation.
|
||||
echo "PKG_CONFIG_ALLOW_CROSS=1" >> "$GITHUB_ENV"
|
||||
pkg_config_path="${libcap_pkgconfig_dir}"
|
||||
if [[ -n "${PKG_CONFIG_PATH:-}" ]]; then
|
||||
pkg_config_path="${pkg_config_path}:${PKG_CONFIG_PATH}"
|
||||
fi
|
||||
echo "PKG_CONFIG_PATH=${pkg_config_path}" >> "$GITHUB_ENV"
|
||||
pkg_config_path_var="PKG_CONFIG_PATH_${TARGET}"
|
||||
pkg_config_path_var="${pkg_config_path_var//-/_}"
|
||||
echo "${pkg_config_path_var}=${libcap_pkgconfig_dir}" >> "$GITHUB_ENV"
|
||||
pkg_config_libdir_var="PKG_CONFIG_LIBDIR_${TARGET}"
|
||||
pkg_config_libdir_var="${pkg_config_libdir_var//-/_}"
|
||||
# Do not let musl cross-builds resolve native libraries from the host glibc
|
||||
# pkg-config directories. libcap is the only target package provided here.
|
||||
echo "${pkg_config_libdir_var}=${libcap_pkgconfig_dir}" >> "$GITHUB_ENV"
|
||||
|
||||
if [[ -n "${sysroot}" && "${sysroot}" != "/" ]]; then
|
||||
echo "PKG_CONFIG_SYSROOT_DIR=${sysroot}" >> "$GITHUB_ENV"
|
||||
pkg_config_sysroot_var="PKG_CONFIG_SYSROOT_DIR_${TARGET}"
|
||||
pkg_config_sysroot_var="${pkg_config_sysroot_var//-/_}"
|
||||
echo "${pkg_config_sysroot_var}=${sysroot}" >> "$GITHUB_ENV"
|
||||
fi
|
||||
51
.github/scripts/install-musl-openssl.sh
vendored
Normal file
51
.github/scripts/install-musl-openssl.sh
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
: "${TARGET:?TARGET environment variable is required}"
|
||||
: "${GITHUB_ENV:?GITHUB_ENV environment variable is required}"
|
||||
: "${OPENSSL_CC:?OPENSSL_CC must name the target musl compiler}"
|
||||
|
||||
case "${TARGET}" in
|
||||
x86_64-unknown-linux-musl) openssl_target="linux-x86_64" ;;
|
||||
aarch64-unknown-linux-musl) openssl_target="linux-aarch64" ;;
|
||||
*) echo "Unexpected musl target: ${TARGET}" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
# openssl-src's latest 300.x crate still contains 3.6.3. Build the upstream
|
||||
# security release until that crate catches up, keeping the existing 3.x ABI.
|
||||
openssl_version="3.6.4"
|
||||
openssl_sha256="9bffaa1ad1e07b354c21bd3324ec02fa15579f45a7d0494b3e74bc449b7333ef"
|
||||
openssl_root="${RUNNER_TEMP:-/tmp}/codex-musl-tools-${TARGET}/openssl-${openssl_version}"
|
||||
openssl_prefix="${openssl_root}/prefix"
|
||||
|
||||
if [[ ! -f "${openssl_prefix}/.complete" ]]; then
|
||||
mkdir -p "${openssl_root}"
|
||||
archive="${openssl_root}/openssl-${openssl_version}.tar.gz"
|
||||
curl -fsSL "https://github.com/openssl/openssl/releases/download/openssl-${openssl_version}/openssl-${openssl_version}.tar.gz" -o "${archive}"
|
||||
echo "${openssl_sha256} ${archive}" | sha256sum -c -
|
||||
tar -xzf "${archive}" -C "${openssl_root}"
|
||||
|
||||
(
|
||||
cd "${openssl_root}/openssl-${openssl_version}"
|
||||
# Match openssl-src's default/legacy configuration for musl, including
|
||||
# disabling shared libraries, zlib, engines, and unsupported async APIs.
|
||||
CC="${OPENSSL_CC}" perl ./Configure "${openssl_target}" \
|
||||
"--prefix=${openssl_prefix}" --openssldir=/usr/local/ssl --libdir=lib \
|
||||
no-shared no-module no-tests no-comp no-zlib no-zlib-dynamic \
|
||||
no-ssl3 no-md2 no-rc5 no-weak-ssl-ciphers no-camellia no-idea no-seed \
|
||||
no-engine no-async -DOPENSSL_NO_SECURE_MEMORY
|
||||
make -j"${OPENSSL_BUILD_JOBS:-$(nproc)}" build_libs
|
||||
make install_dev
|
||||
)
|
||||
touch "${openssl_prefix}/.complete"
|
||||
fi
|
||||
|
||||
# Scope these overrides to the target so host build dependencies are unaffected.
|
||||
# openssl-sys honors OPENSSL_NO_VENDOR even when Cargo enables `vendored`.
|
||||
target_env="${TARGET^^}"
|
||||
target_env="${target_env//-/_}"
|
||||
{
|
||||
echo "${target_env}_OPENSSL_DIR=${openssl_prefix}"
|
||||
echo "${target_env}_OPENSSL_NO_VENDOR=1"
|
||||
echo "${target_env}_OPENSSL_STATIC=1"
|
||||
} >> "${GITHUB_ENV}"
|
||||
40
.github/scripts/macos-signing/README.md
vendored
Normal file
40
.github/scripts/macos-signing/README.md
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# Provisioned CLI signing identity
|
||||
|
||||
The provisioned CLI has two deliberately separate identifiers:
|
||||
|
||||
| Purpose | Identifier |
|
||||
| ------------------------------------- | ------------------------------- |
|
||||
| Code-signing identifier | `codex` |
|
||||
| Bundle identifier | `com.openai.codex.cli` |
|
||||
| Provisioned App ID and keychain group | `<TeamID>.com.openai.codex.cli` |
|
||||
|
||||
The code-signing identifier preserves access to existing login-keychain items
|
||||
whose access rules require the original CLI identity. Giving the CLI an app
|
||||
bundle must not change that identifier. The bundle identifier, App ID,
|
||||
entitlements, profile, and approved certificate remain independently validated.
|
||||
The native-verification keys use the provisioned keychain group; they do not
|
||||
replace existing login-keychain credential access rules.
|
||||
|
||||
Changing the new binary's designated requirement to accept both identifiers
|
||||
would not make it satisfy an existing item's requirement for `codex`. Items
|
||||
created by a binary signed as `com.openai.codex.cli` are a separate compatibility
|
||||
case: restoring `codex` does not silently authorize access to those items.
|
||||
|
||||
The signing backend must honor an explicit `--binary-identifier` when signing
|
||||
an app bundle. The wrapper signs the bundle once; rcodesign seals its metadata
|
||||
and resources while retaining `codex` as the main executable's identity.
|
||||
Release tool artifact URIs and SHA-256 digests are pinned in the signing
|
||||
environment configuration.
|
||||
|
||||
## Release verification
|
||||
|
||||
When `CODEX_PROVISIONED_MACOS_CANDIDATE` is enabled, tag releases automatically
|
||||
publish the provisioned archives and versioned `codex-provisioned` manifest after
|
||||
both architecture packages pass the existing signature, entitlement, profile,
|
||||
architecture, stapling, Gatekeeper, and package-smoke checks. An enabled
|
||||
provisioned build that fails verification blocks release publication.
|
||||
|
||||
The signing-driver tests use generated credentials and stubbed native tools.
|
||||
They cover the signing command contract and failure handling. Actual keychain
|
||||
access and credential recovery across identity changes require runtime testing;
|
||||
these unit tests do not establish that behavior.
|
||||
10
.github/scripts/macos-signing/codex-app-server.entitlements.plist
vendored
Normal file
10
.github/scripts/macos-signing/codex-app-server.entitlements.plist
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
10
.github/scripts/macos-signing/codex-code-mode-host.entitlements.plist
vendored
Normal file
10
.github/scripts/macos-signing/codex-code-mode-host.entitlements.plist
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
5
.github/scripts/macos-signing/codex-exec-server.entitlements.plist
vendored
Normal file
5
.github/scripts/macos-signing/codex-exec-server.entitlements.plist
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict/>
|
||||
</plist>
|
||||
8
.github/scripts/macos-signing/codex-responses-api-proxy.entitlements.plist
vendored
Normal file
8
.github/scripts/macos-signing/codex-responses-api-proxy.entitlements.plist
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
8
.github/scripts/macos-signing/codex-voice-host.entitlements.plist
vendored
Normal file
8
.github/scripts/macos-signing/codex-voice-host.entitlements.plist
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.device.audio-input</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
10
.github/scripts/macos-signing/codex.entitlements.plist
vendored
Normal file
10
.github/scripts/macos-signing/codex.entitlements.plist
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.cs.allow-jit</key>
|
||||
<true/>
|
||||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
110
.github/scripts/macos-signing/notarize_macos_binary_with_akv.sh
vendored
Executable file
110
.github/scripts/macos-signing/notarize_macos_binary_with_akv.sh
vendored
Executable file
@@ -0,0 +1,110 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Notarize a standalone binary and retain its diagnostic report.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat >&2 <<'EOF'
|
||||
Usage: notarize_macos_binary_with_akv.sh --binary PATH [--report-dir PATH] [--max-wait-seconds SECONDS]
|
||||
|
||||
Options:
|
||||
--binary PATH Signed standalone macOS binary to notarize.
|
||||
--report-dir PATH Directory for notarization logs.
|
||||
--max-wait-seconds SECONDS Maximum Apple notarization wait time.
|
||||
EOF
|
||||
}
|
||||
|
||||
binary_path=""
|
||||
report_dir="${RUNNER_TEMP:-/tmp}/macos-binary-notarization-verification"
|
||||
max_wait_seconds="600"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--binary)
|
||||
binary_path="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--report-dir)
|
||||
report_dir="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--max-wait-seconds)
|
||||
max_wait_seconds="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown notarization argument: $1" >&2
|
||||
usage
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$binary_path" ]]; then
|
||||
echo "--binary is required." >&2
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ ! -f "$binary_path" ]]; then
|
||||
echo "Binary does not exist: $binary_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! "$max_wait_seconds" =~ ^[0-9]+$ ]]; then
|
||||
echo "--max-wait-seconds must be a non-negative integer." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
for command_name in python3 zip; do
|
||||
if ! command -v "$command_name" >/dev/null 2>&1; then
|
||||
echo "$command_name was not found on PATH." >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
missing_environment=0
|
||||
for variable_name in \
|
||||
APPLE_NOTARIZATION_AKV_KEY_NAME \
|
||||
AZURE_KEYVAULT_NAME
|
||||
do
|
||||
if [[ -z "${!variable_name:-}" ]]; then
|
||||
echo "$variable_name must be configured before notarizing a binary." >&2
|
||||
missing_environment=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$missing_environment" -ne 0 ]]; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "$report_dir"
|
||||
|
||||
notarization_temp_dir="$(mktemp -d)"
|
||||
trap 'rm -rf "$notarization_temp_dir" >/dev/null' EXIT
|
||||
|
||||
binary_name="$(basename "$binary_path")"
|
||||
archive_path="$notarization_temp_dir/${binary_name}.zip"
|
||||
(
|
||||
cd "$(dirname "$binary_path")"
|
||||
zip -q "$archive_path" "$binary_name"
|
||||
)
|
||||
|
||||
notarization_log="$report_dir/${binary_name}-notarization.log"
|
||||
python3 "$(dirname "$0")/notarize_with_akv.py" \
|
||||
--file "$archive_path" \
|
||||
--report-log "$report_dir/${binary_name}-notarization-developer-log.json" \
|
||||
--max-wait-seconds "$max_wait_seconds" \
|
||||
2>&1 | tee "$notarization_log"
|
||||
|
||||
{
|
||||
echo "binary_name=$binary_name"
|
||||
echo "max_wait_seconds=$max_wait_seconds"
|
||||
echo "binary_sha256=$(shasum -a 256 "$binary_path" | awk '{ print $1 }')"
|
||||
echo "notarization=completed"
|
||||
} >"$report_dir/${binary_name}-notarization-summary.txt"
|
||||
100
.github/scripts/macos-signing/notarize_macos_dmg_with_akv.sh
vendored
Executable file
100
.github/scripts/macos-signing/notarize_macos_dmg_with_akv.sh
vendored
Executable file
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Notarize a signed disk image and staple its ticket.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat >&2 <<'EOF'
|
||||
Usage: notarize_macos_dmg_with_akv.sh --dmg PATH [--report-dir PATH] [--max-wait-seconds SECONDS]
|
||||
|
||||
Options:
|
||||
--dmg PATH Signed DMG to submit to Apple notarization.
|
||||
--report-dir PATH Directory for notarization logs.
|
||||
--max-wait-seconds SECONDS Maximum Apple notarization wait time.
|
||||
EOF
|
||||
}
|
||||
|
||||
dmg_path=""
|
||||
report_dir="${RUNNER_TEMP:-/tmp}/macos-notarization-verification"
|
||||
max_wait_seconds="600"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--dmg)
|
||||
dmg_path="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--report-dir)
|
||||
report_dir="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--max-wait-seconds)
|
||||
max_wait_seconds="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown notarization argument: $1" >&2
|
||||
usage
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$dmg_path" ]]; then
|
||||
echo "--dmg is required." >&2
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ ! -f "$dmg_path" ]]; then
|
||||
echo "DMG does not exist: $dmg_path" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! "$max_wait_seconds" =~ ^[0-9]+$ ]]; then
|
||||
echo "--max-wait-seconds must be a non-negative integer." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if ! command -v rcodesign > /dev/null 2>&1; then
|
||||
echo "rcodesign was not found on PATH." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
missing_environment=0
|
||||
for variable_name in \
|
||||
APPLE_NOTARIZATION_AKV_KEY_NAME \
|
||||
AZURE_KEYVAULT_NAME
|
||||
do
|
||||
if [[ -z "${!variable_name:-}" ]]; then
|
||||
echo "$variable_name must be configured before notarizing a DMG." >&2
|
||||
missing_environment=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ "$missing_environment" -ne 0 ]]; then
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "$report_dir"
|
||||
|
||||
notarization_log="$report_dir/dmg-notarization.log"
|
||||
python3 "$(dirname "$0")/notarize_with_akv.py" \
|
||||
--file "$dmg_path" \
|
||||
--report-log "$report_dir/dmg-notarization-developer-log.json" \
|
||||
--max-wait-seconds "$max_wait_seconds" \
|
||||
2>&1 | tee "$notarization_log"
|
||||
|
||||
rcodesign staple "$dmg_path" 2>&1 | tee -a "$notarization_log"
|
||||
|
||||
{
|
||||
echo "dmg_path=$dmg_path"
|
||||
echo "max_wait_seconds=$max_wait_seconds"
|
||||
echo "dmg_sha256=$(shasum -a 256 "$dmg_path" | awk '{ print $1 }')"
|
||||
echo "notarization_staple=completed"
|
||||
} > "$report_dir/dmg-notarization-summary.txt"
|
||||
519
.github/scripts/macos-signing/notarize_with_akv.py
vendored
Normal file
519
.github/scripts/macos-signing/notarize_with_akv.py
vendored
Normal file
@@ -0,0 +1,519 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Submit release artifacts for notarization and wait for the result."""
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import datetime
|
||||
import hashlib
|
||||
import hmac
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import urllib.error
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
APPLE_NOTARY_URL = "https://appstoreconnect.apple.com/notary/v2/submissions"
|
||||
AZURE_KEYVAULT_API_VERSION = "7.4"
|
||||
AWS_REGION = "us-west-2"
|
||||
JWT_LIFETIME_SECONDS = 15 * 60
|
||||
POLL_INTERVAL_SECONDS = 10
|
||||
MAX_SINGLE_UPLOAD_BYTES = 5 * 1024 * 1024 * 1024
|
||||
|
||||
|
||||
class NotarizationError(RuntimeError):
|
||||
"""Describe a notarization failure."""
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class NotarizationConfiguration:
|
||||
"""Hold the account and signing-key configuration."""
|
||||
|
||||
issuer_id: str
|
||||
apple_key_id: str
|
||||
vault_name: str
|
||||
vault_key_name: str
|
||||
vault_key_version: str
|
||||
|
||||
@classmethod
|
||||
def from_environment(cls) -> "NotarizationConfiguration":
|
||||
"""Load and validate the notarization configuration."""
|
||||
|
||||
required = {
|
||||
"vault_name": "AZURE_KEYVAULT_NAME",
|
||||
"vault_key_name": "APPLE_NOTARIZATION_AKV_KEY_NAME",
|
||||
}
|
||||
values = {
|
||||
field: os.environ.get(name, "").strip() for field, name in required.items()
|
||||
}
|
||||
missing = [name for field, name in required.items() if not values[field]]
|
||||
if missing:
|
||||
raise NotarizationError(
|
||||
"Missing notarization configuration: " + ", ".join(missing)
|
||||
)
|
||||
if not re.fullmatch(r"[A-Za-z][A-Za-z0-9-]{2,23}", values["vault_name"]):
|
||||
raise NotarizationError("Invalid signing vault name")
|
||||
if not re.fullmatch(r"[A-Za-z0-9-]+", values["vault_key_name"]):
|
||||
raise NotarizationError("Invalid notarization key name")
|
||||
key_version = os.environ.get("APPLE_NOTARIZATION_AKV_KEY_VERSION", "").strip()
|
||||
if key_version and not re.fullmatch(r"[0-9a-fA-F]{32}", key_version):
|
||||
raise NotarizationError(
|
||||
"Notarization key must resolve to a 32-character pinned version"
|
||||
)
|
||||
|
||||
command = [
|
||||
"az",
|
||||
"keyvault",
|
||||
"key",
|
||||
"show",
|
||||
"--vault-name",
|
||||
values["vault_name"],
|
||||
"--name",
|
||||
values["vault_key_name"],
|
||||
]
|
||||
if key_version:
|
||||
command.extend(["--version", key_version])
|
||||
command.extend(
|
||||
[
|
||||
"--query",
|
||||
'{id:key.kid,apple_key_id:tags."apple-key-id",'
|
||||
'apple_issuer_id:tags."apple-issuer-id"}',
|
||||
"--output",
|
||||
"json",
|
||||
"--only-show-errors",
|
||||
]
|
||||
)
|
||||
|
||||
# Resolve the key identifier and version from the same lookup.
|
||||
try:
|
||||
result = subprocess.run(command, check=True, capture_output=True, text=True)
|
||||
except (OSError, subprocess.CalledProcessError) as error:
|
||||
raise NotarizationError(
|
||||
"Notarization signing key could not be read"
|
||||
) from error
|
||||
try:
|
||||
metadata = json.loads(result.stdout)
|
||||
returned_key_id = metadata["id"]
|
||||
apple_key_id = metadata["apple_key_id"]
|
||||
apple_issuer_id = metadata["apple_issuer_id"]
|
||||
except (json.JSONDecodeError, KeyError, TypeError) as error:
|
||||
raise NotarizationError("Notarization key metadata is invalid") from error
|
||||
|
||||
key_id_prefix = f"https://{values['vault_name']}.vault.azure.net/keys/{values['vault_key_name']}/"
|
||||
if not isinstance(returned_key_id, str) or not returned_key_id.startswith(
|
||||
key_id_prefix
|
||||
):
|
||||
raise NotarizationError("Unexpected notarization signing key")
|
||||
returned_key_version = returned_key_id[len(key_id_prefix) :]
|
||||
if not re.fullmatch(r"[0-9a-fA-F]{32}", returned_key_version):
|
||||
raise NotarizationError(
|
||||
"Notarization key must resolve to a 32-character pinned version"
|
||||
)
|
||||
if key_version and returned_key_version.lower() != key_version.lower():
|
||||
raise NotarizationError("Unexpected notarization key version")
|
||||
if not isinstance(apple_key_id, str) or not apple_key_id.strip():
|
||||
raise NotarizationError("Notarization key must have an apple-key-id tag")
|
||||
if not isinstance(apple_issuer_id, str) or not apple_issuer_id.strip():
|
||||
raise NotarizationError("Notarization key must have an apple-issuer-id tag")
|
||||
if not re.fullmatch(
|
||||
r"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-"
|
||||
r"[0-9a-fA-F]{4}-[0-9a-fA-F]{12}",
|
||||
apple_issuer_id.strip(),
|
||||
):
|
||||
raise NotarizationError(
|
||||
"Notarization apple-issuer-id tag must contain a valid UUID"
|
||||
)
|
||||
|
||||
values["issuer_id"] = apple_issuer_id.strip()
|
||||
values["apple_key_id"] = apple_key_id.strip()
|
||||
values["vault_key_version"] = returned_key_version
|
||||
return cls(**values)
|
||||
|
||||
@property
|
||||
def versioned_key_id(self) -> str:
|
||||
"""Return the versioned signing-key identifier."""
|
||||
|
||||
return (
|
||||
f"https://{self.vault_name}.vault.azure.net/keys/"
|
||||
f"{self.vault_key_name}/{self.vault_key_version}"
|
||||
)
|
||||
|
||||
|
||||
def base64url_encode(value: bytes) -> str:
|
||||
"""Encode bytes using the unpadded base64url format required by JWTs."""
|
||||
|
||||
return base64.urlsafe_b64encode(value).decode("ascii").rstrip("=")
|
||||
|
||||
|
||||
def base64url_decode(value: str) -> bytes:
|
||||
"""Decode a base64url value and reject malformed input."""
|
||||
|
||||
try:
|
||||
return base64.b64decode(
|
||||
value + "=" * (-len(value) % 4), altchars=b"-_", validate=True
|
||||
)
|
||||
except (ValueError, UnicodeEncodeError) as error:
|
||||
raise NotarizationError(
|
||||
"Signing service returned an invalid signature"
|
||||
) from error
|
||||
|
||||
|
||||
def create_apple_jwt(
|
||||
configuration: NotarizationConfiguration, *, issued_at: int
|
||||
) -> str:
|
||||
"""Create an authentication token for notarization requests."""
|
||||
|
||||
header = {"alg": "ES256", "kid": configuration.apple_key_id, "typ": "JWT"}
|
||||
# Restrict the token to notarization requests.
|
||||
claims = {
|
||||
"iss": configuration.issuer_id,
|
||||
"iat": issued_at,
|
||||
"exp": issued_at + JWT_LIFETIME_SECONDS,
|
||||
"aud": "appstoreconnect-v1",
|
||||
"scope": ["/notary/v2"],
|
||||
}
|
||||
encoded_header = base64url_encode(
|
||||
json.dumps(header, separators=(",", ":")).encode("utf-8")
|
||||
)
|
||||
encoded_claims = base64url_encode(
|
||||
json.dumps(claims, separators=(",", ":")).encode("utf-8")
|
||||
)
|
||||
signing_input = f"{encoded_header}.{encoded_claims}"
|
||||
digest = hashlib.sha256(signing_input.encode("ascii")).digest()
|
||||
key_url = configuration.versioned_key_id
|
||||
request_body = json.dumps({"alg": "ES256", "value": base64url_encode(digest)})
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
[
|
||||
"az",
|
||||
"rest",
|
||||
"--method",
|
||||
"post",
|
||||
"--url",
|
||||
f"{key_url}/sign?api-version={AZURE_KEYVAULT_API_VERSION}",
|
||||
"--resource",
|
||||
"https://vault.azure.net",
|
||||
"--headers",
|
||||
"Content-Type=application/json",
|
||||
"--body",
|
||||
request_body,
|
||||
"--output",
|
||||
"json",
|
||||
"--only-show-errors",
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
except (OSError, subprocess.CalledProcessError) as error:
|
||||
detail = getattr(error, "stderr", "").strip()
|
||||
message = "Signing service could not sign the authentication token"
|
||||
if detail:
|
||||
message = f"{message}: {detail}"
|
||||
raise NotarizationError(message) from error
|
||||
|
||||
try:
|
||||
response = json.loads(result.stdout)
|
||||
returned_key_id = response["kid"]
|
||||
encoded_signature = response["value"]
|
||||
except (json.JSONDecodeError, KeyError, TypeError) as error:
|
||||
raise NotarizationError(
|
||||
"Signing service returned an invalid response"
|
||||
) from error
|
||||
|
||||
# Reject signatures generated with a different key version.
|
||||
if returned_key_id != key_url:
|
||||
raise NotarizationError("Signing service returned an unexpected key version")
|
||||
if not isinstance(encoded_signature, str):
|
||||
raise NotarizationError("Signing service returned an invalid signature")
|
||||
signature = base64url_decode(encoded_signature)
|
||||
# ES256 JWT signatures are 64 raw R || S bytes, not ASN.1/DER-encoded ECDSA signatures.
|
||||
if len(signature) != 64:
|
||||
raise NotarizationError("ES256 signature must contain 64 JOSE R || S bytes")
|
||||
return f"{signing_input}.{base64url_encode(signature)}"
|
||||
|
||||
|
||||
def json_request(
|
||||
url: str, token: str, *, body: dict[str, Any] | None = None
|
||||
) -> dict[str, Any]:
|
||||
"""Send an authenticated JSON request to Apple's notarization service."""
|
||||
|
||||
data = None if body is None else json.dumps(body).encode("utf-8")
|
||||
request = urllib.request.Request(
|
||||
url,
|
||||
data=data,
|
||||
method="GET" if body is None else "POST",
|
||||
headers={
|
||||
"Accept": "application/json",
|
||||
"Authorization": f"Bearer {token}",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
)
|
||||
try:
|
||||
with urllib.request.urlopen(request, timeout=60) as response:
|
||||
result = json.load(response)
|
||||
except urllib.error.HTTPError as error:
|
||||
detail = error.read(1024).decode("utf-8", errors="replace")
|
||||
raise NotarizationError(
|
||||
f"Apple Notary API returned HTTP {error.code}: {detail}"
|
||||
) from error
|
||||
except (OSError, json.JSONDecodeError) as error:
|
||||
raise NotarizationError("Apple Notary API request failed") from error
|
||||
|
||||
if not isinstance(result, dict):
|
||||
raise NotarizationError("Apple Notary API returned an invalid response")
|
||||
return result
|
||||
|
||||
|
||||
def sha256_file(path: Path) -> str:
|
||||
"""Hash an artifact incrementally so large release files stay off the heap."""
|
||||
|
||||
digest = hashlib.sha256()
|
||||
with path.open("rb") as source:
|
||||
for chunk in iter(lambda: source.read(1024 * 1024), b""):
|
||||
digest.update(chunk)
|
||||
return digest.hexdigest()
|
||||
|
||||
|
||||
def hmac_sha256(key: bytes, value: str) -> bytes:
|
||||
"""Derive one AWS Signature Version 4 signing-key component."""
|
||||
|
||||
return hmac.new(key, value.encode("utf-8"), hashlib.sha256).digest()
|
||||
|
||||
|
||||
def upload_to_apple_s3(
|
||||
path: Path,
|
||||
file_digest: str,
|
||||
credentials: dict[str, Any],
|
||||
*,
|
||||
timestamp: datetime.datetime | None = None,
|
||||
) -> None:
|
||||
"""Upload an artifact using the provided temporary credentials."""
|
||||
|
||||
required = (
|
||||
"awsAccessKeyId",
|
||||
"awsSecretAccessKey",
|
||||
"awsSessionToken",
|
||||
"bucket",
|
||||
"object",
|
||||
)
|
||||
if any(
|
||||
not isinstance(credentials.get(name), str) or not credentials[name]
|
||||
for name in required
|
||||
):
|
||||
raise NotarizationError(
|
||||
"Apple returned incomplete temporary upload credentials"
|
||||
)
|
||||
|
||||
size = path.stat().st_size
|
||||
if not 0 < size <= MAX_SINGLE_UPLOAD_BYTES:
|
||||
raise NotarizationError("Notarization payload must be between 1 byte and 5 GiB")
|
||||
|
||||
now = timestamp or datetime.datetime.now(datetime.timezone.utc)
|
||||
amz_date = now.strftime("%Y%m%dT%H%M%SZ")
|
||||
date_stamp = now.strftime("%Y%m%d")
|
||||
host = f"{credentials['bucket']}.s3.{AWS_REGION}.amazonaws.com"
|
||||
object_path = "/" + urllib.parse.quote(
|
||||
credentials["object"].lstrip("/"), safe="/-_.~"
|
||||
)
|
||||
headers = {
|
||||
"content-type": "application/octet-stream",
|
||||
"host": host,
|
||||
"x-amz-content-sha256": file_digest,
|
||||
"x-amz-date": amz_date,
|
||||
"x-amz-security-token": credentials["awsSessionToken"],
|
||||
}
|
||||
# Build the signature required by the upload endpoint.
|
||||
signed_headers = ";".join(sorted(headers))
|
||||
canonical_headers = "".join(f"{name}:{headers[name]}\n" for name in sorted(headers))
|
||||
canonical_request = "\n".join(
|
||||
["PUT", object_path, "", canonical_headers, signed_headers, file_digest]
|
||||
)
|
||||
credential_scope = f"{date_stamp}/{AWS_REGION}/s3/aws4_request"
|
||||
string_to_sign = "\n".join(
|
||||
[
|
||||
"AWS4-HMAC-SHA256",
|
||||
amz_date,
|
||||
credential_scope,
|
||||
hashlib.sha256(canonical_request.encode("utf-8")).hexdigest(),
|
||||
]
|
||||
)
|
||||
signing_key = ("AWS4" + credentials["awsSecretAccessKey"]).encode("utf-8")
|
||||
for component in (date_stamp, AWS_REGION, "s3", "aws4_request"):
|
||||
signing_key = hmac_sha256(signing_key, component)
|
||||
signature = hmac.new(
|
||||
signing_key, string_to_sign.encode("utf-8"), hashlib.sha256
|
||||
).hexdigest()
|
||||
authorization = (
|
||||
"AWS4-HMAC-SHA256 "
|
||||
f"Credential={credentials['awsAccessKeyId']}/{credential_scope}, "
|
||||
f"SignedHeaders={signed_headers}, Signature={signature}"
|
||||
)
|
||||
|
||||
# Stream the artifact to avoid buffering its full contents.
|
||||
with path.open("rb") as source:
|
||||
request = urllib.request.Request(
|
||||
f"https://{host}{object_path}",
|
||||
data=source,
|
||||
method="PUT",
|
||||
headers={
|
||||
**headers,
|
||||
"Authorization": authorization,
|
||||
"Content-Length": str(size),
|
||||
},
|
||||
)
|
||||
try:
|
||||
with urllib.request.urlopen(request, timeout=300):
|
||||
pass
|
||||
except urllib.error.HTTPError as error:
|
||||
raise NotarizationError(
|
||||
f"Apple notarization payload upload failed with HTTP {error.code}"
|
||||
) from error
|
||||
except OSError as error:
|
||||
raise NotarizationError(
|
||||
"Apple notarization payload upload failed"
|
||||
) from error
|
||||
|
||||
|
||||
def write_developer_log(
|
||||
submission_id: str, token: str, destination: Path | None
|
||||
) -> None:
|
||||
"""Write the submission's optional diagnostic report."""
|
||||
|
||||
if destination is None:
|
||||
return
|
||||
response = json_request(f"{APPLE_NOTARY_URL}/{submission_id}/logs", token)
|
||||
try:
|
||||
log_url = response["data"]["attributes"]["developerLogUrl"]
|
||||
except (KeyError, TypeError) as error:
|
||||
raise NotarizationError(
|
||||
"Apple did not provide a notarization developer log"
|
||||
) from error
|
||||
if not isinstance(log_url, str) or not log_url.startswith("https://"):
|
||||
raise NotarizationError(
|
||||
"Apple returned an invalid notarization developer log URL"
|
||||
)
|
||||
try:
|
||||
# Do not forward unrelated authorization headers to the download URL.
|
||||
with urllib.request.urlopen(log_url, timeout=60) as response:
|
||||
destination.write_bytes(response.read())
|
||||
except urllib.error.HTTPError as error:
|
||||
raise NotarizationError(
|
||||
f"Apple notarization developer log download failed with HTTP {error.code}"
|
||||
) from error
|
||||
except OSError as error:
|
||||
raise NotarizationError(
|
||||
"Apple notarization developer log download failed"
|
||||
) from error
|
||||
|
||||
|
||||
def notarize(
|
||||
path: Path,
|
||||
configuration: NotarizationConfiguration,
|
||||
*,
|
||||
max_wait_seconds: int,
|
||||
report_log: Path | None,
|
||||
) -> str:
|
||||
"""Submit an artifact, upload it to Apple, and wait for a terminal result."""
|
||||
|
||||
issued_at = int(time.time())
|
||||
token = create_apple_jwt(configuration, issued_at=issued_at)
|
||||
file_digest = sha256_file(path)
|
||||
# Create the submission before uploading the artifact.
|
||||
response = json_request(
|
||||
APPLE_NOTARY_URL,
|
||||
token,
|
||||
body={"sha256": file_digest, "submissionName": path.name},
|
||||
)
|
||||
try:
|
||||
submission_id = response["data"]["id"]
|
||||
upload_credentials = response["data"]["attributes"]
|
||||
except (KeyError, TypeError) as error:
|
||||
raise NotarizationError(
|
||||
"Apple returned an invalid notarization submission"
|
||||
) from error
|
||||
if not isinstance(submission_id, str) or not submission_id:
|
||||
raise NotarizationError("Apple did not return a notarization submission ID")
|
||||
if not isinstance(upload_credentials, dict):
|
||||
raise NotarizationError(
|
||||
"Apple returned invalid notarization upload credentials"
|
||||
)
|
||||
|
||||
print(f"Uploading notarization submission {submission_id} for {path.name}")
|
||||
upload_to_apple_s3(path, file_digest, upload_credentials)
|
||||
# A monotonic deadline keeps the wait limit stable if the system clock changes.
|
||||
deadline = time.monotonic() + max_wait_seconds
|
||||
|
||||
# Wait for completion, equivalent to `notarytool submit --wait`.
|
||||
while True:
|
||||
# Refresh the token before it expires.
|
||||
if int(time.time()) >= issued_at + JWT_LIFETIME_SECONDS - 60:
|
||||
issued_at = int(time.time())
|
||||
token = create_apple_jwt(configuration, issued_at=issued_at)
|
||||
result = json_request(f"{APPLE_NOTARY_URL}/{submission_id}", token)
|
||||
try:
|
||||
status = result["data"]["attributes"]["status"]
|
||||
except (KeyError, TypeError) as error:
|
||||
raise NotarizationError(
|
||||
"Apple returned an invalid notarization status"
|
||||
) from error
|
||||
|
||||
if status in {"Accepted", "Invalid", "Rejected"}:
|
||||
# Save diagnostics for both accepted and rejected submissions.
|
||||
write_developer_log(submission_id, token, report_log)
|
||||
message = f"Notarization submission {submission_id} completed with status {status}"
|
||||
if status != "Accepted":
|
||||
raise NotarizationError(message)
|
||||
print(message)
|
||||
return submission_id
|
||||
if status != "In Progress":
|
||||
raise NotarizationError(f"Unexpected notarization status: {status!r}")
|
||||
|
||||
remaining = deadline - time.monotonic()
|
||||
if remaining <= 0:
|
||||
raise NotarizationError(
|
||||
f"Notarization submission {submission_id} exceeded {max_wait_seconds} seconds"
|
||||
)
|
||||
print(f"Notarization submission {submission_id} is still in progress")
|
||||
time.sleep(min(POLL_INTERVAL_SECONDS, remaining))
|
||||
|
||||
|
||||
def main() -> int:
|
||||
"""Run notarization using command-line arguments."""
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--file", type=Path, required=True)
|
||||
parser.add_argument("--report-log", type=Path)
|
||||
parser.add_argument("--max-wait-seconds", type=int, default=600)
|
||||
arguments = parser.parse_args()
|
||||
|
||||
try:
|
||||
if not arguments.file.is_file():
|
||||
raise NotarizationError(
|
||||
f"Notarization payload does not exist: {arguments.file}"
|
||||
)
|
||||
if arguments.max_wait_seconds < 0:
|
||||
raise NotarizationError("--max-wait-seconds must be non-negative")
|
||||
if arguments.report_log is not None:
|
||||
arguments.report_log.parent.mkdir(parents=True, exist_ok=True)
|
||||
notarize(
|
||||
arguments.file,
|
||||
NotarizationConfiguration.from_environment(),
|
||||
max_wait_seconds=arguments.max_wait_seconds,
|
||||
report_log=arguments.report_log,
|
||||
)
|
||||
except NotarizationError as error:
|
||||
print(f"Notarization failed: {error}", file=sys.stderr)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
240
.github/scripts/macos-signing/provisioned_macos_cli_package.py
vendored
Normal file
240
.github/scripts/macos-signing/provisioned_macos_cli_package.py
vendored
Normal file
@@ -0,0 +1,240 @@
|
||||
"""Prepare and verify provisioned CLI bundles using an explicitly approved profile."""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import plistlib
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime, timezone
|
||||
from pathlib import Path
|
||||
|
||||
BUNDLE_ID = "com.openai.codex.cli"
|
||||
# Existing login-keychain ACLs identify the CLI by its code-signing identifier.
|
||||
# Keep this stable independently of the bundle and provisioned App ID.
|
||||
CODE_SIGNING_ID = "codex"
|
||||
APP = Path("CodexCLI.app")
|
||||
EXECUTABLE = APP / "Contents/MacOS/codex"
|
||||
SIGNING = Path(__file__).resolve().parent
|
||||
HELPERS = ("bin/codex-code-mode-host", "bin/codex-exec-server", "codex-path/rg")
|
||||
LAUNCHER = """#!/bin/sh
|
||||
set -eu
|
||||
entry="$0"
|
||||
while [ -L "$entry" ]; do
|
||||
parent=$(CDPATH= cd -P -- "$(dirname -- "$entry")" && pwd)
|
||||
entry=$(readlink "$entry")
|
||||
case "$entry" in /*) ;; *) entry="$parent/$entry" ;; esac
|
||||
done
|
||||
bin_dir=$(CDPATH= cd -P -- "$(dirname -- "$entry")" && pwd)
|
||||
exec "$bin_dir/../CodexCLI.app/Contents/MacOS/codex" "$@"
|
||||
"""
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ProfileConfiguration:
|
||||
"""Independent release expectations; never infer these from the signed package."""
|
||||
|
||||
profile: Path
|
||||
profile_sha256: str
|
||||
certificate_sha256: str
|
||||
team_id: str
|
||||
|
||||
def __post_init__(self):
|
||||
for name in ("profile_sha256", "certificate_sha256"):
|
||||
if not re.fullmatch(r"[0-9a-f]{64}", getattr(self, name)):
|
||||
raise ValueError(f"{name} must be a lowercase SHA-256 digest")
|
||||
if not re.fullmatch(r"[A-Z0-9]{10}", self.team_id):
|
||||
raise ValueError("team_id must be a ten-character Apple Team ID")
|
||||
|
||||
def validate_signing_certificate(self, certificate: Path):
|
||||
certificate_der = subprocess.check_output(
|
||||
["openssl", "x509", "-in", str(certificate), "-outform", "DER"]
|
||||
)
|
||||
if hashlib.sha256(certificate_der).hexdigest() != self.certificate_sha256:
|
||||
raise ValueError("AKV signing certificate is not authorized by the profile")
|
||||
|
||||
|
||||
def load_profile(configuration: ProfileConfiguration):
|
||||
# Pin the portal-approved CMS as well as checking its signature. -noverify
|
||||
# skips OpenSSL's non-Apple trust store, not CMS signature verification.
|
||||
if (
|
||||
hashlib.sha256(configuration.profile.read_bytes()).hexdigest()
|
||||
!= configuration.profile_sha256
|
||||
):
|
||||
raise ValueError("Provisioning profile changed; review and update its pin")
|
||||
profile = plistlib.loads(
|
||||
subprocess.check_output(
|
||||
[
|
||||
"openssl",
|
||||
"cms",
|
||||
"-verify",
|
||||
"-inform",
|
||||
"DER",
|
||||
"-noverify",
|
||||
"-in",
|
||||
str(configuration.profile),
|
||||
]
|
||||
)
|
||||
)
|
||||
validate_profile(profile, configuration)
|
||||
return profile
|
||||
|
||||
|
||||
def validate_profile(profile, configuration: ProfileConfiguration):
|
||||
allowed = profile["Entitlements"]
|
||||
if (
|
||||
profile["TeamIdentifier"] != [configuration.team_id]
|
||||
or profile["ApplicationIdentifierPrefix"] != [configuration.team_id]
|
||||
or allowed["com.apple.application-identifier"]
|
||||
!= f"{configuration.team_id}.{BUNDLE_ID}"
|
||||
or allowed["com.apple.developer.team-identifier"] != configuration.team_id
|
||||
or allowed["keychain-access-groups"] != [f"{configuration.team_id}.*"]
|
||||
or allowed.get("get-task-allow", False)
|
||||
or not profile.get("ProvisionsAllDevices")
|
||||
or "ProvisionedDevices" in profile
|
||||
):
|
||||
raise ValueError("Profile does not authorize the CLI Developer ID identity")
|
||||
now = datetime.now(timezone.utc).replace(tzinfo=None)
|
||||
if not profile["CreationDate"] <= now < profile["ExpirationDate"]:
|
||||
raise ValueError("Provisioning profile is not currently valid")
|
||||
if [
|
||||
hashlib.sha256(cert).hexdigest() for cert in profile["DeveloperCertificates"]
|
||||
] != [configuration.certificate_sha256]:
|
||||
raise ValueError("Profile does not authorize the approved signing certificate")
|
||||
|
||||
|
||||
def entitlements(configuration: ProfileConfiguration):
|
||||
base = plistlib.loads((SIGNING / "codex.entitlements.plist").read_bytes())
|
||||
return {
|
||||
**base,
|
||||
"com.apple.application-identifier": f"{configuration.team_id}.{BUNDLE_ID}",
|
||||
"com.apple.developer.team-identifier": configuration.team_id,
|
||||
"keychain-access-groups": [f"{configuration.team_id}.{BUNDLE_ID}"],
|
||||
}
|
||||
|
||||
|
||||
def prepare(package, reports, configuration: ProfileConfiguration):
|
||||
load_profile(configuration)
|
||||
metadata = json.loads((package / "codex-package.json").read_text())
|
||||
if (
|
||||
metadata["variant"] != "codex"
|
||||
or metadata["layoutVersion"] != 1
|
||||
or metadata["target"] not in ("aarch64-apple-darwin", "x86_64-apple-darwin")
|
||||
or metadata["entrypoint"] != "bin/codex"
|
||||
):
|
||||
raise ValueError("Expected a canonical macOS CLI package")
|
||||
for relative in ("bin/codex", *HELPERS):
|
||||
path = package / relative
|
||||
if path.is_symlink() or not path.is_file() or not os.access(path, os.X_OK):
|
||||
raise ValueError(f"Expected a regular executable: {relative}")
|
||||
# Refuse to overwrite a previously prepared or signed bundle.
|
||||
(package / EXECUTABLE).parent.mkdir(parents=True, exist_ok=False)
|
||||
(package / "bin/codex").rename(package / EXECUTABLE)
|
||||
(package / "bin/codex").write_text(LAUNCHER)
|
||||
(package / "bin/codex").chmod(0o755)
|
||||
contents = package / APP / "Contents"
|
||||
shutil.copyfile(configuration.profile, contents / "embedded.provisionprofile")
|
||||
(contents / "Info.plist").write_bytes(
|
||||
plistlib.dumps(
|
||||
{
|
||||
"CFBundleIdentifier": BUNDLE_ID,
|
||||
"CFBundleDisplayName": "ChatGPT",
|
||||
"CFBundleExecutable": "codex",
|
||||
"CFBundleName": "ChatGPT",
|
||||
"CFBundlePackageType": "APPL",
|
||||
"CFBundleVersion": "1",
|
||||
}
|
||||
)
|
||||
)
|
||||
reports.mkdir(parents=True, exist_ok=True)
|
||||
# Keep expected entitlements separate from the shared verifier's extracted
|
||||
# codex-entitlements.plist, otherwise it would overwrite its own expectation.
|
||||
(reports / "codex-provisioned-entitlements.plist").write_bytes(
|
||||
plistlib.dumps(entitlements(configuration))
|
||||
)
|
||||
|
||||
|
||||
def verify(package, reports, expected_target, configuration: ProfileConfiguration):
|
||||
"""Check profile and certificate pins; the signing driver verifies code."""
|
||||
load_profile(configuration)
|
||||
info = plistlib.loads((package / APP / "Contents/Info.plist").read_bytes())
|
||||
if (
|
||||
info.get("CFBundleIdentifier") != BUNDLE_ID
|
||||
or info.get("CFBundleExecutable") != EXECUTABLE.name
|
||||
or info.get("CFBundlePackageType") != "APPL"
|
||||
):
|
||||
raise ValueError("Unexpected provisioned CLI bundle identity or executable")
|
||||
if (
|
||||
package / APP / "Contents/embedded.provisionprofile"
|
||||
).read_bytes() != configuration.profile.read_bytes():
|
||||
raise ValueError("Embedded profile differs from the reviewed profile")
|
||||
if (package / "bin/codex").read_text() != LAUNCHER:
|
||||
raise ValueError("Unexpected CLI launcher")
|
||||
metadata = json.loads((package / "codex-package.json").read_text())
|
||||
if metadata["target"] != expected_target:
|
||||
raise ValueError(
|
||||
"Package target differs from the requested verification target"
|
||||
)
|
||||
reports.mkdir(parents=True, exist_ok=True)
|
||||
(reports / "codex-provisioned-entitlements.plist").write_bytes(
|
||||
plistlib.dumps(entitlements(configuration))
|
||||
)
|
||||
# sign_macos_cli_package.py owns shared architecture, signature and entitlement
|
||||
# checks. Here, require the exact certificate authorized by the profile.
|
||||
for relative in (EXECUTABLE, *(Path(helper) for helper in HELPERS)):
|
||||
binary = package / relative
|
||||
target = package / APP if relative == EXECUTABLE else binary
|
||||
prefix = reports / f"{binary.name}-cert-"
|
||||
subprocess.run(
|
||||
["codesign", "-d", f"--extract-certificates={prefix}", str(target)],
|
||||
check=True,
|
||||
)
|
||||
if (
|
||||
hashlib.sha256(Path(f"{prefix}0").read_bytes()).hexdigest()
|
||||
!= configuration.certificate_sha256
|
||||
):
|
||||
raise ValueError(f"Unexpected signing certificate: {relative}")
|
||||
|
||||
|
||||
def parse_profile_args(parser, configuration: ProfileConfiguration | None):
|
||||
"""Require independent profile expectations unless the caller supplies them."""
|
||||
if configuration is None:
|
||||
parser.add_argument("--profile", type=Path, required=True)
|
||||
parser.add_argument("--profile-sha256", required=True)
|
||||
parser.add_argument("--certificate-sha256", required=True)
|
||||
parser.add_argument("--team-id", required=True)
|
||||
args = parser.parse_args()
|
||||
if configuration is None:
|
||||
configuration = ProfileConfiguration(
|
||||
args.profile, args.profile_sha256, args.certificate_sha256, args.team_id
|
||||
)
|
||||
return args, configuration
|
||||
|
||||
|
||||
def main(configuration: ProfileConfiguration | None = None):
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("operation", choices=("prepare", "verify", "validate-profile"))
|
||||
parser.add_argument("--package", type=Path, default=Path("package"))
|
||||
parser.add_argument("--reports", type=Path, default=Path("provisioned-reports"))
|
||||
parser.add_argument("--certificate", type=Path)
|
||||
parser.add_argument(
|
||||
"--target", choices=("aarch64-apple-darwin", "x86_64-apple-darwin")
|
||||
)
|
||||
args, configuration = parse_profile_args(parser, configuration)
|
||||
if args.certificate:
|
||||
configuration.validate_signing_certificate(args.certificate)
|
||||
if args.operation == "validate-profile":
|
||||
load_profile(configuration)
|
||||
elif args.operation == "prepare":
|
||||
prepare(args.package, args.reports, configuration)
|
||||
else:
|
||||
if not args.target:
|
||||
parser.error("--target is required for verification")
|
||||
verify(args.package, args.reports, args.target, configuration)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
191
.github/scripts/macos-signing/sign_macos_cli_package.py
vendored
Normal file
191
.github/scripts/macos-signing/sign_macos_cli_package.py
vendored
Normal file
@@ -0,0 +1,191 @@
|
||||
"""Sign and verify macOS CLI packages using the shared AKV and native tools."""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import plistlib
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import provisioned_macos_cli_package as bundle
|
||||
|
||||
|
||||
def main(configuration: bundle.ProfileConfiguration | None = None):
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("operation", choices=("sign", "verify"))
|
||||
parser.add_argument("package", type=Path)
|
||||
args, configuration = bundle.parse_profile_args(parser, configuration)
|
||||
package = args.package.resolve(strict=True)
|
||||
if not package.is_dir():
|
||||
parser.error("package must be an extracted CLI package directory")
|
||||
repo_root = os.environ.get("CODEX_REPO_ROOT")
|
||||
if not repo_root:
|
||||
parser.error("CODEX_REPO_ROOT must be set")
|
||||
reports = Path(repo_root) / "signing-verification"
|
||||
reports.mkdir(parents=True, exist_ok=True)
|
||||
provisioned = os.environ.get("PROVISIONED_MACOS", "false") == "true"
|
||||
if provisioned:
|
||||
if args.operation == "sign":
|
||||
configuration.validate_signing_certificate(
|
||||
Path(os.environ["OAI_AKV_SIGNING_CERTIFICATE_PEM"])
|
||||
)
|
||||
bundle.prepare(package, reports, configuration)
|
||||
else:
|
||||
bundle.verify(package, reports, os.environ["TARGET"], configuration)
|
||||
|
||||
for relative in ("bin/codex", *bundle.HELPERS):
|
||||
binary = package / relative
|
||||
name = binary.name
|
||||
target = binary
|
||||
identifier = name
|
||||
entitlements = bundle.SIGNING / f"{name}.entitlements.plist"
|
||||
if provisioned and relative == "bin/codex":
|
||||
binary = package / bundle.EXECUTABLE
|
||||
target = package / bundle.APP
|
||||
identifier = bundle.CODE_SIGNING_ID
|
||||
entitlements = reports / "codex-provisioned-entitlements.plist"
|
||||
if args.operation == "sign":
|
||||
command = [
|
||||
"bash",
|
||||
str(bundle.SIGNING / "sign_macos_code.sh"),
|
||||
"--target",
|
||||
str(target),
|
||||
"--identity",
|
||||
"unused",
|
||||
"--deep",
|
||||
"false",
|
||||
"--options",
|
||||
"runtime",
|
||||
"--timestamp",
|
||||
"true",
|
||||
]
|
||||
if relative.startswith("bin/"):
|
||||
command.extend(
|
||||
["--identifier", identifier, "--entitlements", str(entitlements)]
|
||||
)
|
||||
else:
|
||||
command.extend(["--identifier", f"com.openai.codex.{name}"])
|
||||
subprocess.run(command, check=True)
|
||||
with (reports / f"{name}-signature.yaml").open("wb") as output:
|
||||
subprocess.run(
|
||||
["rcodesign", "print-signature-info", str(binary)],
|
||||
stdout=output,
|
||||
check=True,
|
||||
)
|
||||
if not provisioned:
|
||||
subprocess.run(
|
||||
[
|
||||
"bash",
|
||||
str(bundle.SIGNING / "notarize_macos_binary_with_akv.sh"),
|
||||
"--binary",
|
||||
str(binary),
|
||||
"--report-dir",
|
||||
str(reports / name),
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
else:
|
||||
target_triple = os.environ["TARGET"]
|
||||
architectures = {
|
||||
"aarch64-apple-darwin": "arm64",
|
||||
"x86_64-apple-darwin": "x86_64",
|
||||
}
|
||||
if target_triple not in architectures:
|
||||
raise ValueError(f"Unexpected macOS target: {target_triple}")
|
||||
subprocess.run(
|
||||
["lipo", str(binary), "-verify_arch", architectures[target_triple]],
|
||||
check=True,
|
||||
)
|
||||
# Preserve the CLI's existing login-keychain identity while checking
|
||||
# its bundle/App ID and provisioning independently in bundle.verify.
|
||||
requirement = (
|
||||
"=anchor apple generic"
|
||||
" and certificate 1[field.1.2.840.113635.100.6.2.6] exists"
|
||||
" and certificate leaf[field.1.2.840.113635.100.6.1.13] exists"
|
||||
)
|
||||
if provisioned and relative == "bin/codex":
|
||||
requirement += (
|
||||
f' and identifier "{bundle.CODE_SIGNING_ID}"'
|
||||
f' and certificate leaf[subject.OU] = "{configuration.team_id}"'
|
||||
)
|
||||
subprocess.run(
|
||||
[
|
||||
"codesign",
|
||||
"--verify",
|
||||
"--strict",
|
||||
"--verbose=2",
|
||||
"--test-requirement",
|
||||
requirement,
|
||||
str(target),
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
signature = reports / f"{name}-signature.txt"
|
||||
with signature.open("wb") as output:
|
||||
subprocess.run(
|
||||
["codesign", "-d", "--verbose=4", str(target)],
|
||||
stderr=output,
|
||||
check=True,
|
||||
)
|
||||
actual = reports / f"{name}-entitlements.plist"
|
||||
with actual.open("wb") as output:
|
||||
subprocess.run(
|
||||
["codesign", "-d", "--entitlements", ":-", str(target)],
|
||||
stdout=output,
|
||||
check=True,
|
||||
)
|
||||
if relative.startswith("bin/"):
|
||||
# Signing tools may omit the blob when no entitlements are requested.
|
||||
if (
|
||||
actual.stat().st_size == 0
|
||||
and plistlib.loads(entitlements.read_bytes()) == {}
|
||||
):
|
||||
actual.write_bytes(entitlements.read_bytes())
|
||||
expected = reports / f"{name}-expected.plist"
|
||||
subprocess.run(
|
||||
[
|
||||
"plutil",
|
||||
"-convert",
|
||||
"xml1",
|
||||
"-o",
|
||||
str(expected),
|
||||
str(entitlements),
|
||||
],
|
||||
check=True,
|
||||
)
|
||||
subprocess.run(["plutil", "-convert", "xml1", str(actual)], check=True)
|
||||
subprocess.run(["diff", "-u", str(expected), str(actual)], check=True)
|
||||
elif actual.stat().st_size:
|
||||
raise ValueError(
|
||||
f"Bundled helper {name} must not have signing entitlements"
|
||||
)
|
||||
|
||||
if provisioned and args.operation == "sign":
|
||||
archive = Path(os.environ["RUNNER_TEMP"]) / "provisioned-cli.zip"
|
||||
subprocess.run(["zip", "-q", "-r", str(archive), "."], cwd=package, check=True)
|
||||
command = [
|
||||
sys.executable,
|
||||
str(bundle.SIGNING / "notarize_with_akv.py"),
|
||||
"--file",
|
||||
str(archive),
|
||||
"--report-log",
|
||||
str(reports / "notarization-developer-log.json"),
|
||||
"--max-wait-seconds",
|
||||
"1200",
|
||||
]
|
||||
with (
|
||||
(reports / "notarization.log").open("w") as output,
|
||||
subprocess.Popen(
|
||||
command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True
|
||||
) as process,
|
||||
):
|
||||
assert process.stdout is not None
|
||||
for line in process.stdout:
|
||||
print(line, end="", flush=True)
|
||||
output.write(line)
|
||||
if returncode := process.wait():
|
||||
raise subprocess.CalledProcessError(returncode, command)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
248
.github/scripts/macos-signing/sign_macos_code.sh
vendored
Executable file
248
.github/scripts/macos-signing/sign_macos_code.sh
vendored
Executable file
@@ -0,0 +1,248 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Small compatibility wrapper around native codesign and rcodesign.
|
||||
#
|
||||
# Existing packaging scripts call this instead of choosing a signing backend
|
||||
# directly. OAI_CODESIGN_BACKEND=akv-pkcs11 routes signing through rcodesign
|
||||
# while preserving the option, entitlement, identifier, timestamp, and deep
|
||||
# signing surface used by the native codesign path.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
usage() {
|
||||
cat >&2 <<'EOF'
|
||||
Usage: sign_macos_code.sh --target PATH --identity IDENTITY [options]
|
||||
|
||||
Options:
|
||||
--deep true|false
|
||||
--entitlements PATH
|
||||
--identifier IDENTIFIER
|
||||
--identity IDENTITY
|
||||
--options FLAGS
|
||||
--target PATH
|
||||
--timestamp true|false|none
|
||||
EOF
|
||||
}
|
||||
|
||||
target=""
|
||||
identity=""
|
||||
options=""
|
||||
entitlements_file=""
|
||||
identifier=""
|
||||
deep="false"
|
||||
timestamp="true"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--deep)
|
||||
deep="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--entitlements)
|
||||
entitlements_file="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--identifier)
|
||||
identifier="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--identity)
|
||||
identity="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--options)
|
||||
options="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--target)
|
||||
target="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--timestamp)
|
||||
timestamp="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown signing argument: $1" >&2
|
||||
usage
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$target" ]]; then
|
||||
echo "--target is required." >&2
|
||||
usage
|
||||
exit 2
|
||||
fi
|
||||
|
||||
if [[ ! -e "$target" ]]; then
|
||||
echo "Signing target does not exist: $target" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$deep" in
|
||||
true|false) ;;
|
||||
*)
|
||||
echo "--deep must be true or false, got '$deep'." >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$timestamp" in
|
||||
true|false|none) ;;
|
||||
*)
|
||||
echo "--timestamp must be true, false, or none, got '$timestamp'." >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
|
||||
sign_with_codesign() {
|
||||
if [[ -z "$identity" ]]; then
|
||||
echo "Native codesign requires --identity." >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
local -a args
|
||||
args=(--force)
|
||||
|
||||
if [[ "$deep" == "true" ]]; then
|
||||
args+=(--deep)
|
||||
fi
|
||||
|
||||
if [[ -n "$options" ]]; then
|
||||
args+=(--options "$options")
|
||||
fi
|
||||
|
||||
case "$timestamp" in
|
||||
true)
|
||||
args+=(--timestamp)
|
||||
;;
|
||||
false|none)
|
||||
args+=(--timestamp=none)
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ -n "$entitlements_file" ]]; then
|
||||
args+=(--entitlements "$entitlements_file")
|
||||
fi
|
||||
|
||||
if [[ -n "$identifier" ]]; then
|
||||
args+=(--identifier "$identifier")
|
||||
fi
|
||||
|
||||
args+=(--sign "$identity" "$target")
|
||||
codesign "${args[@]}"
|
||||
}
|
||||
|
||||
append_rcodesign_flags() {
|
||||
local raw_options="$1"
|
||||
local option=""
|
||||
|
||||
if [[ -z "$raw_options" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
IFS=',' read -ra split_options <<< "$raw_options"
|
||||
for option in "${split_options[@]}"; do
|
||||
option="${option//[[:space:]]/}"
|
||||
[[ -z "$option" ]] && continue
|
||||
|
||||
case "$option" in
|
||||
host|hard|kill|expires|restrict|library|runtime|linker-signed)
|
||||
rcodesign_args+=(--code-signature-flags "$option")
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported rcodesign code signature option: $option" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
rcodesign_options_require_notarization() {
|
||||
local raw_options="$1"
|
||||
local option=""
|
||||
|
||||
if [[ -z "$raw_options" || "$timestamp" != "true" ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
IFS=',' read -ra split_options <<< "$raw_options"
|
||||
for option in "${split_options[@]}"; do
|
||||
option="${option//[[:space:]]/}"
|
||||
if [[ "$option" == "runtime" ]]; then
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
sign_with_rcodesign() {
|
||||
: "${OAI_AKV_PKCS11_LIBRARY:?OAI_AKV_PKCS11_LIBRARY is required for AKV PKCS11 signing.}"
|
||||
: "${OAI_AKV_SIGNING_CERTIFICATE_PEM:?OAI_AKV_SIGNING_CERTIFICATE_PEM is required for AKV PKCS11 signing.}"
|
||||
: "${OAI_AKV_KEY_LABEL:?OAI_AKV_KEY_LABEL is required for AKV PKCS11 signing.}"
|
||||
|
||||
if ! command -v rcodesign >/dev/null 2>&1; then
|
||||
echo "rcodesign was not found on PATH." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
local -a rcodesign_args
|
||||
rcodesign_args=(
|
||||
sign
|
||||
--config-file /dev/null
|
||||
--pkcs11-library "$OAI_AKV_PKCS11_LIBRARY"
|
||||
--pkcs11-certificate-file "$OAI_AKV_SIGNING_CERTIFICATE_PEM"
|
||||
--pkcs11-key-label "$OAI_AKV_KEY_LABEL"
|
||||
)
|
||||
|
||||
if [[ "${OAI_RCODESIGN_ARM64_16K_CODE_PAGES:-false}" == "true" ]]; then
|
||||
rcodesign_args+=(--arm64-16k-code-pages)
|
||||
fi
|
||||
|
||||
if [[ "$deep" == "false" ]]; then
|
||||
rcodesign_args+=(--shallow)
|
||||
fi
|
||||
|
||||
case "$timestamp" in
|
||||
true)
|
||||
;;
|
||||
false|none)
|
||||
rcodesign_args+=(--timestamp-url none)
|
||||
;;
|
||||
esac
|
||||
|
||||
append_rcodesign_flags "$options"
|
||||
if rcodesign_options_require_notarization "$options"; then
|
||||
rcodesign_args+=(--for-notarization)
|
||||
fi
|
||||
|
||||
if [[ -n "$entitlements_file" ]]; then
|
||||
rcodesign_args+=(--entitlements-xml-file "$entitlements_file")
|
||||
fi
|
||||
|
||||
if [[ -n "$identifier" ]]; then
|
||||
rcodesign_args+=(--binary-identifier "$identifier")
|
||||
fi
|
||||
|
||||
rcodesign "${rcodesign_args[@]}" "$target"
|
||||
}
|
||||
|
||||
case "${OAI_CODESIGN_BACKEND:-codesign}" in
|
||||
codesign|"")
|
||||
sign_with_codesign
|
||||
;;
|
||||
akv-pkcs11)
|
||||
sign_with_rcodesign
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported OAI_CODESIGN_BACKEND: ${OAI_CODESIGN_BACKEND}" >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
257
.github/scripts/macos-signing/test_notarize_with_akv.py
vendored
Normal file
257
.github/scripts/macos-signing/test_notarize_with_akv.py
vendored
Normal file
@@ -0,0 +1,257 @@
|
||||
import contextlib
|
||||
import hashlib
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
SIGNING_DIRECTORY = Path(__file__).resolve().parent
|
||||
sys.path.insert(0, str(SIGNING_DIRECTORY))
|
||||
import notarize_with_akv as notary # noqa: E402
|
||||
|
||||
CONFIGURATION = notary.NotarizationConfiguration(
|
||||
"01234567-89ab-cdef-0123-456789abcdef",
|
||||
"APPLEKEY01",
|
||||
"notary-vault",
|
||||
"example-signing-key",
|
||||
"0123456789abcdef" * 2,
|
||||
)
|
||||
ENVIRONMENT = {
|
||||
"AZURE_KEYVAULT_NAME": CONFIGURATION.vault_name,
|
||||
"APPLE_NOTARIZATION_AKV_KEY_NAME": CONFIGURATION.vault_key_name,
|
||||
}
|
||||
CREDENTIALS = {
|
||||
"awsAccessKeyId": "temporary-access-key",
|
||||
"awsSecretAccessKey": "temporary-secret-key",
|
||||
"awsSessionToken": "temporary-session-token",
|
||||
"bucket": "apple-notary-bucket",
|
||||
"object": "uploads/release artifact.dmg",
|
||||
}
|
||||
|
||||
|
||||
def response(payload):
|
||||
return io.BytesIO(
|
||||
json.dumps(payload).encode() if isinstance(payload, dict) else payload
|
||||
)
|
||||
|
||||
|
||||
def azure_response(payload):
|
||||
return subprocess.CompletedProcess([], 0, stdout=json.dumps(payload), stderr="")
|
||||
|
||||
|
||||
class NotarizationTest(unittest.TestCase):
|
||||
def test_validates_the_apple_key_tags_and_pins_its_version(self) -> None:
|
||||
metadata = {
|
||||
"id": CONFIGURATION.versioned_key_id,
|
||||
"apple_key_id": "APPLEKEY01",
|
||||
"apple_issuer_id": CONFIGURATION.issuer_id,
|
||||
}
|
||||
with (
|
||||
patch.dict(os.environ, ENVIRONMENT, clear=True),
|
||||
patch.object(
|
||||
notary.subprocess,
|
||||
"run",
|
||||
return_value=azure_response(metadata),
|
||||
) as show,
|
||||
):
|
||||
self.assertEqual(
|
||||
notary.NotarizationConfiguration.from_environment(),
|
||||
CONFIGURATION,
|
||||
)
|
||||
show.return_value = azure_response({**metadata, "apple_key_id": None})
|
||||
with self.assertRaisesRegex(notary.NotarizationError, "apple-key-id tag"):
|
||||
notary.NotarizationConfiguration.from_environment()
|
||||
for issuer_id in (None, "", " "):
|
||||
with self.subTest(issuer_id=issuer_id):
|
||||
show.return_value = azure_response(
|
||||
{**metadata, "apple_issuer_id": issuer_id}
|
||||
)
|
||||
with self.assertRaisesRegex(
|
||||
notary.NotarizationError, "apple-issuer-id tag"
|
||||
):
|
||||
notary.NotarizationConfiguration.from_environment()
|
||||
show.return_value = azure_response(
|
||||
{**metadata, "apple_issuer_id": "invalid-issuer"}
|
||||
)
|
||||
with self.assertRaisesRegex(notary.NotarizationError, "valid UUID"):
|
||||
notary.NotarizationConfiguration.from_environment()
|
||||
self.assertIn(
|
||||
'{id:key.kid,apple_key_id:tags."apple-key-id",'
|
||||
'apple_issuer_id:tags."apple-issuer-id"}',
|
||||
show.call_args.args[0],
|
||||
)
|
||||
|
||||
invalid_environment = {
|
||||
**ENVIRONMENT,
|
||||
"APPLE_NOTARIZATION_AKV_KEY_NAME": "../bad",
|
||||
}
|
||||
with (
|
||||
patch.dict(os.environ, invalid_environment, clear=True),
|
||||
self.assertRaisesRegex(notary.NotarizationError, "key name"),
|
||||
):
|
||||
notary.NotarizationConfiguration.from_environment()
|
||||
|
||||
def test_signs_the_notary_scoped_digest_with_the_pinned_key(self) -> None:
|
||||
signature = bytes(range(64))
|
||||
payload = {
|
||||
"kid": CONFIGURATION.versioned_key_id,
|
||||
"value": notary.base64url_encode(signature),
|
||||
}
|
||||
with patch.object(
|
||||
notary.subprocess, "run", return_value=azure_response(payload)
|
||||
) as sign:
|
||||
token = notary.create_apple_jwt(CONFIGURATION, issued_at=1_780_000_000)
|
||||
header, claims, encoded_signature = token.split(".")
|
||||
self.assertEqual(
|
||||
json.loads(notary.base64url_decode(header))["kid"], "APPLEKEY01"
|
||||
)
|
||||
self.assertEqual(
|
||||
json.loads(notary.base64url_decode(claims))["iss"], CONFIGURATION.issuer_id
|
||||
)
|
||||
self.assertEqual(
|
||||
json.loads(notary.base64url_decode(claims))["scope"],
|
||||
["/notary/v2"],
|
||||
)
|
||||
self.assertEqual(notary.base64url_decode(encoded_signature), signature)
|
||||
command = sign.call_args.args[0]
|
||||
body = json.loads(command[command.index("--body") + 1])
|
||||
self.assertEqual(body["alg"], "ES256")
|
||||
self.assertEqual(
|
||||
notary.base64url_decode(body["value"]),
|
||||
hashlib.sha256(f"{header}.{claims}".encode()).digest(),
|
||||
)
|
||||
|
||||
def test_rejects_wrong_key_versions_and_invalid_signatures(self) -> None:
|
||||
cases = (
|
||||
(
|
||||
CONFIGURATION.versioned_key_id + "wrong",
|
||||
bytes(64),
|
||||
"unexpected key version",
|
||||
),
|
||||
(CONFIGURATION.versioned_key_id, b"short", "64 JOSE"),
|
||||
)
|
||||
for key_id, signature, message in cases:
|
||||
payload = {"kid": key_id, "value": notary.base64url_encode(signature)}
|
||||
with (
|
||||
self.subTest(message=message),
|
||||
patch.object(
|
||||
notary.subprocess,
|
||||
"run",
|
||||
return_value=azure_response(payload),
|
||||
),
|
||||
self.assertRaisesRegex(notary.NotarizationError, message),
|
||||
):
|
||||
notary.create_apple_jwt(CONFIGURATION, issued_at=1)
|
||||
|
||||
def test_uploads_polls_and_retains_sanitized_apple_diagnostics(self) -> None:
|
||||
signature = azure_response(
|
||||
{
|
||||
"kid": CONFIGURATION.versioned_key_id,
|
||||
"value": notary.base64url_encode(bytes(64)),
|
||||
}
|
||||
)
|
||||
responses = [
|
||||
response({"data": {"id": "submission-1", "attributes": CREDENTIALS}}),
|
||||
response(b""),
|
||||
response({"data": {"attributes": {"status": "In Progress"}}}),
|
||||
response({"data": {"attributes": {"status": "Accepted"}}}),
|
||||
response(
|
||||
{
|
||||
"data": {
|
||||
"attributes": {
|
||||
"developerLogUrl": "https://logs.example.com/log"
|
||||
}
|
||||
}
|
||||
}
|
||||
),
|
||||
response(b'{"status":"Accepted"}'),
|
||||
]
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
artifact, log = (
|
||||
Path(directory) / "codex.zip",
|
||||
Path(directory) / "notary-log.json",
|
||||
)
|
||||
artifact.write_bytes(b"signed release binary")
|
||||
output = io.StringIO()
|
||||
with (
|
||||
patch.object(notary.subprocess, "run", return_value=signature),
|
||||
patch.object(
|
||||
notary.urllib.request, "urlopen", side_effect=responses
|
||||
) as requests,
|
||||
patch.object(notary.time, "sleep") as sleep,
|
||||
contextlib.redirect_stdout(output),
|
||||
):
|
||||
submission = notary.notarize(
|
||||
artifact, CONFIGURATION, max_wait_seconds=600, report_log=log
|
||||
)
|
||||
self.assertEqual(submission, "submission-1")
|
||||
self.assertEqual(json.loads(log.read_text()), {"status": "Accepted"})
|
||||
sleep.assert_called_once_with(10)
|
||||
upload = requests.call_args_list[1].args[0]
|
||||
self.assertEqual(upload.get_method(), "PUT")
|
||||
self.assertNotIn("temporary-secret-key", upload.get_header("Authorization"))
|
||||
self.assertNotIn("temporary-secret-key", output.getvalue())
|
||||
|
||||
|
||||
class NotarizationWrapperTest(unittest.TestCase):
|
||||
def test_binary_and_dmg_wrappers_preserve_notarization_contracts(
|
||||
self,
|
||||
) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root, tools = Path(directory), Path(directory) / "tools"
|
||||
tools.mkdir()
|
||||
call_log = root / "calls.txt"
|
||||
environment = {
|
||||
**os.environ,
|
||||
**ENVIRONMENT,
|
||||
"PATH": f"{tools}:{os.environ['PATH']}",
|
||||
"RUNNER_TEMP": str(root),
|
||||
"CALL_LOG": str(call_log),
|
||||
}
|
||||
for name in ("az", "python3", "rcodesign"):
|
||||
body = (
|
||||
"exit 0"
|
||||
if name == "az"
|
||||
else f'printf "{name} %s\\n" "$*" >> "$CALL_LOG"'
|
||||
)
|
||||
executable = tools / name
|
||||
executable.write_text(
|
||||
f"#!/usr/bin/env bash\nset -euo pipefail\n{body}\n"
|
||||
)
|
||||
executable.chmod(0o755)
|
||||
for kind in ("binary", "dmg"):
|
||||
with self.subTest(kind=kind):
|
||||
artifact = root / ("codex.dmg" if kind == "dmg" else "codex")
|
||||
artifact.write_bytes(b"signed release artifact")
|
||||
subprocess.run(
|
||||
[
|
||||
str(
|
||||
SIGNING_DIRECTORY / f"notarize_macos_{kind}_with_akv.sh"
|
||||
),
|
||||
f"--{kind}",
|
||||
str(artifact),
|
||||
"--report-dir",
|
||||
str(root / "report"),
|
||||
],
|
||||
env=environment,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
calls = call_log.read_text().splitlines()
|
||||
self.assertIn("notarize_with_akv.py --file", calls[0])
|
||||
if kind == "dmg":
|
||||
self.assertEqual(calls[1], f"rcodesign staple {artifact}")
|
||||
else:
|
||||
self.assertEqual(len(calls), 1)
|
||||
self.assertEqual(list(root.rglob("*.p8")), [])
|
||||
call_log.unlink()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
217
.github/scripts/macos-signing/test_provisioned_macos_cli_package.py
vendored
Normal file
217
.github/scripts/macos-signing/test_provisioned_macos_cli_package.py
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
"""Exercise profile validation, relocation and signing without release credentials."""
|
||||
|
||||
import copy
|
||||
import hashlib
|
||||
import json
|
||||
import plistlib
|
||||
import shutil
|
||||
import ssl
|
||||
import subprocess
|
||||
import tarfile
|
||||
import tempfile
|
||||
import unittest
|
||||
from dataclasses import replace
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from pathlib import Path
|
||||
|
||||
import provisioned_macos_cli_package as bundle
|
||||
|
||||
|
||||
class ProvisioningTestCase(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
directory = tempfile.TemporaryDirectory()
|
||||
cls.addClassCleanup(directory.cleanup)
|
||||
root = Path(directory.name)
|
||||
key = root / "test-key.pem"
|
||||
certificate = root / "test-certificate.pem"
|
||||
subprocess.run(
|
||||
[
|
||||
"openssl",
|
||||
"req",
|
||||
"-x509",
|
||||
"-newkey",
|
||||
"rsa:2048",
|
||||
"-nodes",
|
||||
"-keyout",
|
||||
str(key),
|
||||
"-out",
|
||||
str(certificate),
|
||||
"-days",
|
||||
"1",
|
||||
"-subj",
|
||||
"/CN=CLI provisioning test/OU=TESTTEAM01",
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
cert_der = ssl.PEM_cert_to_DER_cert(certificate.read_text())
|
||||
now = datetime.now(timezone.utc).replace(tzinfo=None, microsecond=0)
|
||||
cls.profile = {
|
||||
"TeamIdentifier": ["TESTTEAM01"],
|
||||
"ApplicationIdentifierPrefix": ["TESTTEAM01"],
|
||||
"Entitlements": {
|
||||
"com.apple.application-identifier": "TESTTEAM01.com.openai.codex.cli",
|
||||
"com.apple.developer.team-identifier": "TESTTEAM01",
|
||||
"keychain-access-groups": ["TESTTEAM01.*"],
|
||||
},
|
||||
"CreationDate": now - timedelta(days=1),
|
||||
"ExpirationDate": now + timedelta(days=1),
|
||||
"ProvisionsAllDevices": True,
|
||||
"DeveloperCertificates": [cert_der],
|
||||
}
|
||||
payload = root / "profile.plist"
|
||||
payload.write_bytes(plistlib.dumps(cls.profile))
|
||||
profile_path = root / "test.provisionprofile"
|
||||
subprocess.run(
|
||||
[
|
||||
"openssl",
|
||||
"cms",
|
||||
"-sign",
|
||||
"-binary",
|
||||
"-nodetach",
|
||||
"-outform",
|
||||
"DER",
|
||||
"-in",
|
||||
str(payload),
|
||||
"-signer",
|
||||
str(certificate),
|
||||
"-inkey",
|
||||
str(key),
|
||||
"-out",
|
||||
str(profile_path),
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
)
|
||||
cls.configuration = bundle.ProfileConfiguration(
|
||||
profile=profile_path,
|
||||
profile_sha256=hashlib.sha256(profile_path.read_bytes()).hexdigest(),
|
||||
certificate_sha256=hashlib.sha256(cert_der).hexdigest(),
|
||||
team_id="TESTTEAM01",
|
||||
)
|
||||
|
||||
|
||||
class ProvisionedCliTests(ProvisioningTestCase):
|
||||
def test_profile_configuration_fails_closed(self):
|
||||
self.assertEqual(bundle.load_profile(self.configuration), self.profile)
|
||||
for changes in (
|
||||
{"profile_sha256": "0" * 64},
|
||||
{"certificate_sha256": "0" * 64},
|
||||
{"team_id": "OTHERTEAM1"},
|
||||
{"profile_sha256": ""},
|
||||
{"certificate_sha256": ""},
|
||||
{"team_id": ""},
|
||||
):
|
||||
with self.subTest(changes=changes), self.assertRaises(ValueError):
|
||||
bundle.load_profile(replace(self.configuration, **changes))
|
||||
|
||||
def test_rejects_profile_with_wrong_identity_certificate_or_validity(self):
|
||||
for field, value in (
|
||||
("TeamIdentifier", ["OTHERTEAM"]),
|
||||
("DeveloperCertificates", [b"another certificate"]),
|
||||
(
|
||||
"ExpirationDate",
|
||||
datetime(2000, 1, 1, tzinfo=timezone.utc).replace(tzinfo=None),
|
||||
),
|
||||
(
|
||||
"CreationDate",
|
||||
datetime(2099, 1, 1, tzinfo=timezone.utc).replace(tzinfo=None),
|
||||
),
|
||||
("ProvisionsAllDevices", False),
|
||||
("ProvisionedDevices", ["device"]),
|
||||
):
|
||||
with self.subTest(field=field):
|
||||
profile = copy.deepcopy(self.profile)
|
||||
profile[field] = value
|
||||
with self.assertRaises(ValueError):
|
||||
bundle.validate_profile(profile, self.configuration)
|
||||
for field, value in (
|
||||
(
|
||||
"com.apple.application-identifier",
|
||||
f"{self.configuration.team_id}.another.app",
|
||||
),
|
||||
("keychain-access-groups", [f"{self.configuration.team_id}.another.app"]),
|
||||
("get-task-allow", True),
|
||||
):
|
||||
with self.subTest(field=field):
|
||||
profile = copy.deepcopy(self.profile)
|
||||
profile["Entitlements"][field] = value
|
||||
with self.assertRaises(ValueError):
|
||||
bundle.validate_profile(profile, self.configuration)
|
||||
|
||||
def test_archive_relocation_copy_and_symlink_preserve_launcher(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
package = root / "original package"
|
||||
metadata = {
|
||||
"variant": "codex",
|
||||
"layoutVersion": 1,
|
||||
"target": "aarch64-apple-darwin",
|
||||
"entrypoint": "bin/codex",
|
||||
}
|
||||
for relative in ("bin/codex", *bundle.HELPERS):
|
||||
path = package / relative
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text('#!/bin/sh\nprintf "%s\\n" "$@"\nexit 23\n')
|
||||
path.chmod(0o755)
|
||||
(package / "codex-package.json").write_text(json.dumps(metadata))
|
||||
original_binary = (package / "bin/codex").read_bytes()
|
||||
bundle.prepare(package, root / "reports", self.configuration)
|
||||
with self.assertRaises(FileExistsError):
|
||||
bundle.prepare(package, root / "reports", self.configuration)
|
||||
with self.assertRaisesRegex(ValueError, "Package target differs"):
|
||||
bundle.verify(
|
||||
package, root / "reports", "x86_64-apple-darwin", self.configuration
|
||||
)
|
||||
self.assertEqual(
|
||||
(package / bundle.EXECUTABLE).read_bytes(), original_binary
|
||||
)
|
||||
self.assertEqual(
|
||||
json.loads((package / "codex-package.json").read_text()), metadata
|
||||
)
|
||||
|
||||
archive_path = root / "package.tar.gz"
|
||||
with tarfile.open(archive_path, "w:gz") as archive:
|
||||
archive.add(package, arcname=".")
|
||||
relocated = root / "relocated package"
|
||||
with tarfile.open(archive_path) as archive:
|
||||
archive.extractall(relocated, filter="data")
|
||||
shutil.rmtree(package)
|
||||
# npm currently dereferences symlinks when copying packages. The
|
||||
# launcher remains a script and the provisioned executable stays put.
|
||||
copied = root / "copied package"
|
||||
shutil.copytree(relocated, copied)
|
||||
link = root / "installed codex"
|
||||
link.symlink_to(Path("copied package/bin/codex"))
|
||||
absolute_link = root / "absolute codex"
|
||||
absolute_link.symlink_to(link)
|
||||
for entry in (
|
||||
relocated / "bin/codex",
|
||||
copied / "bin/codex",
|
||||
link,
|
||||
absolute_link,
|
||||
):
|
||||
with self.subTest(entry=entry):
|
||||
result = subprocess.run(
|
||||
[str(entry), "space argument", "*", "--flag"],
|
||||
cwd="/",
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
self.assertEqual(
|
||||
(result.returncode, result.stdout, result.stderr),
|
||||
(23, "space argument\n*\n--flag\n", ""),
|
||||
)
|
||||
(copied / bundle.APP / "Contents/embedded.provisionprofile").write_bytes(
|
||||
b"tampered"
|
||||
)
|
||||
with self.assertRaisesRegex(ValueError, "Embedded profile differs"):
|
||||
bundle.verify(
|
||||
copied, root / "reports", "aarch64-apple-darwin", self.configuration
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
377
.github/scripts/macos-signing/test_sign_macos_cli_package.py
vendored
Normal file
377
.github/scripts/macos-signing/test_sign_macos_cli_package.py
vendored
Normal file
@@ -0,0 +1,377 @@
|
||||
"""Exercise signing orchestration with generated credentials and stubbed native tools."""
|
||||
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
import plistlib
|
||||
import shutil
|
||||
import ssl
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
import zipfile
|
||||
from pathlib import Path
|
||||
|
||||
import provisioned_macos_cli_package as bundle
|
||||
from test_provisioned_macos_cli_package import ProvisioningTestCase
|
||||
|
||||
NATIVE_TOOL = """#!/usr/bin/env python3
|
||||
import json, os, plistlib, sys
|
||||
from pathlib import Path
|
||||
name = Path(sys.argv[0]).name
|
||||
args = sys.argv[1:]
|
||||
with open(os.environ["CALL_LOG"], "a") as log:
|
||||
log.write(json.dumps([name, *args]) + "\\n")
|
||||
if name == "codesign":
|
||||
for arg in args:
|
||||
if arg.startswith("--extract-certificates="):
|
||||
Path(arg.split("=", 1)[1] + "0").write_bytes(Path(os.environ["MOCK_CERTIFICATE"]).read_bytes())
|
||||
if "--test-requirement" in args and os.environ.get("MOCK_WRONG_SIGNING_IDENTITY"):
|
||||
print("code failed to satisfy specified code requirement(s)", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
if "--entitlements" in args:
|
||||
target = Path(args[-1]).name
|
||||
if target == "CodexCLI.app":
|
||||
source = Path(os.environ["CODEX_REPO_ROOT"]) / "signing-verification/codex-provisioned-entitlements.plist"
|
||||
elif target in ("codex", "codex-code-mode-host", "codex-exec-server"):
|
||||
source = Path(os.environ["MOCK_SIGNING_SCRIPTS"]) / (target + ".entitlements.plist")
|
||||
else:
|
||||
sys.exit(0)
|
||||
if target == "codex-exec-server" and os.environ.get("MOCK_EXECUTOR_ENTITLEMENTS"):
|
||||
sys.stdout.buffer.write(plistlib.dumps({"unexpected": True}))
|
||||
sys.exit(0)
|
||||
if not plistlib.loads(source.read_bytes()) and os.environ.get("MOCK_OMIT_EMPTY_ENTITLEMENTS"):
|
||||
sys.exit(0)
|
||||
if os.environ.get("MOCK_WRONG_ENTITLEMENTS"):
|
||||
sys.stdout.buffer.write(plistlib.dumps({"unexpected": True}))
|
||||
else:
|
||||
sys.stdout.buffer.write(source.read_bytes())
|
||||
elif name == "plutil":
|
||||
source = Path(args[-1])
|
||||
target = Path(args[args.index("-o") + 1]) if "-o" in args else source
|
||||
target.write_bytes(plistlib.dumps(plistlib.loads(source.read_bytes())))
|
||||
"""
|
||||
|
||||
|
||||
class MacosSigningTests(ProvisioningTestCase):
|
||||
def fixture(self, root, provisioned, target="aarch64-apple-darwin"):
|
||||
source = Path(bundle.__file__).parent
|
||||
common = Path(os.path.commonpath((source, bundle.SIGNING)))
|
||||
helpers = root / source.relative_to(common)
|
||||
scripts = root / bundle.SIGNING.relative_to(common)
|
||||
helpers.mkdir(parents=True, exist_ok=True)
|
||||
scripts.mkdir(parents=True, exist_ok=True)
|
||||
for name in ("provisioned_macos_cli_package.py", "sign_macos_cli_package.py"):
|
||||
shutil.copyfile(source / name, helpers / name)
|
||||
for path in bundle.SIGNING.glob("*.entitlements.plist"):
|
||||
shutil.copyfile(path, scripts / path.name)
|
||||
(root / "record.py").write_text(
|
||||
"import json, os, sys\n"
|
||||
"with open(os.environ['CALL_LOG'], 'a') as log:\n"
|
||||
" log.write(json.dumps(sys.argv[1:]) + '\\n')\n"
|
||||
"if os.environ.get('FAIL_TOOL') == sys.argv[1]:\n"
|
||||
" print('fixture stdout', flush=True)\n"
|
||||
" print('fixture stderr', file=sys.stderr, flush=True)\n"
|
||||
" sys.exit(17)\n"
|
||||
)
|
||||
for name in ("sign_macos_code.sh", "notarize_macos_binary_with_akv.sh"):
|
||||
(scripts / name).write_text(
|
||||
'python3 "$CODEX_REPO_ROOT/record.py" "$(basename "$0")" "$@"\n'
|
||||
)
|
||||
(scripts / "notarize_with_akv.py").write_text(
|
||||
"import os, runpy, sys\n"
|
||||
"sys.argv.insert(1, 'notarize_with_akv.py')\n"
|
||||
"runpy.run_path(os.environ['CODEX_REPO_ROOT'] + '/record.py')\n"
|
||||
)
|
||||
for name in ("rcodesign", "codesign", "lipo", "plutil"):
|
||||
path = root / name
|
||||
path.write_text(NATIVE_TOOL)
|
||||
path.chmod(0o755)
|
||||
certificate_der = self.profile["DeveloperCertificates"][0]
|
||||
certificate = root / "certificate.pem"
|
||||
certificate.write_text(ssl.DER_cert_to_PEM_cert(certificate_der))
|
||||
(root / "certificate.der").write_bytes(certificate_der)
|
||||
package = root / "package with spaces"
|
||||
for relative in ("bin/codex", *bundle.HELPERS):
|
||||
path = package / relative
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
path.write_text("#!/bin/sh\nexit 0\n")
|
||||
path.chmod(0o755)
|
||||
(package / "codex-package.json").write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"variant": "codex",
|
||||
"layoutVersion": 1,
|
||||
"target": target,
|
||||
"entrypoint": "bin/codex",
|
||||
}
|
||||
)
|
||||
)
|
||||
env = {
|
||||
key: value
|
||||
for key, value in os.environ.items()
|
||||
if key not in ("GITHUB_WORKSPACE", "CODEX_PROVISIONING_HELPER")
|
||||
}
|
||||
env.update(
|
||||
CODEX_REPO_ROOT=str(root),
|
||||
RUNNER_TEMP=str(root),
|
||||
TARGET=target,
|
||||
PATH=f"{root}{os.pathsep}{os.environ['PATH']}",
|
||||
CALL_LOG=str(root / "calls.jsonl"),
|
||||
PROVISIONED_MACOS=str(provisioned).lower(),
|
||||
OAI_AKV_SIGNING_CERTIFICATE_PEM=str(certificate),
|
||||
MOCK_CERTIFICATE=str(root / "certificate.der"),
|
||||
MOCK_SIGNING_SCRIPTS=str(scripts),
|
||||
)
|
||||
return package, helpers / "sign_macos_cli_package.py", env
|
||||
|
||||
def run_driver(self, driver, operation, package, env):
|
||||
return subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
str(driver),
|
||||
operation,
|
||||
str(package),
|
||||
"--profile",
|
||||
str(self.configuration.profile),
|
||||
"--profile-sha256",
|
||||
self.configuration.profile_sha256,
|
||||
"--certificate-sha256",
|
||||
self.configuration.certificate_sha256,
|
||||
"--team-id",
|
||||
self.configuration.team_id,
|
||||
],
|
||||
env=env,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
timeout=30,
|
||||
check=False,
|
||||
)
|
||||
|
||||
def test_standard_and_provisioned_signing_and_verification(self):
|
||||
for provisioned, target, omit_empty in itertools.product(
|
||||
(False, True),
|
||||
("aarch64-apple-darwin", "x86_64-apple-darwin"),
|
||||
(False, True),
|
||||
):
|
||||
with (
|
||||
self.subTest(
|
||||
provisioned=provisioned, target=target, omit_empty=omit_empty
|
||||
),
|
||||
tempfile.TemporaryDirectory() as directory,
|
||||
):
|
||||
root = Path(directory).resolve()
|
||||
package, driver, env = self.fixture(root, provisioned, target)
|
||||
if omit_empty:
|
||||
env["MOCK_OMIT_EMPTY_ENTITLEMENTS"] = "1"
|
||||
result = self.run_driver(driver, "sign", package, env)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
result = self.run_driver(driver, "verify", package, env)
|
||||
self.assertEqual(result.returncode, 0, result.stderr)
|
||||
calls = [
|
||||
json.loads(line)
|
||||
for line in (root / "calls.jsonl").read_text().splitlines()
|
||||
]
|
||||
signing = [call for call in calls if call[0] == "sign_macos_code.sh"]
|
||||
self.assertEqual(
|
||||
[call[call.index("--target") + 1] for call in signing],
|
||||
[
|
||||
str(package / relative)
|
||||
for relative in (
|
||||
bundle.APP if provisioned else "bin/codex",
|
||||
*bundle.HELPERS,
|
||||
)
|
||||
],
|
||||
)
|
||||
self.assertEqual(
|
||||
signing[0][signing[0].index("--identifier") + 1], "codex"
|
||||
)
|
||||
self.assertEqual(
|
||||
signing[0][signing[0].index("--entitlements") + 1],
|
||||
str(
|
||||
root
|
||||
/ "signing-verification/codex-provisioned-entitlements.plist"
|
||||
)
|
||||
if provisioned
|
||||
else str(
|
||||
Path(env["MOCK_SIGNING_SCRIPTS"]) / "codex.entitlements.plist"
|
||||
),
|
||||
)
|
||||
self.assertEqual(
|
||||
["--entitlements" in call for call in signing],
|
||||
[True, True, True, False],
|
||||
)
|
||||
self.assertEqual(
|
||||
[call[0] for call in calls if call[0].startswith("notarize")],
|
||||
["notarize_with_akv.py"]
|
||||
if provisioned
|
||||
else ["notarize_macos_binary_with_akv.sh"] * 4,
|
||||
)
|
||||
self.assertEqual(
|
||||
[call[1:] for call in calls if call[0] == "lipo"],
|
||||
[
|
||||
[
|
||||
str(package / relative),
|
||||
"-verify_arch",
|
||||
"arm64" if target.startswith("aarch64") else "x86_64",
|
||||
]
|
||||
for relative in (
|
||||
bundle.EXECUTABLE if provisioned else "bin/codex",
|
||||
*bundle.HELPERS,
|
||||
)
|
||||
],
|
||||
)
|
||||
if provisioned:
|
||||
verification = [
|
||||
call
|
||||
for call in calls
|
||||
if call[0] == "codesign" and "--test-requirement" in call
|
||||
]
|
||||
cli_verification = verification[0]
|
||||
self.assertEqual(cli_verification[-1], str(package / bundle.APP))
|
||||
requirement = cli_verification[
|
||||
cli_verification.index("--test-requirement") + 1
|
||||
]
|
||||
self.assertIn(' and identifier "codex"', requirement)
|
||||
self.assertIn(
|
||||
' and certificate leaf[subject.OU] = "TESTTEAM01"', requirement
|
||||
)
|
||||
with zipfile.ZipFile(root / "provisioned-cli.zip") as archive:
|
||||
info = plistlib.loads(
|
||||
archive.read("CodexCLI.app/Contents/Info.plist")
|
||||
)
|
||||
self.assertEqual(
|
||||
info["CFBundleIdentifier"], "com.openai.codex.cli"
|
||||
)
|
||||
self.assertEqual(info["CFBundleExecutable"], "codex")
|
||||
self.assertEqual(
|
||||
plistlib.loads(
|
||||
(
|
||||
root
|
||||
/ "signing-verification/codex-provisioned-entitlements.plist"
|
||||
).read_bytes()
|
||||
),
|
||||
{
|
||||
**plistlib.loads(
|
||||
(
|
||||
Path(env["MOCK_SIGNING_SCRIPTS"])
|
||||
/ "codex.entitlements.plist"
|
||||
).read_bytes()
|
||||
),
|
||||
"com.apple.application-identifier": "TESTTEAM01.com.openai.codex.cli",
|
||||
"com.apple.developer.team-identifier": "TESTTEAM01",
|
||||
"keychain-access-groups": [
|
||||
"TESTTEAM01.com.openai.codex.cli"
|
||||
],
|
||||
},
|
||||
)
|
||||
self.assertEqual(
|
||||
archive.read(
|
||||
"CodexCLI.app/Contents/embedded.provisionprofile"
|
||||
),
|
||||
self.configuration.profile.read_bytes(),
|
||||
)
|
||||
self.assertEqual(
|
||||
archive.read("bin/codex").decode(), bundle.LAUNCHER
|
||||
)
|
||||
self.assertTrue(
|
||||
all(
|
||||
helper in archive.namelist()
|
||||
for helper in bundle.HELPERS
|
||||
)
|
||||
)
|
||||
|
||||
def test_provisioned_verification_rejects_changed_bundle_identity(self):
|
||||
for field, value in (
|
||||
("CFBundleIdentifier", "codex"),
|
||||
("CFBundleExecutable", "another-codex"),
|
||||
("CFBundlePackageType", "BNDL"),
|
||||
):
|
||||
with self.subTest(field=field), tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory).resolve()
|
||||
package, driver, env = self.fixture(root, True)
|
||||
signed = self.run_driver(driver, "sign", package, env)
|
||||
self.assertEqual(signed.returncode, 0, signed.stderr)
|
||||
info_path = package / bundle.APP / "Contents/Info.plist"
|
||||
info = plistlib.loads(info_path.read_bytes())
|
||||
info[field] = value
|
||||
info_path.write_bytes(plistlib.dumps(info))
|
||||
result = self.run_driver(driver, "verify", package, env)
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertIn(
|
||||
"Unexpected provisioned CLI bundle identity or executable",
|
||||
result.stderr,
|
||||
)
|
||||
|
||||
def test_signing_and_notarization_failures_stop_the_driver(self):
|
||||
for tool in ("sign_macos_code.sh", "notarize_with_akv.py"):
|
||||
with self.subTest(tool=tool), tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory).resolve()
|
||||
package, driver, env = self.fixture(root, True)
|
||||
result = self.run_driver(
|
||||
driver, "sign", package, {**env, "FAIL_TOOL": tool}
|
||||
)
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
calls = [
|
||||
json.loads(line)
|
||||
for line in (root / "calls.jsonl").read_text().splitlines()
|
||||
]
|
||||
self.assertEqual(calls[-1][0], tool)
|
||||
if tool == "notarize_with_akv.py":
|
||||
self.assertEqual(
|
||||
(root / "signing-verification/notarization.log").read_text(),
|
||||
"fixture stdout\nfixture stderr\n",
|
||||
)
|
||||
self.assertIn("fixture stdout\nfixture stderr\n", result.stdout)
|
||||
else:
|
||||
self.assertFalse((root / "provisioned-cli.zip").exists())
|
||||
|
||||
def test_verification_rejects_wrong_signing_identity_and_entitlements(self):
|
||||
for provisioned, failure in itertools.product(
|
||||
(False, True),
|
||||
(
|
||||
"MOCK_WRONG_SIGNING_IDENTITY",
|
||||
"MOCK_WRONG_ENTITLEMENTS",
|
||||
"MOCK_EXECUTOR_ENTITLEMENTS",
|
||||
),
|
||||
):
|
||||
with (
|
||||
self.subTest(provisioned=provisioned, failure=failure),
|
||||
tempfile.TemporaryDirectory() as directory,
|
||||
):
|
||||
root = Path(directory).resolve()
|
||||
package, driver, env = self.fixture(root, provisioned)
|
||||
signed = self.run_driver(driver, "sign", package, env)
|
||||
self.assertEqual(signed.returncode, 0, signed.stderr)
|
||||
result = self.run_driver(
|
||||
driver, "verify", package, {**env, failure: "true"}
|
||||
)
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
if failure == "MOCK_WRONG_SIGNING_IDENTITY":
|
||||
self.assertIn(
|
||||
"code failed to satisfy specified code requirement(s)",
|
||||
result.stderr,
|
||||
)
|
||||
else:
|
||||
self.assertIn("unexpected", result.stdout)
|
||||
|
||||
def test_cli_requires_independent_profile_configuration(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
result = subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
str(Path(bundle.__file__).with_name("sign_macos_cli_package.py")),
|
||||
"verify",
|
||||
directory,
|
||||
],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=False,
|
||||
)
|
||||
self.assertEqual(result.returncode, 2)
|
||||
self.assertIn("the following arguments are required", result.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
48
.github/scripts/npm_alpha_tag.py
vendored
Normal file
48
.github/scripts/npm_alpha_tag.py
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
"""Choose forward-only npm dist-tags under rust-release's publication lock."""
|
||||
|
||||
import json
|
||||
from pathlib import Path
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
|
||||
from releases import is_valid_stable_release_version, should_update_version
|
||||
|
||||
|
||||
def npm_alpha_tag(tarball: Path, version: str, tag: str) -> str:
|
||||
# Read the actual package name: platform archives share @openai/codex,
|
||||
# while the SDK and proxy have independent latest/alpha pointers.
|
||||
with tarfile.open(tarball, "r:gz") as archive:
|
||||
with archive.extractfile("package/package.json") as manifest:
|
||||
package = json.load(manifest)["name"]
|
||||
|
||||
result = subprocess.run(
|
||||
["npm", "view", package, "dist-tags", "--json", "--prefer-online"],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
current = json.loads(result.stdout).get(tag, "")
|
||||
if tag not in ("alpha", "latest"):
|
||||
# build_npm_package.py appends -<platform> to the release version.
|
||||
current = current.removesuffix(f"-{tag.removeprefix('alpha-')}")
|
||||
# Stable tags fail closed on unreadable metadata. Alpha tags keep their
|
||||
# existing recovery behavior, as with the other prerelease channels.
|
||||
is_alpha = tag == "alpha" or tag.startswith("alpha-")
|
||||
if current and not is_alpha and not is_valid_stable_release_version(current):
|
||||
raise ValueError(f"Cannot compare current {package}@{tag} version: {current}")
|
||||
if should_update_version(version, current):
|
||||
return tag
|
||||
|
||||
# npm publish always writes a tag. Keep this version installable without
|
||||
# changing latest, alpha, or their platform tags. Prefix avoids semver tags,
|
||||
# which npm rejects. Include the platform for versions of the same package.
|
||||
print(
|
||||
f"Keeping {package}@{tag} at {current}; publishing {version} separately",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return f"release-{version}-{tag}"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
print(npm_alpha_tag(Path(sys.argv[1]), sys.argv[2], sys.argv[3]))
|
||||
40
.github/scripts/publish-github-release.sh
vendored
Normal file
40
.github/scripts/publish-github-release.sh
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
repo_api="repos/$GITHUB_REPOSITORY"
|
||||
# Look up this tag, including drafts. A lookup error must abort publication.
|
||||
# shellcheck disable=SC2016
|
||||
exists="$(gh api graphql \
|
||||
-f query='query($owner:String!,$repo:String!,$tag:String!){repository(owner:$owner,name:$repo){release(tagName:$tag){databaseId}}}' \
|
||||
-f owner="$GITHUB_REPOSITORY_OWNER" \
|
||||
-f repo="${GITHUB_REPOSITORY#*/}" \
|
||||
-f tag="$GITHUB_REF_NAME" \
|
||||
--jq '.data.repository.release != null')"
|
||||
|
||||
if [[ "$exists" == false ]]; then
|
||||
# The create API would create a missing tag from the default branch.
|
||||
gh api --silent "$repo_api/git/ref/tags/$GITHUB_REF_NAME"
|
||||
draft=true
|
||||
if [[ "$PRERELEASE" == true ]]; then
|
||||
# Create prereleases directly to preserve the prereleased event.
|
||||
draft=false
|
||||
fi
|
||||
release_id="$(gh api --method POST "$repo_api/releases" \
|
||||
-f tag_name="$GITHUB_REF_NAME" -f name="$RELEASE_NAME" -F "body=@$RELEASE_NOTES" \
|
||||
-F draft="$draft" -F prerelease="$PRERELEASE" -f make_latest=false --jq '.id')"
|
||||
if [[ "$PRERELEASE" == true ]]; then
|
||||
# A maintainer can replace a release under the same tag during upload.
|
||||
trap '
|
||||
echo "Removing incomplete prerelease $release_id" >&2
|
||||
gh api --method DELETE "$repo_api/releases/$release_id" || true
|
||||
' EXIT
|
||||
fi
|
||||
fi
|
||||
|
||||
mapfile -d '' assets < <(find dist -type f -print0 | sort -z)
|
||||
gh release upload "$GITHUB_REF_NAME" "${assets[@]}" --repo "$GITHUB_REPOSITORY" --clobber
|
||||
trap - EXIT
|
||||
|
||||
gh release edit "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" \
|
||||
--title "$RELEASE_NAME" --notes-file "$RELEASE_NOTES" --prerelease="$PRERELEASE" \
|
||||
--draft=false --latest="$MAKE_LATEST"
|
||||
573
.github/scripts/publish_r2_release.py
vendored
Executable file
573
.github/scripts/publish_r2_release.py
vendored
Executable file
@@ -0,0 +1,573 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Mirror a Codex GitHub Release to Cloudflare R2.
|
||||
|
||||
Cloudflare R2 exposes an S3-compatible API, so the built-in AWS CLI uses
|
||||
standard AWS credentials and the R2 endpoint from ``AWS_ENDPOINT_URL``.
|
||||
Objects are created under ``codex/releases/<version>/`` with a validated upload
|
||||
checksum and checked using object metadata before the run succeeds. The
|
||||
versioned prefix includes every release asset plus installer-facing
|
||||
``release.json`` metadata derived from the verified downloads. Once those
|
||||
objects are verified, the same metadata advances ``codex/channels/latest`` when
|
||||
the release is marked latest and ``codex/channels/prerelease`` for prereleases
|
||||
that are newer than its current version, or when that version is unreadable.
|
||||
Latest stable releases also update the mutable ``codex/install.sh`` and
|
||||
``codex/install.ps1`` bootstrap aliases from their verified versioned assets.
|
||||
An older stable release cannot move these aliases or the latest channel back.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from pathlib import Path
|
||||
from typing import Any, NamedTuple, NoReturn
|
||||
from urllib.parse import quote
|
||||
|
||||
from releases import (
|
||||
is_valid_release_version,
|
||||
is_valid_stable_release_version,
|
||||
should_update_version,
|
||||
)
|
||||
|
||||
BUCKET = "releases"
|
||||
PREFIX = "codex"
|
||||
REPOSITORY = "openai/codex"
|
||||
RELEASE_METADATA_NAME = "release.json"
|
||||
INSTALLER_NAMES = ("install.sh", "install.ps1")
|
||||
MAX_UPLOAD_WORKERS = 8
|
||||
CRC64_RE = re.compile(r"^[A-Za-z0-9+/]{11}=$")
|
||||
SHA256_RE = re.compile(r"^sha256:([0-9a-f]{64})$")
|
||||
MISSING_OBJECT_RE = re.compile(r"\((?:404|NoSuchKey|NotFound)\)")
|
||||
|
||||
|
||||
class PublishError(RuntimeError):
|
||||
pass
|
||||
|
||||
|
||||
class ReleaseAsset(NamedTuple):
|
||||
path: Path
|
||||
size: int
|
||||
sha256: str
|
||||
|
||||
|
||||
def run_command(args: list[str]) -> str:
|
||||
result = subprocess.run(
|
||||
args,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
)
|
||||
if result.stdout:
|
||||
print(result.stdout, end="", file=sys.stderr)
|
||||
if result.stderr:
|
||||
print(result.stderr, end="", file=sys.stderr)
|
||||
result.check_returncode()
|
||||
return result.stdout or ""
|
||||
|
||||
|
||||
def get_release_metadata(tag: str, directory: Path, stage: str) -> list[ReleaseAsset]:
|
||||
try:
|
||||
metadata = json.loads(
|
||||
run_command(
|
||||
[
|
||||
"gh",
|
||||
"release",
|
||||
"view",
|
||||
tag,
|
||||
"--repo",
|
||||
REPOSITORY,
|
||||
"--json",
|
||||
"assets",
|
||||
"--jq",
|
||||
"[.assets[] | {name, size, state, digest}]",
|
||||
]
|
||||
)
|
||||
)
|
||||
except (OSError, subprocess.CalledProcessError) as error:
|
||||
raise PublishError(
|
||||
f"GitHub release metadata request failed for {tag}: {error}"
|
||||
) from error
|
||||
except json.JSONDecodeError as error:
|
||||
raise PublishError(
|
||||
f"invalid GitHub release metadata for {tag}: {error}"
|
||||
) from error
|
||||
|
||||
expected = {}
|
||||
if not isinstance(metadata, list):
|
||||
raise PublishError(f"GitHub returned invalid release metadata for {tag}")
|
||||
for asset in metadata:
|
||||
if not isinstance(asset, dict):
|
||||
raise PublishError(
|
||||
f"GitHub returned invalid release metadata for {tag}: {asset!r}"
|
||||
)
|
||||
# DotSlash runs concurrently, so defer its in-progress assets to finalization.
|
||||
if stage == "assets" and asset.get("state") != "uploaded":
|
||||
continue
|
||||
name = asset.get("name")
|
||||
size = asset.get("size")
|
||||
digest = asset.get("digest")
|
||||
match = SHA256_RE.fullmatch(digest) if isinstance(digest, str) else None
|
||||
if (
|
||||
not isinstance(name, str)
|
||||
or not name
|
||||
or name == RELEASE_METADATA_NAME
|
||||
or name in expected
|
||||
or type(size) is not int
|
||||
or size < 0
|
||||
or asset.get("state") != "uploaded"
|
||||
or match is None
|
||||
):
|
||||
raise PublishError(
|
||||
f"GitHub returned invalid release metadata for {tag}: {asset!r}"
|
||||
)
|
||||
expected[name] = ReleaseAsset(directory / name, size, match.group(1))
|
||||
|
||||
if not expected:
|
||||
raise PublishError(f"GitHub Release {tag} has no assets")
|
||||
return sorted(expected.values(), key=lambda asset: asset.path.name)
|
||||
|
||||
|
||||
def download_assets(tag: str, directory: Path, assets: list[ReleaseAsset]) -> None:
|
||||
if not assets:
|
||||
return
|
||||
|
||||
command = [
|
||||
"gh",
|
||||
"release",
|
||||
"download",
|
||||
tag,
|
||||
"--repo",
|
||||
REPOSITORY,
|
||||
"--dir",
|
||||
str(directory),
|
||||
]
|
||||
for asset in assets:
|
||||
command.extend(["--pattern", asset.path.name])
|
||||
|
||||
try:
|
||||
run_command(command)
|
||||
except (OSError, subprocess.CalledProcessError) as error:
|
||||
raise PublishError(
|
||||
f"GitHub release download failed for {tag}: {error}"
|
||||
) from error
|
||||
|
||||
if any(not asset.path.is_file() for asset in assets):
|
||||
raise PublishError("GitHub returned invalid release assets")
|
||||
|
||||
|
||||
def stream_digest(source: Any) -> tuple[int, str]:
|
||||
digest = hashlib.sha256()
|
||||
size = 0
|
||||
while chunk := source.read(1024 * 1024):
|
||||
digest.update(chunk)
|
||||
size += len(chunk)
|
||||
return size, digest.hexdigest()
|
||||
|
||||
|
||||
def validate_asset(asset: ReleaseAsset) -> None:
|
||||
with asset.path.open("rb") as source:
|
||||
size, sha256 = stream_digest(source)
|
||||
if size != asset.size or sha256 != asset.sha256:
|
||||
raise PublishError(
|
||||
f"GitHub asset mismatch for {asset.path.name}: expected "
|
||||
f"size={asset.size} sha256={asset.sha256}, got "
|
||||
f"size={size} sha256={sha256}"
|
||||
)
|
||||
|
||||
|
||||
def raise_s3(
|
||||
action: str, key: str, error: Exception, detail: str | None = None
|
||||
) -> NoReturn:
|
||||
raise PublishError(
|
||||
f"could not {action} s3://{BUCKET}/{key}: {detail or error}"
|
||||
) from error
|
||||
|
||||
|
||||
def put_object(
|
||||
endpoint: str,
|
||||
key: str,
|
||||
path: Path,
|
||||
sha256: str,
|
||||
*,
|
||||
extra_args: list[str],
|
||||
) -> None:
|
||||
try:
|
||||
run_command(
|
||||
[
|
||||
"aws",
|
||||
"s3",
|
||||
"cp",
|
||||
str(path),
|
||||
f"s3://{BUCKET}/{key}",
|
||||
*extra_args,
|
||||
"--checksum-algorithm",
|
||||
"CRC64NVME",
|
||||
"--metadata",
|
||||
f"sha256={sha256}",
|
||||
"--endpoint-url",
|
||||
endpoint,
|
||||
]
|
||||
)
|
||||
except subprocess.CalledProcessError as error:
|
||||
raise_s3("upload", key, error, (error.stderr or "").strip())
|
||||
except OSError as error:
|
||||
raise_s3("upload", key, error)
|
||||
|
||||
|
||||
def verify_remote(
|
||||
endpoint: str,
|
||||
key: str,
|
||||
expected_size: int,
|
||||
expected_sha256: str,
|
||||
) -> None:
|
||||
try:
|
||||
response = json.loads(
|
||||
run_command(
|
||||
[
|
||||
"aws",
|
||||
"s3api",
|
||||
"head-object",
|
||||
"--bucket",
|
||||
BUCKET,
|
||||
"--key",
|
||||
key,
|
||||
"--checksum-mode",
|
||||
"ENABLED",
|
||||
"--endpoint-url",
|
||||
endpoint,
|
||||
]
|
||||
)
|
||||
)
|
||||
except subprocess.CalledProcessError as error:
|
||||
raise_s3("inspect", key, error, (error.stderr or "").strip())
|
||||
except OSError as error:
|
||||
raise_s3("inspect", key, error)
|
||||
except json.JSONDecodeError as error:
|
||||
raise PublishError(f"invalid object metadata for {key}: {error}") from error
|
||||
|
||||
metadata = response.get("Metadata") if isinstance(response, dict) else None
|
||||
size = response.get("ContentLength") if isinstance(response, dict) else None
|
||||
crc64 = response.get("ChecksumCRC64NVME") if isinstance(response, dict) else None
|
||||
sha256 = metadata.get("sha256") if isinstance(metadata, dict) else None
|
||||
if (
|
||||
size != expected_size
|
||||
or sha256 != expected_sha256
|
||||
or not isinstance(crc64, str)
|
||||
or not CRC64_RE.fullmatch(crc64)
|
||||
):
|
||||
raise PublishError(
|
||||
f"object metadata mismatch for {key}: expected size={expected_size} "
|
||||
f"sha256={expected_sha256}, got size={size} sha256={sha256} "
|
||||
f"crc64nvme={crc64}"
|
||||
)
|
||||
|
||||
|
||||
def should_update_channel(endpoint: str, version: str, channel: str) -> bool:
|
||||
# Read R2 directly: the public CDN may still serve an older version.
|
||||
key = f"{PREFIX}/channels/{channel}"
|
||||
url = f"s3://{BUCKET}/{key}"
|
||||
try:
|
||||
raw = run_command(["aws", "s3", "cp", url, "-", "--endpoint-url", endpoint])
|
||||
except subprocess.CalledProcessError as error:
|
||||
if MISSING_OBJECT_RE.search(error.stderr or ""):
|
||||
return True
|
||||
raise_s3("read", key, error, (error.stderr or "").strip())
|
||||
except OSError as error:
|
||||
raise_s3("read", key, error)
|
||||
|
||||
try:
|
||||
metadata = json.loads(raw)
|
||||
except json.JSONDecodeError as error:
|
||||
if channel == "latest":
|
||||
raise PublishError(f"invalid channel metadata for {key}") from error
|
||||
return True
|
||||
tag = metadata.get("tag_name") if isinstance(metadata, dict) else None
|
||||
if not isinstance(tag, str) or not tag.startswith("rust-v"):
|
||||
if channel == "latest":
|
||||
raise PublishError(f"invalid channel metadata for {key}")
|
||||
return True
|
||||
|
||||
current = tag.removeprefix("rust-v")
|
||||
if channel == "latest":
|
||||
if not is_valid_stable_release_version(current):
|
||||
raise PublishError(f"invalid stable version in channel metadata for {key}")
|
||||
# Reruns can repair installer writes interrupted before channel finalization.
|
||||
if version == current:
|
||||
return True
|
||||
return should_update_version(version, current)
|
||||
|
||||
|
||||
def publish_installers(endpoint: str, tag: str, assets: list[ReleaseAsset]) -> None:
|
||||
installers = {asset.path.name: asset for asset in assets}
|
||||
missing = sorted(set(INSTALLER_NAMES) - installers.keys())
|
||||
if missing:
|
||||
raise PublishError(
|
||||
f"GitHub Release {tag} is missing installer assets: {', '.join(missing)}"
|
||||
)
|
||||
for name in INSTALLER_NAMES:
|
||||
asset = installers[name]
|
||||
validate_asset(asset)
|
||||
installer_key = f"{PREFIX}/{name}"
|
||||
put_object(endpoint, installer_key, asset.path, asset.sha256, extra_args=[])
|
||||
verify_remote(endpoint, installer_key, asset.size, asset.sha256)
|
||||
print(
|
||||
f"published and verified s3://{BUCKET}/{installer_key} "
|
||||
f"size={asset.size} sha256={asset.sha256}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
|
||||
def publish_asset(
|
||||
endpoint: str, version: str, asset: ReleaseAsset, *, verify: bool = True
|
||||
) -> dict[str, Any]:
|
||||
validate_asset(asset)
|
||||
key = f"{PREFIX}/releases/{version}/{asset.path.name}"
|
||||
put_object(endpoint, key, asset.path, asset.sha256, extra_args=["--no-overwrite"])
|
||||
if verify:
|
||||
verify_remote(endpoint, key, asset.size, asset.sha256)
|
||||
status = "published and verified" if verify else "published"
|
||||
print(
|
||||
f"{status} s3://{BUCKET}/{key} size={asset.size} sha256={asset.sha256}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return {
|
||||
"key": key,
|
||||
"name": asset.path.name,
|
||||
"sha256": asset.sha256,
|
||||
"size": asset.size,
|
||||
}
|
||||
|
||||
|
||||
def publish_assets(
|
||||
endpoint: str, version: str, assets: list[ReleaseAsset], *, verify: bool = True
|
||||
) -> list[dict[str, Any]]:
|
||||
if not assets:
|
||||
return []
|
||||
|
||||
published = {}
|
||||
with ThreadPoolExecutor(
|
||||
max_workers=min(MAX_UPLOAD_WORKERS, len(assets))
|
||||
) as executor:
|
||||
futures = {
|
||||
executor.submit(
|
||||
publish_asset, endpoint, version, asset, verify=verify
|
||||
): asset
|
||||
for asset in assets
|
||||
}
|
||||
for future in as_completed(futures):
|
||||
asset = futures[future]
|
||||
published[asset.path.name] = future.result()
|
||||
return [published[asset.path.name] for asset in assets]
|
||||
|
||||
|
||||
def find_published_assets(
|
||||
endpoint: str, version: str, assets: list[ReleaseAsset]
|
||||
) -> dict[str, dict[str, Any]]:
|
||||
published = {}
|
||||
with ThreadPoolExecutor(
|
||||
max_workers=min(MAX_UPLOAD_WORKERS, len(assets))
|
||||
) as executor:
|
||||
futures = {
|
||||
executor.submit(
|
||||
verify_remote,
|
||||
endpoint,
|
||||
f"{PREFIX}/releases/{version}/{asset.path.name}",
|
||||
asset.size,
|
||||
asset.sha256,
|
||||
): asset
|
||||
for asset in assets
|
||||
}
|
||||
for future in as_completed(futures):
|
||||
asset = futures[future]
|
||||
try:
|
||||
future.result()
|
||||
except PublishError as error:
|
||||
cause = error.__cause__
|
||||
if isinstance(cause, subprocess.CalledProcessError) and (
|
||||
MISSING_OBJECT_RE.search(cause.stderr or "")
|
||||
):
|
||||
continue
|
||||
raise
|
||||
published[asset.path.name] = {
|
||||
"key": f"{PREFIX}/releases/{version}/{asset.path.name}",
|
||||
"name": asset.path.name,
|
||||
"sha256": asset.sha256,
|
||||
"size": asset.size,
|
||||
}
|
||||
return published
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--tag", required=True)
|
||||
parser.add_argument("--make-latest", choices=("true", "false"), required=True)
|
||||
parser.add_argument("--prerelease", choices=("true", "false"), required=True)
|
||||
parser.add_argument("--stage", choices=("assets", "finalize"), required=True)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
args = parse_args()
|
||||
try:
|
||||
endpoint = os.environ.get("AWS_ENDPOINT_URL")
|
||||
if not os.environ.get("GH_TOKEN"):
|
||||
raise PublishError("GH_TOKEN is required")
|
||||
if not endpoint:
|
||||
raise PublishError("AWS_ENDPOINT_URL is required for the R2 S3 endpoint")
|
||||
|
||||
version = args.tag.removeprefix("rust-v")
|
||||
if args.tag == version or not is_valid_release_version(version):
|
||||
raise PublishError(f"invalid rust release tag: {args.tag}")
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
assets_directory = Path(temp_dir) / "assets"
|
||||
assets_directory.mkdir()
|
||||
assets = get_release_metadata(args.tag, assets_directory, args.stage)
|
||||
|
||||
if args.stage == "assets":
|
||||
download_assets(args.tag, assets_directory, assets)
|
||||
published = publish_assets(endpoint, version, assets, verify=False)
|
||||
print(
|
||||
json.dumps(
|
||||
{
|
||||
"assetCount": len(published),
|
||||
"assets": published,
|
||||
"releasePrefix": f"{PREFIX}/releases/{version}/",
|
||||
"stage": args.stage,
|
||||
"tag": args.tag,
|
||||
"version": version,
|
||||
},
|
||||
sort_keys=True,
|
||||
)
|
||||
)
|
||||
return 0
|
||||
|
||||
previously_published = find_published_assets(endpoint, version, assets)
|
||||
remaining = [
|
||||
asset for asset in assets if asset.path.name not in previously_published
|
||||
]
|
||||
required_downloads = list(remaining)
|
||||
if args.prerelease == "false" and args.make_latest == "true":
|
||||
required_downloads.extend(
|
||||
asset
|
||||
for asset in assets
|
||||
if asset.path.name in INSTALLER_NAMES
|
||||
and asset.path.name in previously_published
|
||||
)
|
||||
download_assets(args.tag, assets_directory, required_downloads)
|
||||
additionally_published = {
|
||||
asset["name"]: asset
|
||||
for asset in publish_assets(endpoint, version, remaining)
|
||||
}
|
||||
published = [
|
||||
previously_published.get(asset.path.name)
|
||||
or additionally_published[asset.path.name]
|
||||
for asset in assets
|
||||
]
|
||||
metadata_assets = [
|
||||
{
|
||||
"name": asset.path.name,
|
||||
"digest": f"sha256:{asset.sha256}",
|
||||
"browser_download_url": (
|
||||
f"https://releases.openai.com/{PREFIX}/releases/"
|
||||
f"{version}/{quote(asset.path.name, safe='')}"
|
||||
),
|
||||
}
|
||||
for asset in assets
|
||||
]
|
||||
|
||||
metadata_path = Path(temp_dir) / RELEASE_METADATA_NAME
|
||||
metadata_path.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"assets": metadata_assets,
|
||||
"tag_name": args.tag,
|
||||
},
|
||||
indent=2,
|
||||
)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
with metadata_path.open("rb") as source:
|
||||
metadata_size, metadata_sha256 = stream_digest(source)
|
||||
metadata_key = f"{PREFIX}/releases/{version}/{RELEASE_METADATA_NAME}"
|
||||
put_object(
|
||||
endpoint,
|
||||
metadata_key,
|
||||
metadata_path,
|
||||
metadata_sha256,
|
||||
extra_args=["--no-overwrite"],
|
||||
)
|
||||
verify_remote(
|
||||
endpoint,
|
||||
metadata_key,
|
||||
metadata_size,
|
||||
metadata_sha256,
|
||||
)
|
||||
print(
|
||||
f"published and verified s3://{BUCKET}/{metadata_key} "
|
||||
f"size={metadata_size} sha256={metadata_sha256}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
channels = []
|
||||
if args.make_latest == "true" and should_update_channel(
|
||||
endpoint, version, "latest"
|
||||
):
|
||||
channels.append("latest")
|
||||
if args.prerelease == "true" and should_update_channel(
|
||||
endpoint, version, "prerelease"
|
||||
):
|
||||
channels.append("prerelease")
|
||||
if "latest" in channels and args.prerelease == "false":
|
||||
publish_installers(endpoint, args.tag, assets)
|
||||
for channel in channels:
|
||||
channel_key = f"{PREFIX}/channels/{channel}"
|
||||
put_object(
|
||||
endpoint,
|
||||
channel_key,
|
||||
metadata_path,
|
||||
metadata_sha256,
|
||||
extra_args=["--content-type", "application/json"],
|
||||
)
|
||||
verify_remote(
|
||||
endpoint,
|
||||
channel_key,
|
||||
metadata_size,
|
||||
metadata_sha256,
|
||||
)
|
||||
print(
|
||||
f"published and verified s3://{BUCKET}/{channel_key} "
|
||||
f"size={metadata_size} sha256={metadata_sha256}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
print(
|
||||
json.dumps(
|
||||
{
|
||||
"assetCount": len(published),
|
||||
"assets": published,
|
||||
"releaseMetadata": {
|
||||
"key": metadata_key,
|
||||
"sha256": metadata_sha256,
|
||||
"size": metadata_size,
|
||||
},
|
||||
"releasePrefix": f"{PREFIX}/releases/{version}/",
|
||||
"stage": args.stage,
|
||||
"tag": args.tag,
|
||||
"version": version,
|
||||
},
|
||||
sort_keys=True,
|
||||
)
|
||||
)
|
||||
return 0
|
||||
except PublishError as error:
|
||||
print(f"publish failed: {error}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
85
.github/scripts/releases.py
vendored
Normal file
85
.github/scripts/releases.py
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
"""Validate Codex releases and check whether their GitHub channel pointers can advance."""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
_VERSION_RE = re.compile(
|
||||
r"^[0-9]+\.[0-9]+\.[0-9]+(?:-(?:alpha(?:\.[0-9]+){0,2}"
|
||||
r"|beta(?:\.[0-9]+)?))?$"
|
||||
)
|
||||
|
||||
|
||||
def is_valid_release_version(version: str) -> bool:
|
||||
return _VERSION_RE.fullmatch(version) is not None
|
||||
|
||||
|
||||
def is_valid_stable_release_version(version: str) -> bool:
|
||||
return is_valid_release_version(version) and "-" not in version
|
||||
|
||||
|
||||
def _version_key(version: str) -> tuple[tuple[int, ...], int, tuple[int, ...]]:
|
||||
base, _, prerelease = version.partition("-")
|
||||
channel, _, suffix = prerelease.partition(".")
|
||||
return (
|
||||
tuple(int(part) for part in base.split(".")),
|
||||
{"alpha": 0, "beta": 1, "": 2}[channel],
|
||||
tuple(int(part) for part in suffix.split(".")) if suffix else (),
|
||||
)
|
||||
|
||||
|
||||
def should_update_version(version: str, current_version: str) -> bool:
|
||||
"""Compare version strings; replace an unreadable current version."""
|
||||
if not is_valid_release_version(version):
|
||||
raise ValueError(f"invalid release version: {version}")
|
||||
if not is_valid_release_version(current_version):
|
||||
# Replace an unreadable pointer so publishing can repair it.
|
||||
return True
|
||||
|
||||
return _version_key(version) > _version_key(current_version)
|
||||
|
||||
|
||||
def should_make_latest(version: str, latest: dict) -> bool:
|
||||
if not is_valid_stable_release_version(version):
|
||||
raise ValueError(f"expected a stable release version: {version}")
|
||||
tag = latest.get("tag_name", "")
|
||||
current = tag.removeprefix("rust-v") if isinstance(tag, str) else ""
|
||||
if (
|
||||
not isinstance(tag, str)
|
||||
or not tag.startswith("rust-v")
|
||||
or not is_valid_stable_release_version(current)
|
||||
or latest.get("draft") is not False
|
||||
or latest.get("prerelease") is not False
|
||||
):
|
||||
raise ValueError("Cannot determine the current GitHub latest stable release")
|
||||
# An equal version must be able to finish a partially completed publication.
|
||||
return version == current or should_update_version(version, current)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("version")
|
||||
parser.add_argument(
|
||||
"--check-github",
|
||||
choices=("latest", "canary"),
|
||||
help="Compare with the latest release JSON or canary Cargo.toml on stdin.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
if args.check_github is None:
|
||||
raise SystemExit(0 if is_valid_release_version(args.version) else 1)
|
||||
if args.check_github == "latest":
|
||||
update = should_make_latest(args.version, json.load(sys.stdin))
|
||||
else:
|
||||
import tomllib
|
||||
|
||||
try:
|
||||
current_version = tomllib.loads(sys.stdin.read())["workspace"]["package"][
|
||||
"version"
|
||||
]
|
||||
except (tomllib.TOMLDecodeError, KeyError, TypeError):
|
||||
current_version = ""
|
||||
if not isinstance(current_version, str):
|
||||
current_version = ""
|
||||
update = should_update_version(args.version, current_version)
|
||||
print(str(update).lower())
|
||||
39
.github/scripts/resolve_exec_server_releases.py
vendored
Normal file
39
.github/scripts/resolve_exec_server_releases.py
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
"""Print CODEX_COMPAT_RELEASES JSON for the existing Bazel compatibility tests.
|
||||
|
||||
For local runs, export CODEX_COMPAT_RELEASES="$(python3 <path-to-this-script>)"
|
||||
before invoking Bazel. CI resolves it once before building the test targets.
|
||||
"""
|
||||
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from datetime import datetime, timedelta, timezone
|
||||
|
||||
from contract_releases import PACKAGE, github_read, list_releases, select_stables
|
||||
|
||||
STABLE_LOOKBACK_DAYS = 60
|
||||
|
||||
|
||||
def main() -> None:
|
||||
target_date = datetime.now(timezone.utc) - timedelta(days=STABLE_LOOKBACK_DAYS)
|
||||
tags = select_stables(list_releases(exclude_prereleases=True), target_date)
|
||||
releases = {}
|
||||
for tag in tags:
|
||||
metadata = json.loads(
|
||||
github_read(["gh", "api", f"repos/openai/codex/releases/tags/{tag}"])
|
||||
)
|
||||
asset = next(asset for asset in metadata["assets"] if asset["name"] == PACKAGE)
|
||||
digest = asset.get("digest") or ""
|
||||
if not re.fullmatch(r"sha256:[0-9a-f]{64}", digest):
|
||||
raise ValueError(f"Missing SHA-256 digest for {tag}/{PACKAGE}")
|
||||
releases[tag] = {"version": tag.removeprefix("rust-v"), "sha256": digest[7:]}
|
||||
print(
|
||||
f"Compatibility releases: latest={tags[0]}, "
|
||||
f"closest to {target_date.isoformat()}={tags[-1]}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
print(json.dumps({"latest": releases[tags[0]], "historical": releases[tags[-1]]}))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
123
.github/scripts/resolve_python_cli_release.py
vendored
Normal file
123
.github/scripts/resolve_python_cli_release.py
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Bind downstream Python publication to a published stable CLI release."""
|
||||
|
||||
import argparse
|
||||
import itertools
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def github_api(path: str):
|
||||
return json.loads(subprocess.check_output(["gh", "api", path], text=True))
|
||||
|
||||
|
||||
def github_items(path: str, key: str | None = None):
|
||||
separator = "&" if "?" in path else "?"
|
||||
for page in itertools.count(1):
|
||||
response = github_api(f"{path}{separator}per_page=100&page={page}")
|
||||
items = response[key] if key else response
|
||||
yield from items
|
||||
if len(items) < 100:
|
||||
return
|
||||
|
||||
|
||||
def resolve_release(
|
||||
repository: str, run_id: str, *, run: dict | None = None
|
||||
) -> dict[str, str] | None:
|
||||
if repository != "openai/codex" or not re.fullmatch(r"[1-9][0-9]*", run_id):
|
||||
raise ValueError("Expected an openai/codex Rust release run ID")
|
||||
prefix = f"repos/{repository}"
|
||||
if run is None:
|
||||
run = github_api(f"{prefix}/actions/runs/{run_id}")
|
||||
if (
|
||||
str(run["id"]) != run_id
|
||||
or run["path"] != ".github/workflows/rust-release.yml"
|
||||
or run["event"] != "push"
|
||||
or run["status"] != "completed"
|
||||
or run["head_repository"]["full_name"] != repository
|
||||
):
|
||||
raise ValueError("Python publication requires a completed Rust release run")
|
||||
tag = run["head_branch"]
|
||||
if not isinstance(tag, str) or not tag.startswith("rust-v"):
|
||||
raise ValueError("The Rust release run must identify a release tag")
|
||||
match = re.fullmatch(r"rust-v([0-9]+\.[0-9]+\.[0-9]+)", tag)
|
||||
if match is None:
|
||||
return None # CLI prereleases do not publish the Python SDK.
|
||||
revision = run["head_sha"]
|
||||
if not re.fullmatch(r"[0-9a-f]{40}", revision):
|
||||
raise ValueError("The Rust release run must identify an exact commit")
|
||||
|
||||
# A partial rerun of an unrelated publisher may not contain the release job.
|
||||
# Inspect all attempts and use the last release job that actually ran.
|
||||
release_job = max(
|
||||
(
|
||||
job
|
||||
for job in github_items(
|
||||
f"{prefix}/actions/runs/{run_id}/jobs?filter=all", "jobs"
|
||||
)
|
||||
if job["name"] == "release" and job["conclusion"] != "skipped"
|
||||
),
|
||||
key=lambda job: (job["run_attempt"], job["id"]),
|
||||
default=None,
|
||||
)
|
||||
if release_job is None or release_job["conclusion"] != "success":
|
||||
raise ValueError("Python publication requires a successful release job")
|
||||
|
||||
target = github_api(f"{prefix}/git/ref/tags/{tag}")["object"]
|
||||
for _ in range(8):
|
||||
if target["type"] != "tag":
|
||||
break
|
||||
target = github_api(f"{prefix}/git/tags/{target['sha']}")["object"]
|
||||
if target.get("type") != "commit" or target.get("sha") != revision:
|
||||
raise ValueError("The release tag no longer matches the successful CLI run")
|
||||
release = github_api(f"{prefix}/releases/tags/{tag}")
|
||||
if release["draft"] or release["prerelease"] or release["tag_name"] != tag:
|
||||
raise ValueError("The CLI release must be published and stable")
|
||||
|
||||
# The runtime builder downloads these six wheels and builds the two musl
|
||||
# wheels from the release's package archives.
|
||||
required_assets = {
|
||||
f"openai_codex_cli_bin-{match[1]}-py3-none-{platform}.whl"
|
||||
for platform in (
|
||||
"macosx_10_9_x86_64",
|
||||
"macosx_11_0_arm64",
|
||||
"manylinux_2_17_aarch64",
|
||||
"manylinux_2_17_x86_64",
|
||||
"win_amd64",
|
||||
"win_arm64",
|
||||
)
|
||||
} | {
|
||||
f"codex-package-{arch}-unknown-linux-musl.tar.gz"
|
||||
for arch in ("aarch64", "x86_64")
|
||||
}
|
||||
available_assets = {
|
||||
asset["name"]
|
||||
for asset in github_items(f"{prefix}/releases/{release['id']}/assets")
|
||||
if asset["state"] == "uploaded" and asset["size"] > 0
|
||||
}
|
||||
if missing := required_assets - available_assets:
|
||||
raise ValueError(f"The CLI release is missing Python inputs: {sorted(missing)}")
|
||||
return {"source_sha": revision, "release_tag": tag, "version": match[1]}
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("run_id")
|
||||
parser.add_argument("--repository", required=True)
|
||||
parser.add_argument("--event-path", type=Path)
|
||||
parser.add_argument("--github-output", type=Path, required=True)
|
||||
args = parser.parse_args(argv)
|
||||
event = json.loads(args.event_path.read_text()) if args.event_path else {}
|
||||
release = resolve_release(
|
||||
args.repository, args.run_id, run=event.get("workflow_run")
|
||||
)
|
||||
with args.github_output.open("a") as output:
|
||||
print(f"publish={str(release is not None).lower()}", file=output)
|
||||
for name, value in (release or {}).items():
|
||||
print(f"{name}={value}", file=output)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
72
.github/scripts/run-argument-comment-lint-bazel.sh
vendored
Executable file
72
.github/scripts/run-argument-comment-lint-bazel.sh
vendored
Executable file
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
bazel_lint_args=("$@")
|
||||
if [[ "${RUNNER_OS:-}" == "Windows" ]]; then
|
||||
# Some Rust top-level targets are still intentionally incompatible with the
|
||||
# local Windows exec platform. Skip those explicit targets so the native
|
||||
# lint aspect can run across the compatible crate graph instead of failing the
|
||||
# whole build after analysis.
|
||||
bazel_lint_args+=("--skip_incompatible_explicit_targets")
|
||||
if [[ -n "${VOICE_WINDOWS_BAZEL_REPOSITORY:-}" ]]; then
|
||||
: "${VOICE_WINDOWS_BAZEL_REPOSITORY:?Windows voice tools are required}"
|
||||
: "${VOICE_WINDOWS_SYSTEM_ROOT:?Windows SystemRoot is required}"
|
||||
: "${VOICE_WINDOWS_HOST_ARCH:?Windows host architecture is required}"
|
||||
bazel_lint_args+=(
|
||||
"--extra_toolchains=//third_party/voice:windows_pkg_config_toolchain,//third_party/voice:windows_cmake_toolchain"
|
||||
"--repo_env=BAZEL_MSVC_RUNTIME_VISUAL_STUDIO_EULA=1"
|
||||
"--inject_repository=voice_windows_tools=${VOICE_WINDOWS_BAZEL_REPOSITORY}"
|
||||
"--//third_party/voice:windows_installed_tools=@voice_windows_tools//:tools"
|
||||
"--action_env=SystemRoot=${VOICE_WINDOWS_SYSTEM_ROOT}"
|
||||
"--host_action_env=SystemRoot=${VOICE_WINDOWS_SYSTEM_ROOT}"
|
||||
"--action_env=PROCESSOR_ARCHITECTURE=${VOICE_WINDOWS_HOST_ARCH}"
|
||||
"--host_action_env=PROCESSOR_ARCHITECTURE=${VOICE_WINDOWS_HOST_ARCH}"
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
read_query_labels() {
|
||||
local query="$1"
|
||||
local query_stdout
|
||||
local query_stderr
|
||||
query_stdout="$(mktemp)"
|
||||
query_stderr="$(mktemp)"
|
||||
|
||||
if ! ./.github/scripts/run-bazel-query-ci.sh \
|
||||
--keep_going \
|
||||
--output=label \
|
||||
-- "$query" >"$query_stdout" 2>"$query_stderr"; then
|
||||
cat "$query_stderr" >&2
|
||||
rm -f "$query_stdout" "$query_stderr"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat "$query_stdout"
|
||||
rm -f "$query_stdout" "$query_stderr"
|
||||
}
|
||||
|
||||
final_build_targets=(//codex-rs/...)
|
||||
if [[ "${RUNNER_OS:-}" == "Windows" ]]; then
|
||||
# Bazel's local Windows platform currently lacks a default test toolchain for
|
||||
# `rust_test`, so target the concrete Rust crate rules directly. The lint
|
||||
# aspect still walks their crate graph, which preserves incremental reuse for
|
||||
# non-test code while avoiding non-Rust wrapper targets such as platform_data.
|
||||
final_build_targets=()
|
||||
while IFS= read -r label; do
|
||||
[[ -n "$label" ]] || continue
|
||||
final_build_targets+=("$label")
|
||||
done < <(read_query_labels 'kind("rust_(library|binary|proc_macro) rule", //codex-rs/...)')
|
||||
|
||||
if [[ ${#final_build_targets[@]} -eq 0 ]]; then
|
||||
echo "Failed to discover Windows Bazel lint targets." >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
./.github/scripts/run-bazel-ci.sh \
|
||||
-- \
|
||||
build \
|
||||
"${bazel_lint_args[@]}" \
|
||||
-- \
|
||||
"${final_build_targets[@]}"
|
||||
382
.github/scripts/run-bazel-ci.sh
vendored
Executable file
382
.github/scripts/run-bazel-ci.sh
vendored
Executable file
@@ -0,0 +1,382 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
print_failed_bazel_test_logs=0
|
||||
print_failed_bazel_action_summary=0
|
||||
remote_download_toplevel=0
|
||||
windows_msvc_host_platform=0
|
||||
windows_cross_compile=0
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--print-failed-test-logs)
|
||||
print_failed_bazel_test_logs=1
|
||||
shift
|
||||
;;
|
||||
--print-failed-action-summary)
|
||||
print_failed_bazel_action_summary=1
|
||||
shift
|
||||
;;
|
||||
--remote-download-toplevel)
|
||||
remote_download_toplevel=1
|
||||
shift
|
||||
;;
|
||||
--windows-msvc-host-platform)
|
||||
windows_msvc_host_platform=1
|
||||
shift
|
||||
;;
|
||||
--windows-cross-compile)
|
||||
windows_cross_compile=1
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Usage: $0 [--print-failed-test-logs] [--print-failed-action-summary] [--remote-download-toplevel] [--windows-msvc-host-platform] [--windows-cross-compile] -- <bazel args> -- <targets>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
bazel_startup_args=()
|
||||
if [[ -n "${BAZEL_OUTPUT_USER_ROOT:-}" ]]; then
|
||||
bazel_startup_args+=("--output_user_root=${BAZEL_OUTPUT_USER_ROOT}")
|
||||
fi
|
||||
|
||||
run_bazel() {
|
||||
if [[ "${RUNNER_OS:-}" == "Windows" ]]; then
|
||||
MSYS2_ARG_CONV_EXCL='*' "$(dirname "${BASH_SOURCE[0]}")/run_bazel_with_buildbuddy.py" "$@"
|
||||
return
|
||||
fi
|
||||
|
||||
"$(dirname "${BASH_SOURCE[0]}")/run_bazel_with_buildbuddy.py" "$@"
|
||||
}
|
||||
|
||||
run_bazel_with_startup_args() {
|
||||
if (( ${#bazel_startup_args[@]} > 0 )); then
|
||||
run_bazel "${bazel_startup_args[@]}" "$@"
|
||||
return
|
||||
fi
|
||||
|
||||
run_bazel "$@"
|
||||
}
|
||||
|
||||
print_bazel_test_log_tails() {
|
||||
local console_log="$1"
|
||||
local testlogs_dir
|
||||
|
||||
local -a bazel_info_args=(info)
|
||||
|
||||
# Only pass flags that affect Bazel's output-root selection or repository
|
||||
# lookup. Test/build-only flags such as execution logs or remote download
|
||||
# mode can make `bazel info` fail, which would hide the real test log path.
|
||||
for arg in "${post_config_bazel_args[@]}"; do
|
||||
case "$arg" in
|
||||
--host_platform=* | --repo_contents_cache=* | --repository_cache=*)
|
||||
bazel_info_args+=("$arg")
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
testlogs_dir="$(run_bazel_with_startup_args \
|
||||
--noexperimental_remote_repo_contents_cache \
|
||||
"${bazel_info_args[@]}" \
|
||||
bazel-testlogs 2>/dev/null || echo bazel-testlogs)"
|
||||
|
||||
local failed_targets=()
|
||||
while IFS= read -r target; do
|
||||
failed_targets+=("$target")
|
||||
done < <(
|
||||
grep -E '^(FAIL: //|ERROR: .* Testing //)' "$console_log" \
|
||||
| sed -E 's#^FAIL: (//[^ ]+).*#\1#; s#^ERROR: .* Testing (//[^ ]+) failed:.*#\1#' \
|
||||
| sort -u
|
||||
)
|
||||
|
||||
if [[ ${#failed_targets[@]} -eq 0 ]]; then
|
||||
echo "No failed Bazel test targets were found in console output."
|
||||
return
|
||||
fi
|
||||
|
||||
for target in "${failed_targets[@]}"; do
|
||||
local rel_path="${target#//}"
|
||||
rel_path="${rel_path/://}"
|
||||
local test_log="${testlogs_dir}/${rel_path}/test.log"
|
||||
local reported_test_log
|
||||
reported_test_log="$(grep -F "FAIL: ${target} " "$console_log" | sed -nE 's#.* \(see (.*[\\/]test\.log)\).*#\1#p' | head -n 1 || true)"
|
||||
if [[ -n "$reported_test_log" ]]; then
|
||||
reported_test_log="${reported_test_log//\\//}"
|
||||
test_log="$reported_test_log"
|
||||
fi
|
||||
|
||||
echo "::group::Bazel test log tail for ${target}"
|
||||
if [[ -f "$test_log" ]]; then
|
||||
tail -n 200 "$test_log"
|
||||
else
|
||||
echo "Missing test log: $test_log"
|
||||
fi
|
||||
echo "::endgroup::"
|
||||
done
|
||||
}
|
||||
|
||||
print_bazel_action_failure_summary() {
|
||||
local console_log="$1"
|
||||
local escaped_summary
|
||||
local summary
|
||||
|
||||
summary="$(
|
||||
awk '
|
||||
function clean(line) {
|
||||
gsub(sprintf("%c", 27) "\\[[0-9;]*m", "", line)
|
||||
sub(/^.*\t[^\t]*\t[0-9TZ:._-]+ /, "", line)
|
||||
return line
|
||||
}
|
||||
|
||||
function is_diagnostic(line) {
|
||||
return line ~ /^(error(\[[^]]+\])?:|warning:|note:|help:)/ ||
|
||||
line ~ /^[[:space:]]+-->/ ||
|
||||
line ~ /^[[:space:]]*[0-9]+[[:space:]]+\|/ ||
|
||||
line ~ /^[[:space:]]*\|/ ||
|
||||
line ~ /^[[:space:]]+= (note|help):/ ||
|
||||
line ~ /^[[:space:]]*\^[[:space:]^~-]*$/ ||
|
||||
line ~ /^For more information/ ||
|
||||
line ~ /^error: aborting/
|
||||
}
|
||||
|
||||
{
|
||||
line = clean($0)
|
||||
}
|
||||
|
||||
line ~ /^ERROR: .* failed:/ {
|
||||
if (printed) {
|
||||
print ""
|
||||
}
|
||||
print line
|
||||
in_failure = 1
|
||||
seen_diagnostic = 0
|
||||
printed = 1
|
||||
next
|
||||
}
|
||||
|
||||
in_failure && is_diagnostic(line) {
|
||||
print line
|
||||
seen_diagnostic = 1
|
||||
next
|
||||
}
|
||||
|
||||
in_failure && seen_diagnostic && line == "" {
|
||||
print ""
|
||||
next
|
||||
}
|
||||
|
||||
in_failure && seen_diagnostic {
|
||||
in_failure = 0
|
||||
seen_diagnostic = 0
|
||||
next
|
||||
}
|
||||
' "$console_log"
|
||||
)"
|
||||
|
||||
if [[ -z "$summary" ]]; then
|
||||
summary="$(grep -E '^ERROR: |^FAILED: ' "$console_log" | tail -n 50 || true)"
|
||||
fi
|
||||
|
||||
if [[ -z "$summary" ]]; then
|
||||
echo "No Bazel action failures were found in the captured console output."
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "${GITHUB_ACTIONS:-}" == "true" ]]; then
|
||||
escaped_summary="$(
|
||||
printf '%s' "$summary" \
|
||||
| awk 'BEGIN { ORS = "" } {
|
||||
gsub(/%/, "%25")
|
||||
gsub(/\r/, "%0D")
|
||||
print sep $0
|
||||
sep = "%0A"
|
||||
}'
|
||||
)"
|
||||
echo "::error title=Bazel failed action diagnostics::${escaped_summary}"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "Bazel failed action diagnostics:"
|
||||
echo "--------------------------------"
|
||||
printf '%s\n' "$summary"
|
||||
echo "--------------------------------"
|
||||
}
|
||||
|
||||
bazel_args=()
|
||||
bazel_targets=()
|
||||
found_target_separator=0
|
||||
for arg in "$@"; do
|
||||
if [[ "$arg" == "--" && $found_target_separator -eq 0 ]]; then
|
||||
found_target_separator=1
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ $found_target_separator -eq 0 ]]; then
|
||||
bazel_args+=("$arg")
|
||||
else
|
||||
bazel_targets+=("$arg")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${#bazel_args[@]} -eq 0 || ${#bazel_targets[@]} -eq 0 ]]; then
|
||||
echo "Expected Bazel args and targets separated by --" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${RUNNER_OS:-}" == "Windows" && $windows_cross_compile -eq 1 ]]; then
|
||||
# Run Windows actions with the native MSVC host platform.
|
||||
windows_msvc_host_platform=1
|
||||
fi
|
||||
|
||||
post_config_bazel_args=()
|
||||
if [[ "${RUNNER_OS:-}" == "Windows" && $windows_msvc_host_platform -eq 1 ]]; then
|
||||
has_host_platform_override=0
|
||||
for arg in "${bazel_args[@]}"; do
|
||||
if [[ "$arg" == --host_platform=* ]]; then
|
||||
has_host_platform_override=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ $has_host_platform_override -eq 0 ]]; then
|
||||
# Use the MSVC Windows platform for jobs that need helper binaries like
|
||||
# Rust test wrappers and V8 generators to resolve a compatible toolchain.
|
||||
# Callers that need a different Windows target platform should pass an
|
||||
# explicit `--platforms=...` flag.
|
||||
post_config_bazel_args+=("--host_platform=//:local_windows_msvc")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $remote_download_toplevel -eq 1 ]]; then
|
||||
# Override the CI config's remote_download_minimal setting when callers need
|
||||
# the built artifact to exist on disk after the command completes.
|
||||
post_config_bazel_args+=(--remote_download_toplevel)
|
||||
fi
|
||||
|
||||
|
||||
if [[ "${RUNNER_OS:-}" == "Windows" && $windows_cross_compile -eq 1 ]]; then
|
||||
# Bound concurrent native Windows actions to fit the runner.
|
||||
post_config_bazel_args+=(--jobs=8)
|
||||
fi
|
||||
|
||||
if [[ -n "${BAZEL_REPO_CONTENTS_CACHE:-}" ]]; then
|
||||
# Windows self-hosted runners can run multiple Bazel jobs concurrently. Give
|
||||
# each job its own repo contents cache so they do not fight over the shared
|
||||
# path configured in `ci-windows`.
|
||||
post_config_bazel_args+=("--repo_contents_cache=${BAZEL_REPO_CONTENTS_CACHE}")
|
||||
fi
|
||||
|
||||
if [[ -n "${BAZEL_REPOSITORY_CACHE:-}" ]]; then
|
||||
post_config_bazel_args+=("--repository_cache=${BAZEL_REPOSITORY_CACHE}")
|
||||
fi
|
||||
|
||||
if [[ -n "${CODEX_BAZEL_EXECUTION_LOG_COMPACT_DIR:-}" ]]; then
|
||||
post_config_bazel_args+=(
|
||||
"--execution_log_compact_file=${CODEX_BAZEL_EXECUTION_LOG_COMPACT_DIR}/execution-log-${bazel_args[0]}-${GITHUB_JOB:-local}-$$.zst"
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ "${RUNNER_OS:-}" == "Windows" ]]; then
|
||||
|
||||
windows_action_env_vars=(
|
||||
INCLUDE
|
||||
LIB
|
||||
LIBPATH
|
||||
UCRTVersion
|
||||
UniversalCRTSdkDir
|
||||
VCINSTALLDIR
|
||||
VCToolsInstallDir
|
||||
WindowsLibPath
|
||||
WindowsSdkBinPath
|
||||
WindowsSdkDir
|
||||
WindowsSDKLibVersion
|
||||
WindowsSDKVersion
|
||||
)
|
||||
|
||||
for env_var in "${windows_action_env_vars[@]}"; do
|
||||
if [[ -n "${!env_var:-}" ]]; then
|
||||
post_config_bazel_args+=("--action_env=${env_var}" "--host_action_env=${env_var}")
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -n "${VOICE_WINDOWS_BAZEL_REPOSITORY:-}" ]]; then
|
||||
# Reuse the verified native audio inputs for local CI's voice targets.
|
||||
# These fixed values must be visible during Starlark analysis as well
|
||||
# as action execution; inherited --action_env values are insufficient.
|
||||
: "${VOICE_WINDOWS_SYSTEM_ROOT:?Windows SystemRoot is required}"
|
||||
: "${VOICE_WINDOWS_HOST_ARCH:?Windows host architecture is required}"
|
||||
# GNU-host lint jobs still need the LLVM linker for their build tools.
|
||||
if [[ $windows_msvc_host_platform -eq 1 ]]; then
|
||||
post_config_bazel_args+=("--config=ci-windows-msvc")
|
||||
fi
|
||||
post_config_bazel_args+=(
|
||||
"--workspace_status_command=./scripts/workspace-status.cmd"
|
||||
"--extra_toolchains=//third_party/voice:windows_pkg_config_toolchain,//third_party/voice:windows_cmake_toolchain"
|
||||
"--repo_env=BAZEL_MSVC_RUNTIME_VISUAL_STUDIO_EULA=1"
|
||||
"--inject_repository=voice_windows_tools=${VOICE_WINDOWS_BAZEL_REPOSITORY}"
|
||||
"--//third_party/voice:windows_installed_tools=@voice_windows_tools//:tools"
|
||||
"--action_env=SystemRoot=${VOICE_WINDOWS_SYSTEM_ROOT}"
|
||||
"--host_action_env=SystemRoot=${VOICE_WINDOWS_SYSTEM_ROOT}"
|
||||
"--action_env=PROCESSOR_ARCHITECTURE=${VOICE_WINDOWS_HOST_ARCH}"
|
||||
"--host_action_env=PROCESSOR_ARCHITECTURE=${VOICE_WINDOWS_HOST_ARCH}"
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ -z "${CODEX_BAZEL_WINDOWS_PATH:-}" ]]; then
|
||||
echo "CODEX_BAZEL_WINDOWS_PATH must be set for Windows Bazel CI." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
post_config_bazel_args+=(
|
||||
"--action_env=PATH=${CODEX_BAZEL_WINDOWS_PATH}"
|
||||
"--host_action_env=PATH=${CODEX_BAZEL_WINDOWS_PATH}"
|
||||
)
|
||||
post_config_bazel_args+=("--test_env=PATH=${CODEX_BAZEL_WINDOWS_PATH}")
|
||||
fi
|
||||
|
||||
bazel_console_log="$(mktemp)"
|
||||
trap 'rm -f "$bazel_console_log"' EXIT
|
||||
|
||||
bazel_run_args=(
|
||||
"${bazel_args[@]}"
|
||||
)
|
||||
if [[ "${bazel_args[0]}" == "test" ]]; then
|
||||
bazel_run_args+=("--test_env=INSTA_UPDATE=no")
|
||||
fi
|
||||
if (( ${#post_config_bazel_args[@]} > 0 )); then
|
||||
bazel_run_args+=("${post_config_bazel_args[@]}")
|
||||
fi
|
||||
set +e
|
||||
# Work around Bazel 9 remote repo contents cache / overlay materialization
|
||||
# failures seen in CI (for example "is not a symlink" or permission errors
|
||||
# while materializing external repos such as rules_perl). This only disables
|
||||
# the startup-level repo contents cache.
|
||||
run_bazel_with_startup_args \
|
||||
--noexperimental_remote_repo_contents_cache \
|
||||
"${bazel_run_args[@]}" \
|
||||
-- \
|
||||
"${bazel_targets[@]}" \
|
||||
2>&1 | tee "$bazel_console_log"
|
||||
bazel_status=${PIPESTATUS[0]}
|
||||
set -e
|
||||
|
||||
if [[ ${bazel_status:-0} -ne 0 ]]; then
|
||||
if [[ $print_failed_bazel_action_summary -eq 1 ]]; then
|
||||
print_bazel_action_failure_summary "$bazel_console_log"
|
||||
fi
|
||||
if [[ $print_failed_bazel_test_logs -eq 1 ]]; then
|
||||
print_bazel_test_log_tails "$bazel_console_log"
|
||||
fi
|
||||
exit "$bazel_status"
|
||||
fi
|
||||
42
.github/scripts/run-bazel-query-ci.sh
vendored
Executable file
42
.github/scripts/run-bazel-query-ci.sh
vendored
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Run target-discovery queries with the same startup settings as the main
|
||||
# build/test invocation so they can reuse the same Bazel server. Queries only
|
||||
# enumerate labels, so they intentionally do not select a CI build/test config
|
||||
# or remote execution.
|
||||
|
||||
if [[ $# -lt 2 || "${@: -2:1}" != "--" ]]; then
|
||||
echo "Usage: $0 [<bazel query args>...] -- <query expression>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
query_args=("${@:1:$#-2}")
|
||||
query_expression="${@: -1}"
|
||||
|
||||
run_bazel() {
|
||||
if [[ "${RUNNER_OS:-}" == "Windows" ]]; then
|
||||
MSYS2_ARG_CONV_EXCL='*' "$(dirname "${BASH_SOURCE[0]}")/run_bazel_with_buildbuddy.py" "$@"
|
||||
return
|
||||
fi
|
||||
|
||||
"$(dirname "${BASH_SOURCE[0]}")/run_bazel_with_buildbuddy.py" "$@"
|
||||
}
|
||||
|
||||
bazel_query_args=(query)
|
||||
|
||||
if [[ -n "${BAZEL_REPO_CONTENTS_CACHE:-}" ]]; then
|
||||
bazel_query_args+=("--repo_contents_cache=${BAZEL_REPO_CONTENTS_CACHE}")
|
||||
fi
|
||||
|
||||
if [[ -n "${BAZEL_REPOSITORY_CACHE:-}" ]]; then
|
||||
bazel_query_args+=("--repository_cache=${BAZEL_REPOSITORY_CACHE}")
|
||||
fi
|
||||
|
||||
if (( ${#query_args[@]} > 0 )); then
|
||||
bazel_query_args+=("${query_args[@]}")
|
||||
fi
|
||||
bazel_query_args+=("$query_expression")
|
||||
|
||||
run_bazel "${bazel_query_args[@]}"
|
||||
120
.github/scripts/run_bazel_with_buildbuddy.py
vendored
Executable file
120
.github/scripts/run_bazel_with_buildbuddy.py
vendored
Executable file
@@ -0,0 +1,120 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from collections.abc import Mapping
|
||||
from collections.abc import Sequence
|
||||
|
||||
|
||||
# These configs select remote execution, which is unavailable on CI runners.
|
||||
REMOTE_EXECUTION_CONFIGS = {
|
||||
"--config=ci-linux",
|
||||
"--config=ci-macos",
|
||||
"--config=ci-v8",
|
||||
"--config=ci-windows-cross",
|
||||
}
|
||||
# Honor either explicit setting so the wrapper never overrides the caller's
|
||||
# choice when it supplies the CI default below.
|
||||
REMOTE_REPO_CONTENTS_CACHE_STARTUP_OPTIONS = {
|
||||
"--experimental_remote_repo_contents_cache",
|
||||
"--noexperimental_remote_repo_contents_cache",
|
||||
}
|
||||
|
||||
|
||||
def startup_args(args: Sequence[str], env: Mapping[str, str]) -> list[str]:
|
||||
"""Return shared startup options that are missing from a Bazel invocation.
|
||||
|
||||
Bazel startup options must precede the command, and changing them restarts
|
||||
the server and discards its analysis cache. GitHub Actions invokes Bazel
|
||||
through several helpers, so normalize their startup options here while
|
||||
preserving any explicit choice made by the caller.
|
||||
"""
|
||||
command_idx = next(
|
||||
(idx for idx, arg in enumerate(args) if not arg.startswith("-")),
|
||||
len(args),
|
||||
)
|
||||
configured_startup_args = args[:command_idx]
|
||||
injected_args = []
|
||||
|
||||
output_user_root = env.get("BAZEL_OUTPUT_USER_ROOT")
|
||||
if output_user_root and not any(
|
||||
arg.startswith("--output_user_root=") for arg in configured_startup_args
|
||||
):
|
||||
injected_args.append(f"--output_user_root={output_user_root}")
|
||||
|
||||
if env.get("GITHUB_ACTIONS") == "true" and not any(
|
||||
arg in REMOTE_REPO_CONTENTS_CACHE_STARTUP_OPTIONS
|
||||
for arg in configured_startup_args
|
||||
):
|
||||
# Work around Bazel 9 overlay materialization failures seen in CI. This
|
||||
# disables only the startup-level repo contents cache.
|
||||
injected_args.append("--noexperimental_remote_repo_contents_cache")
|
||||
|
||||
return injected_args
|
||||
|
||||
|
||||
def bazel_args_without_remote_execution(args: Sequence[str]) -> list[str]:
|
||||
try:
|
||||
separator_idx = args.index("--")
|
||||
except ValueError:
|
||||
separator_idx = len(args)
|
||||
return [
|
||||
*(arg for arg in args[:separator_idx] if arg not in REMOTE_EXECUTION_CONFIGS),
|
||||
*args[separator_idx:],
|
||||
]
|
||||
|
||||
|
||||
def bazel_args_with_remote_config(
|
||||
args: Sequence[str], env: Mapping[str, str]
|
||||
) -> list[str]:
|
||||
command_idx = next(
|
||||
(idx for idx, arg in enumerate(args) if not arg.startswith("-")),
|
||||
None,
|
||||
)
|
||||
if command_idx is None:
|
||||
raise ValueError("expected a Bazel command")
|
||||
|
||||
configured_args = bazel_args_without_remote_execution(args)
|
||||
try:
|
||||
separator_idx = configured_args.index("--")
|
||||
except ValueError:
|
||||
separator_idx = len(configured_args)
|
||||
|
||||
cache_args = [
|
||||
f"{option_prefix}{env[env_name]}"
|
||||
for env_name, option_prefix in (
|
||||
("BAZEL_REPO_CONTENTS_CACHE", "--repo_contents_cache="),
|
||||
("BAZEL_REPOSITORY_CACHE", "--repository_cache="),
|
||||
)
|
||||
if env.get(env_name)
|
||||
and not any(
|
||||
arg.startswith(option_prefix) for arg in configured_args[:separator_idx]
|
||||
)
|
||||
]
|
||||
return [
|
||||
*configured_args[:separator_idx],
|
||||
*cache_args,
|
||||
*configured_args[separator_idx:],
|
||||
]
|
||||
|
||||
|
||||
def bazel_command(*args: str, env: Mapping[str, str] | None = None) -> list[str]:
|
||||
env = os.environ if env is None else env
|
||||
bazel = env.get("CODEX_BAZEL_BIN", "bazel")
|
||||
return [bazel, *startup_args(args, env), *bazel_args_with_remote_config(args, env)]
|
||||
|
||||
|
||||
def main() -> None:
|
||||
command = bazel_command(*sys.argv[1:])
|
||||
if os.name == "nt":
|
||||
# Windows CRT exec can split arguments containing spaces and lose the
|
||||
# eventual child exit status. Wait for Bazel and propagate its status.
|
||||
result = subprocess.run(command, check=False)
|
||||
raise SystemExit(result.returncode)
|
||||
|
||||
os.execvp(command[0], command)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
401
.github/scripts/rusty_v8_bazel.py
vendored
Normal file
401
.github/scripts/rusty_v8_bazel.py
vendored
Normal file
@@ -0,0 +1,401 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import gzip
|
||||
import hashlib
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
from run_bazel_with_buildbuddy import bazel_command
|
||||
from rusty_v8_module_bazel import (
|
||||
RustyV8ChecksumError,
|
||||
check_module_bazel,
|
||||
rusty_v8_http_file_versions,
|
||||
update_module_bazel,
|
||||
)
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
MODULE_BAZEL = ROOT / "MODULE.bazel"
|
||||
RUSTY_V8_CHECKSUMS_DIR = ROOT / "third_party" / "v8"
|
||||
RELEASE_ARTIFACT_PROFILE = "release"
|
||||
SANDBOX_ARTIFACT_PROFILE = "ptrcomp_sandbox_release"
|
||||
|
||||
|
||||
def bazel_execroot() -> Path:
|
||||
output = subprocess.check_output(
|
||||
bazel_command("info", "execution_root"),
|
||||
cwd=ROOT,
|
||||
text=True,
|
||||
)
|
||||
return Path(output.strip())
|
||||
|
||||
|
||||
def bazel_output_base() -> Path:
|
||||
output = subprocess.check_output(
|
||||
bazel_command("info", "output_base"),
|
||||
cwd=ROOT,
|
||||
text=True,
|
||||
)
|
||||
return Path(output.strip())
|
||||
|
||||
|
||||
def bazel_output_path(path: str) -> Path:
|
||||
if path.startswith("external/"):
|
||||
return bazel_output_base() / path
|
||||
return bazel_execroot() / path
|
||||
|
||||
|
||||
def bazel_output_files(
|
||||
platform: str,
|
||||
labels: list[str],
|
||||
compilation_mode: str = "fastbuild",
|
||||
bazel_configs: list[str] | None = None,
|
||||
) -> list[Path]:
|
||||
expression = "set(" + " ".join(labels) + ")"
|
||||
bazel_configs = bazel_configs or []
|
||||
output = subprocess.check_output(
|
||||
bazel_command(
|
||||
"cquery",
|
||||
"-c",
|
||||
compilation_mode,
|
||||
f"--platforms=@llvm//platforms:{platform}",
|
||||
*[f"--config={config}" for config in bazel_configs],
|
||||
"--output=files",
|
||||
expression,
|
||||
),
|
||||
cwd=ROOT,
|
||||
text=True,
|
||||
)
|
||||
return [
|
||||
bazel_output_path(line.strip()) for line in output.splitlines() if line.strip()
|
||||
]
|
||||
|
||||
|
||||
def bazel_build(
|
||||
platform: str,
|
||||
labels: list[str],
|
||||
compilation_mode: str = "fastbuild",
|
||||
bazel_configs: list[str] | None = None,
|
||||
download_toplevel: bool = False,
|
||||
) -> None:
|
||||
bazel_configs = bazel_configs or []
|
||||
download_args = ["--remote_download_toplevel"] if download_toplevel else []
|
||||
subprocess.run(
|
||||
bazel_command(
|
||||
"build",
|
||||
"-c",
|
||||
compilation_mode,
|
||||
f"--platforms=@llvm//platforms:{platform}",
|
||||
*[f"--config={config}" for config in bazel_configs],
|
||||
*download_args,
|
||||
*labels,
|
||||
),
|
||||
cwd=ROOT,
|
||||
check=True,
|
||||
)
|
||||
|
||||
|
||||
def ensure_bazel_output_files(
|
||||
platform: str,
|
||||
labels: list[str],
|
||||
compilation_mode: str = "fastbuild",
|
||||
bazel_configs: list[str] | None = None,
|
||||
) -> list[Path]:
|
||||
# Bazel output paths can be reused across config flips, so existence alone
|
||||
# does not prove the files match the requested flags.
|
||||
bazel_build(
|
||||
platform,
|
||||
labels,
|
||||
compilation_mode,
|
||||
bazel_configs,
|
||||
download_toplevel=True,
|
||||
)
|
||||
outputs = bazel_output_files(platform, labels, compilation_mode, bazel_configs)
|
||||
missing = [str(path) for path in outputs if not path.exists()]
|
||||
if missing:
|
||||
raise SystemExit(f"missing built outputs for {labels}: {missing}")
|
||||
return outputs
|
||||
|
||||
|
||||
def release_pair_label(target: str, sandbox: bool = False) -> str:
|
||||
target_suffix = target.replace("-", "_")
|
||||
pair_kind = "sandbox_release_pair" if sandbox else "release_pair"
|
||||
return f"//third_party/v8:rusty_v8_{pair_kind}_{target_suffix}"
|
||||
|
||||
|
||||
def resolved_v8_crate_version() -> str:
|
||||
cargo_lock = tomllib.loads((ROOT / "codex-rs" / "Cargo.lock").read_text())
|
||||
versions = sorted(
|
||||
{
|
||||
package["version"]
|
||||
for package in cargo_lock["package"]
|
||||
if package["name"] == "v8"
|
||||
}
|
||||
)
|
||||
if len(versions) == 1:
|
||||
return versions[0]
|
||||
if len(versions) > 1:
|
||||
raise SystemExit(f"expected exactly one resolved v8 version, found: {versions}")
|
||||
|
||||
module_bazel = (ROOT / "MODULE.bazel").read_text()
|
||||
matches = sorted(
|
||||
set(
|
||||
re.findall(
|
||||
r"https://static\.crates\.io/crates/v8/v8-([0-9]+\.[0-9]+\.[0-9]+)\.crate",
|
||||
module_bazel,
|
||||
)
|
||||
)
|
||||
)
|
||||
if len(matches) != 1:
|
||||
raise SystemExit(
|
||||
"expected exactly one pinned v8 crate version in MODULE.bazel, "
|
||||
f"found: {matches}"
|
||||
)
|
||||
return matches[0]
|
||||
|
||||
|
||||
def rusty_v8_checksum_manifest_path(version: str) -> Path:
|
||||
return RUSTY_V8_CHECKSUMS_DIR / f"rusty_v8_{version.replace('.', '_')}.sha256"
|
||||
|
||||
|
||||
def command_version(version: str | None) -> str:
|
||||
if version is not None:
|
||||
return version
|
||||
|
||||
manifest_versions = rusty_v8_http_file_versions(MODULE_BAZEL.read_text())
|
||||
if len(manifest_versions) == 1:
|
||||
return manifest_versions[0]
|
||||
if len(manifest_versions) > 1:
|
||||
raise SystemExit(
|
||||
"expected at most one rusty_v8 http_file version in MODULE.bazel, "
|
||||
f"found: {manifest_versions}; pass --version explicitly"
|
||||
)
|
||||
|
||||
return resolved_v8_crate_version()
|
||||
|
||||
|
||||
def command_manifest_path(manifest: Path | None, version: str) -> Path:
|
||||
if manifest is None:
|
||||
return rusty_v8_checksum_manifest_path(version)
|
||||
if manifest.is_absolute():
|
||||
return manifest
|
||||
return ROOT / manifest
|
||||
|
||||
|
||||
def staged_archive_name(target: str, source_path: Path, artifact_profile: str) -> str:
|
||||
if target.endswith("-pc-windows-msvc"):
|
||||
return f"rusty_v8_{artifact_profile}_{target}.lib.gz"
|
||||
return f"librusty_v8_{artifact_profile}_{target}.a.gz"
|
||||
|
||||
|
||||
def staged_binding_name(target: str, artifact_profile: str) -> str:
|
||||
return f"src_binding_{artifact_profile}_{target}.rs"
|
||||
|
||||
|
||||
def staged_checksums_name(target: str, artifact_profile: str) -> str:
|
||||
return f"rusty_v8_{artifact_profile}_{target}.sha256"
|
||||
|
||||
|
||||
def stage_artifacts(
|
||||
target: str,
|
||||
lib_path: Path,
|
||||
binding_path: Path,
|
||||
output_dir: Path,
|
||||
sandbox: bool,
|
||||
) -> None:
|
||||
missing_paths = [
|
||||
str(path) for path in [lib_path, binding_path] if not path.exists()
|
||||
]
|
||||
if missing_paths:
|
||||
raise SystemExit(f"missing release outputs for {target}: {missing_paths}")
|
||||
|
||||
output_dir.mkdir(parents=True, exist_ok=True)
|
||||
artifact_profile = SANDBOX_ARTIFACT_PROFILE if sandbox else RELEASE_ARTIFACT_PROFILE
|
||||
staged_library = output_dir / staged_archive_name(
|
||||
target, lib_path, artifact_profile
|
||||
)
|
||||
staged_binding = output_dir / staged_binding_name(target, artifact_profile)
|
||||
|
||||
with lib_path.open("rb") as src, staged_library.open("wb") as dst:
|
||||
with gzip.GzipFile(
|
||||
filename="",
|
||||
mode="wb",
|
||||
fileobj=dst,
|
||||
compresslevel=6,
|
||||
mtime=0,
|
||||
) as gz:
|
||||
shutil.copyfileobj(src, gz)
|
||||
|
||||
shutil.copyfile(binding_path, staged_binding)
|
||||
|
||||
staged_checksums = output_dir / staged_checksums_name(target, artifact_profile)
|
||||
with staged_checksums.open("w", encoding="utf-8", newline="\n") as checksums:
|
||||
for path in [staged_library, staged_binding]:
|
||||
digest = hashlib.sha256()
|
||||
with path.open("rb") as artifact:
|
||||
for chunk in iter(lambda: artifact.read(1024 * 1024), b""):
|
||||
digest.update(chunk)
|
||||
checksums.write(f"{digest.hexdigest()} {path.name}\n")
|
||||
|
||||
print(staged_library)
|
||||
print(staged_binding)
|
||||
print(staged_checksums)
|
||||
|
||||
|
||||
def upstream_release_pair_paths(
|
||||
target: str,
|
||||
target_dir: Path,
|
||||
) -> tuple[Path, Path]:
|
||||
lib_name = (
|
||||
"rusty_v8.lib" if target.endswith("-pc-windows-msvc") else "librusty_v8.a"
|
||||
)
|
||||
gn_out = target_dir / target / "release" / "gn_out"
|
||||
return gn_out / "obj" / lib_name, gn_out / "src_binding.rs"
|
||||
|
||||
|
||||
def stage_upstream_release_pair(
|
||||
target: str,
|
||||
output_dir: Path,
|
||||
target_dir: Path,
|
||||
sandbox: bool = False,
|
||||
) -> None:
|
||||
lib_path, binding_path = upstream_release_pair_paths(
|
||||
target,
|
||||
target_dir,
|
||||
)
|
||||
stage_artifacts(target, lib_path, binding_path, output_dir, sandbox)
|
||||
|
||||
|
||||
def stage_release_pair(
|
||||
platform: str,
|
||||
target: str,
|
||||
output_dir: Path,
|
||||
compilation_mode: str = "fastbuild",
|
||||
bazel_configs: list[str] | None = None,
|
||||
sandbox: bool = False,
|
||||
) -> None:
|
||||
outputs = ensure_bazel_output_files(
|
||||
platform,
|
||||
[release_pair_label(target, sandbox)],
|
||||
compilation_mode,
|
||||
bazel_configs,
|
||||
)
|
||||
|
||||
try:
|
||||
lib_path = next(path for path in outputs if path.suffix in {".a", ".lib"})
|
||||
except StopIteration as exc:
|
||||
raise SystemExit(f"missing static library output for {target}") from exc
|
||||
|
||||
try:
|
||||
binding_path = next(path for path in outputs if path.suffix == ".rs")
|
||||
except StopIteration as exc:
|
||||
raise SystemExit(f"missing Rust binding output for {target}") from exc
|
||||
|
||||
stage_artifacts(target, lib_path, binding_path, output_dir, sandbox)
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser()
|
||||
subparsers = parser.add_subparsers(dest="command", required=True)
|
||||
|
||||
stage_release_pair_parser = subparsers.add_parser("stage-release-pair")
|
||||
stage_release_pair_parser.add_argument("--platform", required=True)
|
||||
stage_release_pair_parser.add_argument("--target", required=True)
|
||||
stage_release_pair_parser.add_argument("--output-dir", required=True)
|
||||
stage_release_pair_parser.add_argument("--sandbox", action="store_true")
|
||||
stage_release_pair_parser.add_argument(
|
||||
"--bazel-config",
|
||||
action="append",
|
||||
default=[],
|
||||
dest="bazel_configs",
|
||||
)
|
||||
stage_release_pair_parser.add_argument(
|
||||
"--compilation-mode",
|
||||
default="fastbuild",
|
||||
choices=["fastbuild", "opt", "dbg"],
|
||||
)
|
||||
|
||||
stage_upstream_release_pair_parser = subparsers.add_parser(
|
||||
"stage-upstream-release-pair"
|
||||
)
|
||||
stage_upstream_release_pair_parser.add_argument(
|
||||
"--target-dir", type=Path, required=True
|
||||
)
|
||||
stage_upstream_release_pair_parser.add_argument("--target", required=True)
|
||||
stage_upstream_release_pair_parser.add_argument("--output-dir", required=True)
|
||||
stage_upstream_release_pair_parser.add_argument("--sandbox", action="store_true")
|
||||
|
||||
subparsers.add_parser("resolved-v8-crate-version")
|
||||
|
||||
check_module_bazel_parser = subparsers.add_parser("check-module-bazel")
|
||||
check_module_bazel_parser.add_argument("--version")
|
||||
check_module_bazel_parser.add_argument("--manifest", type=Path)
|
||||
check_module_bazel_parser.add_argument(
|
||||
"--module-bazel",
|
||||
type=Path,
|
||||
default=MODULE_BAZEL,
|
||||
)
|
||||
|
||||
update_module_bazel_parser = subparsers.add_parser("update-module-bazel")
|
||||
update_module_bazel_parser.add_argument("--version")
|
||||
update_module_bazel_parser.add_argument("--manifest", type=Path)
|
||||
update_module_bazel_parser.add_argument(
|
||||
"--module-bazel",
|
||||
type=Path,
|
||||
default=MODULE_BAZEL,
|
||||
)
|
||||
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
args = parse_args()
|
||||
if args.command == "stage-release-pair":
|
||||
stage_release_pair(
|
||||
platform=args.platform,
|
||||
target=args.target,
|
||||
output_dir=Path(args.output_dir),
|
||||
compilation_mode=args.compilation_mode,
|
||||
bazel_configs=args.bazel_configs,
|
||||
sandbox=args.sandbox,
|
||||
)
|
||||
return 0
|
||||
if args.command == "stage-upstream-release-pair":
|
||||
stage_upstream_release_pair(
|
||||
target=args.target,
|
||||
output_dir=Path(args.output_dir),
|
||||
target_dir=args.target_dir,
|
||||
sandbox=args.sandbox,
|
||||
)
|
||||
return 0
|
||||
if args.command == "resolved-v8-crate-version":
|
||||
print(resolved_v8_crate_version())
|
||||
return 0
|
||||
if args.command == "check-module-bazel":
|
||||
version = command_version(args.version)
|
||||
manifest_path = command_manifest_path(args.manifest, version)
|
||||
try:
|
||||
check_module_bazel(args.module_bazel, manifest_path, version)
|
||||
except RustyV8ChecksumError as exc:
|
||||
raise SystemExit(str(exc)) from exc
|
||||
return 0
|
||||
if args.command == "update-module-bazel":
|
||||
version = command_version(args.version)
|
||||
manifest_path = command_manifest_path(args.manifest, version)
|
||||
try:
|
||||
update_module_bazel(args.module_bazel, manifest_path, version)
|
||||
except RustyV8ChecksumError as exc:
|
||||
raise SystemExit(str(exc)) from exc
|
||||
return 0
|
||||
raise SystemExit(f"unsupported command: {args.command}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
243
.github/scripts/rusty_v8_module_bazel.py
vendored
Normal file
243
.github/scripts/rusty_v8_module_bazel.py
vendored
Normal file
@@ -0,0 +1,243 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
SHA256_RE = re.compile(r"[0-9a-f]{64}")
|
||||
HTTP_FILE_BLOCK_RE = re.compile(r"(?ms)^http_file\(\n.*?^\)\n?")
|
||||
HTTP_FILE_VERSION_RE = re.compile(r"^rusty_v8_([0-9]+)_([0-9]+)_([0-9]+)_")
|
||||
|
||||
|
||||
class RustyV8ChecksumError(ValueError):
|
||||
pass
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RustyV8HttpFile:
|
||||
start: int
|
||||
end: int
|
||||
block: str
|
||||
name: str
|
||||
downloaded_file_path: str
|
||||
sha256: str | None
|
||||
|
||||
|
||||
def parse_checksum_manifest(path: Path) -> dict[str, str]:
|
||||
try:
|
||||
lines = path.read_text(encoding="utf-8").splitlines()
|
||||
except FileNotFoundError as exc:
|
||||
raise RustyV8ChecksumError(f"missing checksum manifest: {path}") from exc
|
||||
|
||||
checksums: dict[str, str] = {}
|
||||
for line_number, line in enumerate(lines, 1):
|
||||
if not line.strip():
|
||||
continue
|
||||
parts = line.split()
|
||||
if len(parts) != 2:
|
||||
raise RustyV8ChecksumError(
|
||||
f"{path}:{line_number}: expected '<sha256> <filename>'"
|
||||
)
|
||||
checksum, filename = parts
|
||||
if not SHA256_RE.fullmatch(checksum):
|
||||
raise RustyV8ChecksumError(
|
||||
f"{path}:{line_number}: invalid SHA-256 digest for {filename}"
|
||||
)
|
||||
if not filename or filename in {".", ".."} or "/" in filename:
|
||||
raise RustyV8ChecksumError(
|
||||
f"{path}:{line_number}: expected a bare artifact filename"
|
||||
)
|
||||
if filename in checksums:
|
||||
raise RustyV8ChecksumError(
|
||||
f"{path}:{line_number}: duplicate checksum for {filename}"
|
||||
)
|
||||
checksums[filename] = checksum
|
||||
|
||||
if not checksums:
|
||||
raise RustyV8ChecksumError(f"empty checksum manifest: {path}")
|
||||
return checksums
|
||||
|
||||
|
||||
def string_field(block: str, field: str) -> str | None:
|
||||
# Matches one-line string fields inside http_file blocks, e.g. `sha256 = "...",`.
|
||||
match = re.search(rf'^\s*{re.escape(field)}\s*=\s*"([^"]+)",\s*$', block, re.M)
|
||||
if match:
|
||||
return match.group(1)
|
||||
return None
|
||||
|
||||
|
||||
def rusty_v8_http_files(module_bazel: str, version: str) -> list[RustyV8HttpFile]:
|
||||
version_slug = version.replace(".", "_")
|
||||
name_prefix = f"rusty_v8_{version_slug}_"
|
||||
entries = []
|
||||
for match in HTTP_FILE_BLOCK_RE.finditer(module_bazel):
|
||||
block = match.group(0)
|
||||
name = string_field(block, "name")
|
||||
if not name or not name.startswith(name_prefix):
|
||||
continue
|
||||
downloaded_file_path = string_field(block, "downloaded_file_path")
|
||||
if not downloaded_file_path:
|
||||
raise RustyV8ChecksumError(
|
||||
f"MODULE.bazel {name} is missing downloaded_file_path"
|
||||
)
|
||||
entries.append(
|
||||
RustyV8HttpFile(
|
||||
start=match.start(),
|
||||
end=match.end(),
|
||||
block=block,
|
||||
name=name,
|
||||
downloaded_file_path=downloaded_file_path,
|
||||
sha256=string_field(block, "sha256"),
|
||||
)
|
||||
)
|
||||
return entries
|
||||
|
||||
|
||||
def rusty_v8_http_file_versions(module_bazel: str) -> list[str]:
|
||||
versions = set()
|
||||
for match in HTTP_FILE_BLOCK_RE.finditer(module_bazel):
|
||||
name = string_field(match.group(0), "name")
|
||||
if not name:
|
||||
continue
|
||||
version_match = HTTP_FILE_VERSION_RE.match(name)
|
||||
if version_match:
|
||||
versions.add(".".join(version_match.groups()))
|
||||
return sorted(versions)
|
||||
|
||||
|
||||
def module_entry_set_errors(
|
||||
entries: list[RustyV8HttpFile],
|
||||
checksums: dict[str, str],
|
||||
version: str,
|
||||
) -> list[str]:
|
||||
errors = []
|
||||
if not entries:
|
||||
errors.append(f"MODULE.bazel has no rusty_v8 http_file entries for {version}")
|
||||
return errors
|
||||
|
||||
module_files: dict[str, RustyV8HttpFile] = {}
|
||||
duplicate_files = set()
|
||||
for entry in entries:
|
||||
if entry.downloaded_file_path in module_files:
|
||||
duplicate_files.add(entry.downloaded_file_path)
|
||||
module_files[entry.downloaded_file_path] = entry
|
||||
|
||||
for filename in sorted(duplicate_files):
|
||||
errors.append(f"MODULE.bazel has duplicate http_file entries for {filename}")
|
||||
|
||||
for filename in sorted(set(module_files) - set(checksums)):
|
||||
entry = module_files[filename]
|
||||
errors.append(f"MODULE.bazel {entry.name} has no checksum in the manifest")
|
||||
|
||||
for filename in sorted(set(checksums) - set(module_files)):
|
||||
errors.append(f"manifest has {filename}, but MODULE.bazel has no http_file")
|
||||
|
||||
return errors
|
||||
|
||||
|
||||
def module_checksum_errors(
|
||||
entries: list[RustyV8HttpFile],
|
||||
checksums: dict[str, str],
|
||||
) -> list[str]:
|
||||
errors = []
|
||||
for entry in entries:
|
||||
expected = checksums.get(entry.downloaded_file_path)
|
||||
if expected is None:
|
||||
continue
|
||||
if entry.sha256 is None:
|
||||
errors.append(f"MODULE.bazel {entry.name} is missing sha256")
|
||||
elif entry.sha256 != expected:
|
||||
errors.append(
|
||||
f"MODULE.bazel {entry.name} has sha256 {entry.sha256}, "
|
||||
f"expected {expected}"
|
||||
)
|
||||
return errors
|
||||
|
||||
|
||||
def raise_checksum_errors(message: str, errors: list[str]) -> None:
|
||||
if errors:
|
||||
formatted_errors = "\n".join(f"- {error}" for error in errors)
|
||||
raise RustyV8ChecksumError(f"{message}:\n{formatted_errors}")
|
||||
|
||||
|
||||
def check_module_bazel_text(
|
||||
module_bazel: str,
|
||||
checksums: dict[str, str],
|
||||
version: str,
|
||||
) -> None:
|
||||
entries = rusty_v8_http_files(module_bazel, version)
|
||||
errors = [
|
||||
*module_entry_set_errors(entries, checksums, version),
|
||||
*module_checksum_errors(entries, checksums),
|
||||
]
|
||||
raise_checksum_errors("rusty_v8 MODULE.bazel checksum drift", errors)
|
||||
|
||||
|
||||
def block_with_sha256(block: str, checksum: str) -> str:
|
||||
sha256_line_re = re.compile(r'(?m)^(\s*)sha256\s*=\s*"[0-9a-f]+",\s*$')
|
||||
if sha256_line_re.search(block):
|
||||
return sha256_line_re.sub(
|
||||
lambda match: f'{match.group(1)}sha256 = "{checksum}",',
|
||||
block,
|
||||
count=1,
|
||||
)
|
||||
|
||||
downloaded_file_path_match = re.search(
|
||||
r'(?m)^(\s*)downloaded_file_path\s*=\s*"[^"]+",\n',
|
||||
block,
|
||||
)
|
||||
if not downloaded_file_path_match:
|
||||
raise RustyV8ChecksumError("http_file block is missing downloaded_file_path")
|
||||
insert_at = downloaded_file_path_match.end()
|
||||
indent = downloaded_file_path_match.group(1)
|
||||
return f'{block[:insert_at]}{indent}sha256 = "{checksum}",\n{block[insert_at:]}'
|
||||
|
||||
|
||||
def update_module_bazel_text(
|
||||
module_bazel: str,
|
||||
checksums: dict[str, str],
|
||||
version: str,
|
||||
) -> str:
|
||||
entries = rusty_v8_http_files(module_bazel, version)
|
||||
errors = module_entry_set_errors(entries, checksums, version)
|
||||
raise_checksum_errors("cannot update rusty_v8 MODULE.bazel checksums", errors)
|
||||
|
||||
updated = []
|
||||
previous_end = 0
|
||||
for entry in entries:
|
||||
updated.append(module_bazel[previous_end : entry.start])
|
||||
updated.append(
|
||||
block_with_sha256(entry.block, checksums[entry.downloaded_file_path])
|
||||
)
|
||||
previous_end = entry.end
|
||||
updated.append(module_bazel[previous_end:])
|
||||
return "".join(updated)
|
||||
|
||||
|
||||
def check_module_bazel(
|
||||
module_bazel_path: Path,
|
||||
manifest_path: Path,
|
||||
version: str,
|
||||
) -> None:
|
||||
checksums = parse_checksum_manifest(manifest_path)
|
||||
module_bazel = module_bazel_path.read_text(encoding="utf-8")
|
||||
check_module_bazel_text(module_bazel, checksums, version)
|
||||
print(f"{module_bazel_path} rusty_v8 {version} checksums match {manifest_path}")
|
||||
|
||||
|
||||
def update_module_bazel(
|
||||
module_bazel_path: Path,
|
||||
manifest_path: Path,
|
||||
version: str,
|
||||
) -> None:
|
||||
checksums = parse_checksum_manifest(manifest_path)
|
||||
module_bazel = module_bazel_path.read_text(encoding="utf-8")
|
||||
updated_module_bazel = update_module_bazel_text(module_bazel, checksums, version)
|
||||
if updated_module_bazel == module_bazel:
|
||||
print(f"{module_bazel_path} rusty_v8 {version} checksums are already current")
|
||||
return
|
||||
module_bazel_path.write_text(updated_module_bazel, encoding="utf-8")
|
||||
print(f"updated {module_bazel_path} rusty_v8 {version} checksums")
|
||||
103
.github/scripts/select_windows_bazel_targets.py
vendored
Normal file
103
.github/scripts/select_windows_bazel_targets.py
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Assign Windows Bazel test targets using checked-in duration estimates."""
|
||||
|
||||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
DEFAULT_DURATION_SECONDS = 1
|
||||
DURATIONS_PATH = Path(__file__).with_name("windows_bazel_test_durations.tsv")
|
||||
|
||||
|
||||
def read_durations(path: Path) -> dict[str, int]:
|
||||
durations = {}
|
||||
for line_number, line in enumerate(
|
||||
path.read_text(encoding="utf-8").splitlines(), 1
|
||||
):
|
||||
if not line.strip() or line.lstrip().startswith("#"):
|
||||
continue
|
||||
fields = line.split("\t")
|
||||
if len(fields) != 2 or not fields[0] or not fields[1].isdecimal():
|
||||
raise ValueError(
|
||||
f"{path}:{line_number}: expected target<TAB>positive integer"
|
||||
)
|
||||
target, duration_text = fields
|
||||
duration = int(duration_text)
|
||||
if duration < 1:
|
||||
raise ValueError(f"{path}:{line_number}: duration must be positive")
|
||||
if target in durations:
|
||||
raise ValueError(f"{path}:{line_number}: duplicate target {target}")
|
||||
durations[target] = duration
|
||||
return durations
|
||||
|
||||
|
||||
def assign_targets(
|
||||
targets: list[str], durations: dict[str, int], shard_count: int
|
||||
) -> tuple[list[list[str]], list[int]]:
|
||||
if shard_count < 1:
|
||||
raise ValueError("shard count must be positive")
|
||||
if not targets:
|
||||
raise ValueError("no Bazel test targets were provided")
|
||||
if any(not target.strip() for target in targets):
|
||||
raise ValueError("Bazel test target labels must not be empty")
|
||||
if len(targets) != len(set(targets)):
|
||||
raise ValueError("duplicate Bazel test target labels were provided")
|
||||
|
||||
assignments: list[list[str]] = [[] for _ in range(shard_count)]
|
||||
loads = [0] * shard_count
|
||||
# Place the longest targets first, breaking ties by label and shard number.
|
||||
for target in sorted(
|
||||
targets,
|
||||
key=lambda target: (-durations.get(target, DEFAULT_DURATION_SECONDS), target),
|
||||
):
|
||||
shard = min(range(shard_count), key=lambda shard: (loads[shard], shard))
|
||||
assignments[shard].append(target)
|
||||
loads[shard] += durations.get(target, DEFAULT_DURATION_SECONDS)
|
||||
for assignment in assignments:
|
||||
assignment.sort()
|
||||
return assignments, loads
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--shard", required=True, type=int)
|
||||
parser.add_argument("--shard-count", required=True, type=int)
|
||||
parser.add_argument(
|
||||
"--durations",
|
||||
type=Path,
|
||||
default=DURATIONS_PATH,
|
||||
help="use this timing file instead of the checked-in default",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
if not 1 <= args.shard <= args.shard_count:
|
||||
parser.error("shard must be between 1 and shard count")
|
||||
|
||||
try:
|
||||
durations = read_durations(args.durations)
|
||||
targets = sys.stdin.read().splitlines()
|
||||
assignments, loads = assign_targets(targets, durations, args.shard_count)
|
||||
except (OSError, ValueError) as error:
|
||||
parser.error(str(error))
|
||||
|
||||
selected_targets = assignments[args.shard - 1]
|
||||
if not selected_targets:
|
||||
parser.error(
|
||||
f"no Bazel test targets selected for shard {args.shard}/{args.shard_count}"
|
||||
)
|
||||
|
||||
target_set = set(targets)
|
||||
print(
|
||||
f"Windows Bazel shards: targets={[len(assignment) for assignment in assignments]}, "
|
||||
f"estimated test-seconds={loads}, default weights={len(target_set - durations.keys())}, "
|
||||
f"unused weights={len(durations.keys() - target_set)}. "
|
||||
f"Selected shard {args.shard}/{args.shard_count}.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
# Keep LF delimiters when native Windows Python feeds Git Bash mapfile.
|
||||
sys.stdout.buffer.write(("\n".join(selected_targets) + "\n").encode("utf-8"))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
63
.github/scripts/setup-dev-drive.ps1
vendored
Normal file
63
.github/scripts/setup-dev-drive.ps1
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
# Configure a fast drive for Windows CI jobs.
|
||||
#
|
||||
# GitHub-hosted Windows runners do not always expose a secondary D: volume. When
|
||||
# they do not, create a Dev Drive VHD. CI depends on this path for its
|
||||
# build directories where CI spends significant time doing I/O, so fail the
|
||||
# job if no real Dev Drive is available.
|
||||
|
||||
function Test-DevDrive {
|
||||
param([string]$Drive)
|
||||
|
||||
& fsutil devdrv query $Drive *> $null
|
||||
return $LASTEXITCODE -eq 0
|
||||
}
|
||||
|
||||
function Invoke-BestEffort {
|
||||
param([scriptblock]$Script, [string]$Description)
|
||||
|
||||
try {
|
||||
& $Script
|
||||
} catch {
|
||||
Write-Warning "$Description failed: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
if ((Test-Path "D:\") -and (Test-DevDrive "D:")) {
|
||||
Write-Output "Using existing Dev Drive at D:"
|
||||
$Drive = "D:"
|
||||
} else {
|
||||
if (Test-Path "D:\") {
|
||||
Write-Output "Existing D: volume is not a Dev Drive; provisioning a new Dev Drive VHD."
|
||||
}
|
||||
|
||||
try {
|
||||
$VhdPath = Join-Path $env:RUNNER_TEMP "codex-dev-drive.vhdx"
|
||||
$SizeBytes = 64GB
|
||||
|
||||
if (Test-Path $VhdPath) {
|
||||
Remove-Item -Path $VhdPath -Force
|
||||
}
|
||||
|
||||
New-VHD -Path $VhdPath -SizeBytes $SizeBytes -Dynamic -ErrorAction Stop | Out-Null
|
||||
$Mounted = Mount-VHD -Path $VhdPath -Passthru -ErrorAction Stop
|
||||
$Disk = $Mounted | Get-Disk -ErrorAction Stop
|
||||
$Disk | Initialize-Disk -PartitionStyle GPT -ErrorAction Stop
|
||||
$Partition = $Disk | New-Partition -AssignDriveLetter -UseMaximumSize -ErrorAction Stop
|
||||
$Volume = $Partition | Format-Volume -FileSystem ReFS -NewFileSystemLabel "CodexDevDrive" -DevDrive -Confirm:$false -Force -ErrorAction Stop
|
||||
|
||||
$Drive = "$($Volume.DriveLetter):"
|
||||
|
||||
if (-not (Test-DevDrive $Drive)) {
|
||||
throw "Provisioned volume at $Drive did not pass Dev Drive verification."
|
||||
}
|
||||
|
||||
Invoke-BestEffort { fsutil devdrv trust $Drive } "Trusting Dev Drive $Drive"
|
||||
Invoke-BestEffort { fsutil devdrv enable /disallowAv } "Disabling AV filter attachment for Dev Drives"
|
||||
|
||||
Write-Output "Using Dev Drive at $Drive"
|
||||
} catch {
|
||||
throw "Failed to create Dev Drive: $($_.Exception.Message)"
|
||||
}
|
||||
}
|
||||
|
||||
"CI_BUILD_ROOT=$Drive" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
96
.github/scripts/setup-voice-windows.ps1
vendored
Normal file
96
.github/scripts/setup-voice-windows.ps1
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
# CI-only prerequisites. Never install these tools into a Codex package.
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$Target,
|
||||
[Parameter(Mandatory = $true)][string]$SnapshotArchive
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$PkgHashes = @{
|
||||
"x86_64-pc-windows-msvc" = @("x64", "5604cf25ef38bb6a09520cff25ae9f0ecd8c2443053b15e40df4ad1eae0e4405")
|
||||
"aarch64-pc-windows-msvc" = @("arm64", "d5752ce2ac2296c8abb91fb12c12e75ee99ba8a18b52ce5febf325847b6f062b")
|
||||
}
|
||||
if (-not $PkgHashes.ContainsKey($Target)) { throw "Unsupported target: $Target" }
|
||||
$Root = Join-Path $env:RUNNER_TEMP "voice-windows-build-tools"
|
||||
$Evidence = Join-Path $Root "evidence"
|
||||
$Cygwin = Join-Path $Root "cygwin"
|
||||
$Cache = Join-Path $Root "cache"
|
||||
New-Item -ItemType Directory -Path $Root, $Evidence | Out-Null
|
||||
$ManifestPath = Join-Path $PSScriptRoot "voice-cygwin-snapshot.json"
|
||||
$Manifest = Get-Content -Raw $ManifestPath | ConvertFrom-Json
|
||||
$SnapshotTool = Join-Path $PSScriptRoot "voice-cygwin-inputs.py"
|
||||
& python $SnapshotTool extract --archive $SnapshotArchive --directory (Join-Path $Cache $Manifest.cacheDirectory)
|
||||
if ($LASTEXITCODE -ne 0) { throw "Cygwin snapshot could not be verified and extracted" }
|
||||
Copy-Item $ManifestPath (Join-Path $Evidence "cygwin-snapshot.json")
|
||||
|
||||
# Official https://cygwin.com/setup/sha512.sum and pkgconf release asset digests.
|
||||
# The complete package closure is pinned separately in cygwin-snapshot.json.
|
||||
$Inputs = @(
|
||||
@{
|
||||
url = "https://cygwin.com/setup/setup-2.937.x86_64.exe"
|
||||
file = "setup.exe"
|
||||
algorithm = "SHA512"
|
||||
digest = "6acea47c59781c9e7f544a18d53935d59df6e44d5d52ac95ee165671b8e388820455eebf30ccc7d254b00c3d0eb694269a0f8dc84b17944c1f355dac9c5aafcc"
|
||||
},
|
||||
@{
|
||||
url = "https://github.com/pkgconf/pkgconf/releases/download/pkgconf-3.0.6/pkgconf-$($PkgHashes[$Target][0])-3.0.6.msi"
|
||||
file = "pkgconf.msi"
|
||||
algorithm = "SHA256"
|
||||
digest = $PkgHashes[$Target][1]
|
||||
}
|
||||
)
|
||||
foreach ($InputFile in $Inputs) {
|
||||
$Destination = Join-Path $Root $InputFile.file
|
||||
Invoke-WebRequest -Uri $InputFile.url -OutFile $Destination
|
||||
$Actual = (Get-FileHash -Path $Destination -Algorithm $InputFile.algorithm).Hash.ToLowerInvariant()
|
||||
if ($Actual -ne $InputFile.digest) { throw "Build input digest mismatch: $($InputFile.file)" }
|
||||
}
|
||||
$Inputs | ConvertTo-Json | Set-Content (Join-Path $Evidence "bootstrap-inputs.json")
|
||||
$Packages = $Manifest.requestedPackages -join ","
|
||||
# Only setup.xz + setup.xz.sig are present: local mode still verifies that
|
||||
# signature. Never substitute an unsigned setup.ini or enable a network fallback.
|
||||
$Setup = Start-Process -FilePath (Join-Path $Root "setup.exe") -Wait -PassThru -ArgumentList @(
|
||||
"--quiet-mode", "--no-admin", "--no-shortcuts", "--only-site",
|
||||
"--local-install", "--no-version-check",
|
||||
"--root", "`"$Cygwin`"", "--local-package-dir", "`"$Cache`"",
|
||||
"--packages", $Packages
|
||||
)
|
||||
if ($Setup.ExitCode -ne 0) { throw "Cygwin setup failed: $($Setup.ExitCode)" }
|
||||
Copy-Item (Join-Path $Cygwin "var/log/setup.log*") $Evidence
|
||||
Copy-Item (Join-Path $Cygwin "etc/setup/installed.db") $Evidence
|
||||
& (Join-Path $Cygwin "bin/cygcheck.exe") -cd | Set-Content (Join-Path $Evidence "packages.txt")
|
||||
if ($LASTEXITCODE -ne 0) { throw "Cannot inventory Cygwin packages" }
|
||||
& python $SnapshotTool check-installed --inventory (Join-Path $Evidence "packages.txt")
|
||||
if ($LASTEXITCODE -ne 0) { throw "Installed Cygwin package set differs from the snapshot" }
|
||||
Get-ChildItem $Cache -File -Recurse | ForEach-Object {
|
||||
@{ file = [IO.Path]::GetRelativePath($Cache, $_.FullName); bytes = $_.Length;
|
||||
sha512 = (Get-FileHash $_.FullName -Algorithm SHA512).Hash.ToLowerInvariant() }
|
||||
} | ConvertTo-Json | Set-Content (Join-Path $Evidence "package-cache.json")
|
||||
|
||||
# Administrative extraction uses TARGETDIR, not a normal MSI installation:
|
||||
# no product registration or system PATH modification. Fail rather than fall
|
||||
# back to an ambient executable or ordinary installer if the payload is absent.
|
||||
$Image = Join-Path $Root "pkgconf-image"
|
||||
$Extract = Start-Process msiexec.exe -Wait -PassThru -ArgumentList @(
|
||||
"/a", "`"$(Join-Path $Root 'pkgconf.msi')`"", "/qn", "/norestart",
|
||||
"TARGETDIR=`"$Image`"", "/L*v", "`"$(Join-Path $Evidence 'pkgconf-extract.log')`""
|
||||
)
|
||||
if ($Extract.ExitCode -ne 0) { throw "pkgconf extraction failed: $($Extract.ExitCode)" }
|
||||
$Candidates = @(Get-ChildItem $Image -Filter pkgconf.exe -File -Recurse)
|
||||
if ($Candidates.Count -ne 1) { throw "Expected exactly one native pkgconf executable" }
|
||||
# Bazel shell-quotes execpaths containing spaces; Cargo executes PKG_CONFIG
|
||||
# directly. Keep the executable and its support files at a space-free execpath.
|
||||
$Native = Join-Path $Image "native"
|
||||
if (Test-Path $Native) { throw "Native pkgconf destination must be fresh" }
|
||||
Move-Item -LiteralPath $Candidates[0].Directory.FullName -Destination $Native
|
||||
$PkgConfig = Join-Path $Native "pkgconf.exe"
|
||||
$Version = & $PkgConfig --version
|
||||
if ($LASTEXITCODE -ne 0 -or $Version -ne "3.0.6") { throw "Unexpected native pkgconf version" }
|
||||
@{ target = $Target; cygwin_root = $Cygwin; pkg_config = $PkgConfig;
|
||||
pkgconf_version = $Version; requested_packages = $Packages } |
|
||||
ConvertTo-Json | Set-Content (Join-Path $Evidence "tools.json")
|
||||
# Declare complete installed support trees only after snapshot and tool checks.
|
||||
& python (Join-Path $PSScriptRoot "voice_windows_tools.py") --root $Root --target $Target --pkg-config $PkgConfig
|
||||
if ($LASTEXITCODE -ne 0) { throw "Cannot declare Windows Bazel tool inputs" }
|
||||
"VOICE_WINDOWS_BAZEL_REPOSITORY=$Root" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
"VOICE_CYGWIN_ROOT=$Cygwin" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
"VOICE_PKG_CONFIG=$PkgConfig" | Out-File $env:GITHUB_ENV -Encoding utf8 -Append
|
||||
52
.github/scripts/test_contract_releases.py
vendored
Normal file
52
.github/scripts/test_contract_releases.py
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
import unittest
|
||||
from datetime import datetime, timezone
|
||||
|
||||
from contract_releases import select_stables
|
||||
|
||||
|
||||
class StableReleaseSelectionTests(unittest.TestCase):
|
||||
def test_selects_latest_and_closest_stable_by_publication_date(self):
|
||||
releases = [
|
||||
{
|
||||
"tagName": tag,
|
||||
"publishedAt": date,
|
||||
"isPrerelease": False,
|
||||
"isDraft": False,
|
||||
}
|
||||
for tag, date in (
|
||||
("rust-v0.9.9", "2026-02-08T00:00:00Z"),
|
||||
("rust-v0.10.2", "2026-01-10T00:00:00Z"),
|
||||
("rust-v0.10.10", "2026-01-13T00:00:00Z"),
|
||||
("rust-v0.10.11", "2026-01-16T00:00:00Z"),
|
||||
("rust-v1.0.1", "2026-01-20T00:00:00Z"),
|
||||
("rust-v1.1.0", "2026-02-06T00:00:00Z"),
|
||||
("rust-v2.0.0-beta.1", "2026-02-06T00:00:00Z"),
|
||||
)
|
||||
]
|
||||
releases.extend(
|
||||
[
|
||||
{"tagName": "rust-v3.0.0", "isPrerelease": True, "isDraft": False},
|
||||
{"tagName": "rust-v4.0.0", "isPrerelease": False, "isDraft": True},
|
||||
]
|
||||
)
|
||||
for target_date, expected in (
|
||||
# One day newer than the target beats two days older (59 vs. 62).
|
||||
(datetime(2026, 1, 15, tzinfo=timezone.utc), "rust-v0.10.11"),
|
||||
# The older release wins when it is closer.
|
||||
(datetime(2026, 1, 14, tzinfo=timezone.utc), "rust-v0.10.10"),
|
||||
# Equal distances prefer the higher version.
|
||||
(datetime(2026, 1, 14, 12, tzinfo=timezone.utc), "rust-v0.10.11"),
|
||||
):
|
||||
with self.subTest(target_date=target_date):
|
||||
self.assertEqual(
|
||||
select_stables(releases, target_date),
|
||||
["rust-v1.1.0", expected],
|
||||
)
|
||||
self.assertEqual(
|
||||
select_stables(releases, datetime(2026, 2, 6, tzinfo=timezone.utc)),
|
||||
["rust-v1.1.0"],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
37
.github/scripts/test_macos_signing_entitlements.py
vendored
Normal file
37
.github/scripts/test_macos_signing_entitlements.py
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
import plistlib
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SIGNING_DIR = ROOT / ".github" / "scripts" / "macos-signing"
|
||||
ALLOW_JIT = "com.apple.security.cs.allow-jit"
|
||||
ALLOW_UNSIGNED_EXECUTABLE_MEMORY = (
|
||||
"com.apple.security.cs.allow-unsigned-executable-memory"
|
||||
)
|
||||
|
||||
|
||||
class MacosSigningEntitlementsTest(unittest.TestCase):
|
||||
def load(self, binary: str) -> dict[str, bool]:
|
||||
path = SIGNING_DIR / f"{binary}.entitlements.plist"
|
||||
with path.open("rb") as file:
|
||||
return plistlib.load(file)
|
||||
|
||||
def test_v8_binaries_allow_unsigned_executable_memory(self) -> None:
|
||||
expected = {
|
||||
ALLOW_JIT: True,
|
||||
ALLOW_UNSIGNED_EXECUTABLE_MEMORY: True,
|
||||
}
|
||||
for binary in ["codex", "codex-app-server", "codex-code-mode-host"]:
|
||||
with self.subTest(binary=binary):
|
||||
self.assertEqual(self.load(binary), expected)
|
||||
|
||||
def test_responses_proxy_keeps_existing_entitlements(self) -> None:
|
||||
self.assertEqual(
|
||||
self.load("codex-responses-api-proxy"),
|
||||
{ALLOW_JIT: True},
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
416
.github/scripts/test_releases.py
vendored
Normal file
416
.github/scripts/test_releases.py
vendored
Normal file
@@ -0,0 +1,416 @@
|
||||
import io
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import tarfile
|
||||
import tempfile
|
||||
import textwrap
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
from npm_alpha_tag import npm_alpha_tag
|
||||
import publish_r2_release as r2
|
||||
from releases import is_valid_release_version, should_make_latest, 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", "")
|
||||
|
||||
|
||||
class NpmAlphaTagTest(unittest.TestCase):
|
||||
def write_package(self, tarball: Path, package: str) -> None:
|
||||
content = json.dumps({"name": package}).encode()
|
||||
with tarfile.open(tarball, "w:gz") as archive:
|
||||
info = tarfile.TarInfo("package/package.json")
|
||||
info.size = len(content)
|
||||
archive.addfile(info, io.BytesIO(content))
|
||||
|
||||
def test_published_tags_across_packages_and_platforms(self) -> None:
|
||||
# Each package/tag reads its own registry value, even after a partially
|
||||
# published release. Also exercise a missing pointer and dotted hotfix.
|
||||
cases = [
|
||||
(
|
||||
"@openai/codex-sdk",
|
||||
"latest",
|
||||
"0.100.0",
|
||||
"0.99.9",
|
||||
"release-0.99.9-latest",
|
||||
),
|
||||
(
|
||||
"@openai/codex",
|
||||
"linux-x64",
|
||||
"0.99.9-linux-x64",
|
||||
"0.100.0",
|
||||
"linux-x64",
|
||||
),
|
||||
("@openai/codex-responses-api-proxy", "latest", None, "0.100.0", "latest"),
|
||||
(
|
||||
"@openai/codex",
|
||||
"alpha",
|
||||
"0.158.0-alpha.10",
|
||||
"0.157.0-alpha.11.1",
|
||||
"release-0.157.0-alpha.11.1-alpha",
|
||||
),
|
||||
(
|
||||
"@openai/codex",
|
||||
"alpha-linux-x64",
|
||||
"0.158.0-alpha.10-linux-x64",
|
||||
"0.157.0-alpha.11.1",
|
||||
"release-0.157.0-alpha.11.1-alpha-linux-x64",
|
||||
),
|
||||
(
|
||||
"@openai/codex",
|
||||
"alpha-win32-arm64",
|
||||
"0.158.0-alpha.9-win32-arm64",
|
||||
"0.158.0-alpha.10",
|
||||
"alpha-win32-arm64",
|
||||
),
|
||||
(
|
||||
"@openai/codex-sdk",
|
||||
"alpha",
|
||||
"0.158.0-alpha.10",
|
||||
"0.158.0-alpha.10.1",
|
||||
"alpha",
|
||||
),
|
||||
(
|
||||
"@openai/codex-responses-api-proxy",
|
||||
"alpha",
|
||||
"0.159.0-alpha.1",
|
||||
"0.158.0-alpha.10.1",
|
||||
"release-0.158.0-alpha.10.1-alpha",
|
||||
),
|
||||
("@openai/codex-sdk", "alpha", None, "0.158.0-alpha.10", "alpha"),
|
||||
(
|
||||
"@openai/codex",
|
||||
"alpha-linux-x64",
|
||||
"broken-linux-x64",
|
||||
"0.158.0-alpha.10",
|
||||
"alpha-linux-x64",
|
||||
),
|
||||
]
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
tarball = Path(tmpdir) / "package.tgz"
|
||||
for package, tag, current, version, expected in cases:
|
||||
with self.subTest(package=package, tag=tag, version=version):
|
||||
self.write_package(tarball, package)
|
||||
tags = {tag: current} if current is not None else {}
|
||||
result = subprocess.CompletedProcess([], 0, json.dumps(tags))
|
||||
with patch(
|
||||
"npm_alpha_tag.subprocess.run", return_value=result
|
||||
) as run:
|
||||
self.assertEqual(npm_alpha_tag(tarball, version, tag), expected)
|
||||
run.assert_called_once_with(
|
||||
[
|
||||
"npm",
|
||||
"view",
|
||||
package,
|
||||
"dist-tags",
|
||||
"--json",
|
||||
"--prefer-online",
|
||||
],
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
def test_stable_tags_reject_malformed_and_prerelease_versions(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
tarball = Path(tmpdir) / "package.tgz"
|
||||
self.write_package(tarball, "@openai/codex")
|
||||
for tag, current in (
|
||||
("latest", "broken"),
|
||||
("linux-x64", "0.100.0-alpha.1-linux-x64"),
|
||||
):
|
||||
with self.subTest(tag=tag, current=current):
|
||||
result = subprocess.CompletedProcess(
|
||||
[], 0, json.dumps({tag: current})
|
||||
)
|
||||
with patch("npm_alpha_tag.subprocess.run", return_value=result):
|
||||
with self.assertRaises(ValueError):
|
||||
npm_alpha_tag(tarball, "0.99.9", tag)
|
||||
|
||||
def test_registry_failure_prevents_publish(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
tarball = Path(tmpdir) / "package.tgz"
|
||||
self.write_package(tarball, "@openai/codex")
|
||||
with patch(
|
||||
"npm_alpha_tag.subprocess.run",
|
||||
side_effect=subprocess.CalledProcessError(1, "npm"),
|
||||
):
|
||||
with self.assertRaises(subprocess.CalledProcessError):
|
||||
npm_alpha_tag(tarball, "0.158.0-alpha.10", "alpha")
|
||||
|
||||
|
||||
class DotSlashReleaseConfigTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
github_dir = Path(__file__).resolve().parent.parent
|
||||
cls.configs = {
|
||||
filename: json.loads((github_dir / filename).read_text())["outputs"]
|
||||
for filename in (
|
||||
"dotslash-config.json",
|
||||
"dotslash-argument-comment-lint-config.json",
|
||||
"dotslash-provisioned-config.json",
|
||||
)
|
||||
}
|
||||
# Names from the published rust-v0.167.0-alpha.2 release, which has no
|
||||
# Bazel assets: https://github.com/openai/codex/releases/tag/rust-v0.167.0-alpha.2
|
||||
cls.assets = set(
|
||||
(github_dir / "scripts/fixtures/codex-0.167.0-alpha.2-assets.txt")
|
||||
.read_text()
|
||||
.splitlines()
|
||||
)
|
||||
|
||||
def missing_assets(self, assets):
|
||||
return sorted(
|
||||
(filename, output_name, platform)
|
||||
for filename, outputs in self.configs.items()
|
||||
for output_name, output in outputs.items()
|
||||
for platform, config in output["platforms"].items()
|
||||
if not any(re.match(config["regex"], asset) for asset in assets)
|
||||
)
|
||||
|
||||
def test_cargo_release_covers_all_configured_outputs(self):
|
||||
self.assertEqual(
|
||||
{filename: set(outputs) for filename, outputs in self.configs.items()},
|
||||
{
|
||||
"dotslash-config.json": {
|
||||
"codex",
|
||||
"codex-app-server",
|
||||
"codex-responses-api-proxy",
|
||||
"bwrap",
|
||||
"codex-command-runner",
|
||||
"codex-windows-sandbox-setup",
|
||||
"codex-windows-sandbox-service",
|
||||
},
|
||||
"dotslash-argument-comment-lint-config.json": {"argument-comment-lint"},
|
||||
"dotslash-provisioned-config.json": {"codex-provisioned"},
|
||||
},
|
||||
)
|
||||
self.assertFalse(any("-bazel" in asset for asset in self.assets))
|
||||
self.assertEqual(self.missing_assets(self.assets), [])
|
||||
|
||||
def test_missing_cargo_asset_is_detected(self):
|
||||
missing_asset = "codex-package-aarch64-apple-darwin.tar.zst"
|
||||
self.assertIn(missing_asset, self.assets)
|
||||
self.assertEqual(
|
||||
self.missing_assets(self.assets - {missing_asset}),
|
||||
[("dotslash-config.json", "codex", "macos-aarch64")],
|
||||
)
|
||||
|
||||
def test_missing_provisioned_cargo_asset_is_detected(self):
|
||||
for arch in ("aarch64", "x86_64"):
|
||||
with self.subTest(arch=arch):
|
||||
missing_asset = f"codex-provisioned-package-{arch}-apple-darwin.tar.gz"
|
||||
self.assertIn(missing_asset, self.assets)
|
||||
self.assertEqual(
|
||||
self.missing_assets(self.assets - {missing_asset}),
|
||||
[
|
||||
(
|
||||
"dotslash-provisioned-config.json",
|
||||
"codex-provisioned",
|
||||
f"macos-{arch}",
|
||||
)
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class StablePublicationTests(unittest.TestCase):
|
||||
def test_github_release_upload_and_cleanup(self):
|
||||
bash = shutil.which("bash")
|
||||
if bash is None:
|
||||
self.skipTest("Release workflow requires Bash 4.4 or newer")
|
||||
version = subprocess.check_output(
|
||||
[bash, "-c", 'echo "${BASH_VERSINFO[0]} ${BASH_VERSINFO[1]}"'],
|
||||
text=True,
|
||||
)
|
||||
if tuple(map(int, version.split())) < (4, 4):
|
||||
self.skipTest("Release workflow requires Bash 4.4 or newer")
|
||||
|
||||
script = Path(__file__).resolve().with_name("publish-github-release.sh")
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
root = Path(tmpdir)
|
||||
gh = root / "gh"
|
||||
gh.write_text(
|
||||
textwrap.dedent("""\
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
case "$1 $2" in
|
||||
'api graphql')
|
||||
if compgen -G 'release-*' >/dev/null; then echo true; else echo false; fi ;;
|
||||
'api --silent')
|
||||
[[ "$3" == "repos/test/codex/git/ref/tags/$GITHUB_REF_NAME" ]]
|
||||
[[ -f "${3##*/}.tag" ]] || exit 5 ;;
|
||||
'api --method')
|
||||
case "$3 $4" in
|
||||
'POST repos/test/codex/releases')
|
||||
printf '%s\\n' "$@" > "release-$CREATE_ID"
|
||||
echo "$CREATE_ID" ;;
|
||||
'DELETE repos/test/codex/releases/'*)
|
||||
echo "DELETE $4" >> operations
|
||||
rm -- "release-${4##*/}" ;;
|
||||
*) exit 99 ;;
|
||||
esac ;;
|
||||
'release upload')
|
||||
echo upload >> operations
|
||||
[[ "$3" == "$GITHUB_REF_NAME" && -f "$4" ]]
|
||||
if [[ "$FAIL_AT" == replace ]]; then
|
||||
mv "release-$CREATE_ID" release-999
|
||||
exit 7
|
||||
fi
|
||||
[[ "$FAIL_AT" != upload ]] || exit 7 ;;
|
||||
'release edit')
|
||||
echo edit >> operations
|
||||
[[ "$FAIL_AT" != edit ]] || exit 8 ;;
|
||||
*) exit 99 ;;
|
||||
esac
|
||||
""")
|
||||
)
|
||||
gh.chmod(0o755)
|
||||
alpha = "rust-v0.100.0-alpha.1"
|
||||
delete = "DELETE repos/test/codex/releases"
|
||||
# Repeated tags reuse the preceding release state for a retry.
|
||||
for tag, fail_at, create_id, status, surviving_id, operations in (
|
||||
(alpha, "upload", 101, 7, None, ["upload", f"{delete}/101"]),
|
||||
(alpha, "", 102, 0, 102, ["upload", "edit"]),
|
||||
(alpha, "upload", 103, 7, 102, ["upload"]),
|
||||
("rust-v0.100.0-alpha.2", "edit", 104, 8, 104, ["upload", "edit"]),
|
||||
("rust-v0.100.0", "upload", 105, 7, 105, ["upload"]),
|
||||
(
|
||||
"rust-v0.100.0-alpha.3",
|
||||
"replace",
|
||||
106,
|
||||
7,
|
||||
999,
|
||||
["upload", f"{delete}/106"],
|
||||
),
|
||||
("rust-v0.100.0-alpha.4", "missing_tag", 107, 5, None, []),
|
||||
):
|
||||
with self.subTest(tag=tag, fail_at=fail_at):
|
||||
directory = root / tag
|
||||
tag_file = directory / f"{tag}.tag"
|
||||
if not directory.exists():
|
||||
(directory / "dist").mkdir(parents=True)
|
||||
(directory / "dist/package.tar.gz").write_bytes(b"package")
|
||||
(directory / "notes.md").write_text("release notes\n")
|
||||
if fail_at != "missing_tag":
|
||||
tag_file.touch()
|
||||
operation_log = directory / "operations"
|
||||
operation_log.write_text("")
|
||||
prerelease = "-alpha." in tag
|
||||
result = subprocess.run(
|
||||
[bash, str(script)],
|
||||
cwd=directory,
|
||||
env={
|
||||
**os.environ,
|
||||
"PATH": f"{root}{os.pathsep}{os.environ['PATH']}",
|
||||
"GITHUB_REPOSITORY": "test/codex",
|
||||
"GITHUB_REPOSITORY_OWNER": "test",
|
||||
"GITHUB_REF_NAME": tag,
|
||||
"RELEASE_NAME": tag.removeprefix("rust-v"),
|
||||
"RELEASE_NOTES": "notes.md",
|
||||
"MAKE_LATEST": str(not prerelease).lower(),
|
||||
"PRERELEASE": str(prerelease).lower(),
|
||||
"FAIL_AT": fail_at,
|
||||
"CREATE_ID": str(create_id),
|
||||
},
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
self.assertEqual(result.returncode, status, result.stderr)
|
||||
self.assertEqual(tag_file.exists(), fail_at != "missing_tag")
|
||||
self.assertEqual(operation_log.read_text().splitlines(), operations)
|
||||
releases = list(directory.glob("release-*"))
|
||||
self.assertEqual(
|
||||
[p.name for p in releases],
|
||||
[f"release-{surviving_id}"] if surviving_id else [],
|
||||
)
|
||||
if surviving_id:
|
||||
fields = releases[0].read_text().splitlines()
|
||||
self.assertIn(f"tag_name={tag}", fields)
|
||||
self.assertIn(f"draft={str(not prerelease).lower()}", fields)
|
||||
self.assertIn(f"prerelease={str(prerelease).lower()}", fields)
|
||||
|
||||
def test_github_latest_orders_numerically_and_allows_equal_reruns(self):
|
||||
latest = {"tag_name": "rust-v0.100.0", "draft": False, "prerelease": False}
|
||||
self.assertFalse(should_make_latest("0.99.9", latest))
|
||||
self.assertTrue(should_make_latest("0.100.0", latest))
|
||||
self.assertTrue(should_make_latest("0.101.0", latest))
|
||||
|
||||
def test_github_latest_rejects_unpublished_or_unreadable_metadata(self):
|
||||
for latest in (
|
||||
{},
|
||||
{"tag_name": "rust-vunknown", "draft": False, "prerelease": False},
|
||||
{"tag_name": "rust-v0.100.0", "draft": True, "prerelease": False},
|
||||
{"tag_name": "rust-v0.100.0", "draft": False, "prerelease": True},
|
||||
):
|
||||
with self.subTest(latest=latest):
|
||||
with self.assertRaises(ValueError):
|
||||
should_make_latest("0.99.9", latest)
|
||||
|
||||
def test_r2_checks_its_channel_and_only_repairs_unreadable_prereleases(self):
|
||||
with patch.object(r2, "run_command") as command:
|
||||
command.return_value = '{"tag_name":"rust-v0.100.0"}'
|
||||
self.assertFalse(r2.should_update_channel("endpoint", "0.99.9", "latest"))
|
||||
self.assertTrue(r2.should_update_channel("endpoint", "0.100.0", "latest"))
|
||||
self.assertIn(
|
||||
"s3://releases/codex/channels/latest", command.call_args.args[0]
|
||||
)
|
||||
command.return_value = "invalid"
|
||||
with self.assertRaises(r2.PublishError):
|
||||
r2.should_update_channel("endpoint", "0.99.9", "latest")
|
||||
self.assertTrue(
|
||||
r2.should_update_channel("endpoint", "0.99.9-alpha.1", "prerelease")
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
250
.github/scripts/test_resolve_python_cli_release.py
vendored
Normal file
250
.github/scripts/test_resolve_python_cli_release.py
vendored
Normal file
@@ -0,0 +1,250 @@
|
||||
import copy
|
||||
import json
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import resolve_python_cli_release as resolver
|
||||
|
||||
|
||||
class ResolvePythonCliReleaseTest(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.revision = "a" * 40
|
||||
self.run = {
|
||||
"id": 123,
|
||||
"path": ".github/workflows/rust-release.yml",
|
||||
"event": "push",
|
||||
"status": "completed",
|
||||
"conclusion": "success",
|
||||
"head_repository": {"full_name": "openai/codex"},
|
||||
"head_branch": "rust-v1.2.3",
|
||||
"head_sha": self.revision,
|
||||
}
|
||||
self.job = {
|
||||
"id": 456,
|
||||
"run_attempt": 1,
|
||||
"name": "release",
|
||||
"conclusion": "success",
|
||||
}
|
||||
self.commit = {"type": "commit", "sha": self.revision}
|
||||
self.release = {
|
||||
"id": 789,
|
||||
"draft": False,
|
||||
"prerelease": False,
|
||||
"tag_name": "rust-v1.2.3",
|
||||
}
|
||||
self.assets = [
|
||||
{"name": name, "state": "uploaded", "size": 100}
|
||||
for name in [
|
||||
"openai_codex_cli_bin-1.2.3-py3-none-macosx_10_9_x86_64.whl",
|
||||
"openai_codex_cli_bin-1.2.3-py3-none-macosx_11_0_arm64.whl",
|
||||
"openai_codex_cli_bin-1.2.3-py3-none-manylinux_2_17_aarch64.whl",
|
||||
"openai_codex_cli_bin-1.2.3-py3-none-manylinux_2_17_x86_64.whl",
|
||||
"openai_codex_cli_bin-1.2.3-py3-none-win_amd64.whl",
|
||||
"openai_codex_cli_bin-1.2.3-py3-none-win_arm64.whl",
|
||||
"codex-package-aarch64-unknown-linux-musl.tar.gz",
|
||||
"codex-package-x86_64-unknown-linux-musl.tar.gz",
|
||||
]
|
||||
]
|
||||
self.expected = {
|
||||
"source_sha": self.revision,
|
||||
"release_tag": "rust-v1.2.3",
|
||||
"version": "1.2.3",
|
||||
}
|
||||
|
||||
def responses(self) -> list:
|
||||
return copy.deepcopy(
|
||||
[
|
||||
self.run,
|
||||
{"jobs": [self.job]},
|
||||
{"object": self.commit},
|
||||
self.release,
|
||||
self.assets,
|
||||
]
|
||||
)
|
||||
|
||||
def test_resolves_lightweight_and_annotated_tags_to_the_run_revision(self) -> None:
|
||||
for annotated in (False, True):
|
||||
with self.subTest(annotated=annotated):
|
||||
responses = self.responses()
|
||||
if annotated:
|
||||
responses.insert(2, {"object": {"type": "tag", "sha": "b" * 40}})
|
||||
with patch.object(resolver, "github_api", side_effect=responses):
|
||||
self.assertEqual(
|
||||
resolver.resolve_release("openai/codex", "123"), self.expected
|
||||
)
|
||||
|
||||
def test_skips_cli_prereleases_before_reading_jobs_or_assets(self) -> None:
|
||||
for suffix in ("-alpha", "-alpha.1", "-alpha.1.2", "-beta", "-beta.1"):
|
||||
with self.subTest(suffix=suffix):
|
||||
run = {**self.run, "head_branch": f"rust-v1.2.3{suffix}"}
|
||||
with patch.object(resolver, "github_api", return_value=run) as api:
|
||||
self.assertIsNone(resolver.resolve_release("openai/codex", "123"))
|
||||
api.assert_called_once_with("repos/openai/codex/actions/runs/123")
|
||||
|
||||
def test_rejects_unrelated_or_incomplete_runs(self) -> None:
|
||||
for field, value in (
|
||||
("id", 999),
|
||||
("path", ".github/workflows/sdk.yml"),
|
||||
("event", "pull_request"),
|
||||
("status", "in_progress"),
|
||||
("head_branch", "main"),
|
||||
("head_sha", "main"),
|
||||
("head_repository", {"full_name": "other/codex"}),
|
||||
):
|
||||
with self.subTest(field=field, value=value):
|
||||
with patch.object(
|
||||
resolver, "github_api", return_value={**self.run, field: value}
|
||||
):
|
||||
with self.assertRaises(ValueError):
|
||||
resolver.resolve_release("openai/codex", "123")
|
||||
|
||||
def test_accepts_failed_ancillary_publisher_and_its_partial_rerun(self) -> None:
|
||||
for overall in ("failure", "cancelled"):
|
||||
with self.subTest(overall=overall):
|
||||
responses = self.responses()
|
||||
responses[0]["conclusion"] = overall
|
||||
responses[1]["jobs"].extend(
|
||||
[
|
||||
{
|
||||
"id": 999,
|
||||
"run_attempt": 2,
|
||||
"name": "publish-winget",
|
||||
"conclusion": "failure",
|
||||
},
|
||||
{
|
||||
**self.job,
|
||||
"id": 998,
|
||||
"run_attempt": 2,
|
||||
"conclusion": "skipped",
|
||||
},
|
||||
]
|
||||
)
|
||||
with patch.object(resolver, "github_api", side_effect=responses):
|
||||
self.assertEqual(
|
||||
resolver.resolve_release("openai/codex", "123"), self.expected
|
||||
)
|
||||
|
||||
def test_requires_success_from_latest_executed_release_job(self) -> None:
|
||||
for jobs in (
|
||||
[],
|
||||
[{**self.job, "conclusion": "skipped"}],
|
||||
[{**self.job, "conclusion": "failure"}],
|
||||
[{**self.job, "conclusion": "cancelled"}],
|
||||
[
|
||||
{**self.job, "id": 999, "run_attempt": 2, "conclusion": "failure"},
|
||||
self.job,
|
||||
],
|
||||
):
|
||||
with self.subTest(jobs=jobs):
|
||||
with patch.object(
|
||||
resolver, "github_api", side_effect=[self.run, {"jobs": jobs}]
|
||||
):
|
||||
with self.assertRaisesRegex(ValueError, "successful release job"):
|
||||
resolver.resolve_release("openai/codex", "123")
|
||||
|
||||
def test_reads_all_pages_of_jobs_and_assets(self) -> None:
|
||||
responses = self.responses()
|
||||
responses.insert(1, {"jobs": [{**self.job, "name": "other"}] * 100})
|
||||
responses.insert(-1, [{"name": "other", "state": "uploaded", "size": 1}] * 100)
|
||||
with patch.object(resolver, "github_api", side_effect=responses) as api:
|
||||
self.assertEqual(
|
||||
resolver.resolve_release("openai/codex", "123"), self.expected
|
||||
)
|
||||
api.assert_any_call(
|
||||
"repos/openai/codex/actions/runs/123/jobs?filter=all&per_page=100&page=2"
|
||||
)
|
||||
api.assert_any_call(
|
||||
"repos/openai/codex/releases/789/assets?per_page=100&page=2"
|
||||
)
|
||||
|
||||
def test_rejects_a_moved_tag(self) -> None:
|
||||
responses = self.responses()
|
||||
responses[2] = {"object": {"type": "commit", "sha": "b" * 40}}
|
||||
with patch.object(resolver, "github_api", side_effect=responses):
|
||||
with self.assertRaisesRegex(ValueError, "no longer matches"):
|
||||
resolver.resolve_release("openai/codex", "123")
|
||||
|
||||
def test_bounds_annotated_tag_resolution(self) -> None:
|
||||
tag = {"object": {"type": "tag", "sha": "b" * 40}}
|
||||
with patch.object(
|
||||
resolver,
|
||||
"github_api",
|
||||
side_effect=[self.run, {"jobs": [self.job]}, *([tag] * 9)],
|
||||
) as api:
|
||||
with self.assertRaisesRegex(ValueError, "no longer matches"):
|
||||
resolver.resolve_release("openai/codex", "123")
|
||||
self.assertEqual(api.call_count, 11)
|
||||
|
||||
def test_requires_a_published_stable_release_for_the_tag(self) -> None:
|
||||
for field, value in (
|
||||
("draft", True),
|
||||
("prerelease", True),
|
||||
("tag_name", "rust-v9.9.9"),
|
||||
):
|
||||
responses = self.responses()
|
||||
responses[3][field] = value
|
||||
with self.subTest(field=field):
|
||||
with patch.object(resolver, "github_api", side_effect=responses):
|
||||
with self.assertRaisesRegex(ValueError, "published and stable"):
|
||||
resolver.resolve_release("openai/codex", "123")
|
||||
|
||||
def test_requires_all_runtime_inputs_to_be_uploaded_and_nonempty(self) -> None:
|
||||
for assets in (
|
||||
self.assets[:-1],
|
||||
[*self.assets[:-1], {**self.assets[-1], "size": 0}],
|
||||
[*self.assets[:-1], {**self.assets[-1], "state": "new"}],
|
||||
):
|
||||
with self.subTest(assets=assets):
|
||||
responses = self.responses()
|
||||
responses[-1] = assets
|
||||
with patch.object(resolver, "github_api", side_effect=responses):
|
||||
with self.assertRaisesRegex(ValueError, "missing Python inputs"):
|
||||
resolver.resolve_release("openai/codex", "123")
|
||||
|
||||
def test_rejects_invalid_inputs_before_github_access(self) -> None:
|
||||
with patch.object(resolver, "github_api") as api:
|
||||
for repository, run_id in (
|
||||
("other/codex", "123"),
|
||||
("openai/codex", "../123"),
|
||||
):
|
||||
with self.assertRaises(ValueError):
|
||||
resolver.resolve_release(repository, run_id)
|
||||
api.assert_not_called()
|
||||
|
||||
def test_event_and_manual_retry_emit_the_same_revision_and_version(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
output = Path(directory) / "output"
|
||||
event = Path(directory) / "event.json"
|
||||
for automatic in (True, False):
|
||||
output.write_text("")
|
||||
event.write_text(
|
||||
json.dumps({"workflow_run": self.run} if automatic else {})
|
||||
)
|
||||
responses = self.responses()[1:] if automatic else self.responses()
|
||||
with patch.object(resolver, "github_api", side_effect=responses) as api:
|
||||
resolver.main(
|
||||
[
|
||||
"123",
|
||||
"--repository",
|
||||
"openai/codex",
|
||||
"--event-path",
|
||||
str(event),
|
||||
"--github-output",
|
||||
str(output),
|
||||
]
|
||||
)
|
||||
self.assertEqual(
|
||||
output.read_text(),
|
||||
f"publish=true\nsource_sha={self.revision}\nrelease_tag=rust-v1.2.3\nversion=1.2.3\n",
|
||||
)
|
||||
if automatic:
|
||||
self.assertNotIn(
|
||||
unittest.mock.call("repos/openai/codex/actions/runs/123"),
|
||||
api.call_args_list,
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
127
.github/scripts/test_run_bazel_with_buildbuddy.py
vendored
Normal file
127
.github/scripts/test_run_bazel_with_buildbuddy.py
vendored
Normal file
@@ -0,0 +1,127 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
import run_bazel_with_buildbuddy
|
||||
|
||||
|
||||
class RunBazelWithBuildBuddyTest(unittest.TestCase):
|
||||
def test_bazel_command_uses_configured_binary_locally(self) -> None:
|
||||
self.assertEqual(
|
||||
run_bazel_with_buildbuddy.bazel_command(
|
||||
"info",
|
||||
"execution_root",
|
||||
env={"CODEX_BAZEL_BIN": "fake-bazel"},
|
||||
),
|
||||
["fake-bazel", "info", "execution_root"],
|
||||
)
|
||||
|
||||
def test_bazel_command_normalizes_github_actions_startup_options(self) -> None:
|
||||
env = {
|
||||
"BAZEL_OUTPUT_USER_ROOT": "/tmp/bazel-output",
|
||||
"GITHUB_ACTIONS": "true",
|
||||
}
|
||||
|
||||
self.assertEqual(
|
||||
run_bazel_with_buildbuddy.bazel_command("build", "//codex-rs/...", env=env),
|
||||
[
|
||||
"bazel",
|
||||
"--output_user_root=/tmp/bazel-output",
|
||||
"--noexperimental_remote_repo_contents_cache",
|
||||
"build",
|
||||
"//codex-rs/...",
|
||||
],
|
||||
)
|
||||
self.assertEqual(
|
||||
run_bazel_with_buildbuddy.bazel_command(
|
||||
"--experimental_remote_repo_contents_cache",
|
||||
"build",
|
||||
"//codex-rs/...",
|
||||
env=env,
|
||||
),
|
||||
[
|
||||
"bazel",
|
||||
"--output_user_root=/tmp/bazel-output",
|
||||
"--experimental_remote_repo_contents_cache",
|
||||
"build",
|
||||
"//codex-rs/...",
|
||||
],
|
||||
)
|
||||
|
||||
def test_bazel_command_uses_configured_local_caches(self) -> None:
|
||||
env = {
|
||||
"BAZEL_REPO_CONTENTS_CACHE": "/tmp/bazel-repo-contents",
|
||||
"BAZEL_REPOSITORY_CACHE": "/tmp/bazel-repository",
|
||||
}
|
||||
|
||||
self.assertEqual(
|
||||
run_bazel_with_buildbuddy.bazel_command(
|
||||
"build",
|
||||
"--config=local",
|
||||
"//codex-rs/...",
|
||||
env=env,
|
||||
),
|
||||
[
|
||||
"bazel",
|
||||
"build",
|
||||
"--config=local",
|
||||
"//codex-rs/...",
|
||||
"--repo_contents_cache=/tmp/bazel-repo-contents",
|
||||
"--repository_cache=/tmp/bazel-repository",
|
||||
],
|
||||
)
|
||||
|
||||
def test_bazel_command_adds_local_caches_before_separator(self) -> None:
|
||||
self.assertEqual(
|
||||
run_bazel_with_buildbuddy.bazel_command(
|
||||
"build",
|
||||
"//codex-rs/...",
|
||||
"--",
|
||||
"--program-arg",
|
||||
env={"BAZEL_REPOSITORY_CACHE": "/tmp/bazel-repository"},
|
||||
),
|
||||
[
|
||||
"bazel",
|
||||
"build",
|
||||
"//codex-rs/...",
|
||||
"--repository_cache=/tmp/bazel-repository",
|
||||
"--",
|
||||
"--program-arg",
|
||||
],
|
||||
)
|
||||
|
||||
def test_main_preserves_spaced_argument_and_child_exit_status(self) -> None:
|
||||
spaced_arg = (
|
||||
r"--test_env=PATH=C:\Program Files\PowerShell\7;C:\Program Files\Git\bin"
|
||||
)
|
||||
child_code = (
|
||||
f"import sys; sys.exit(37 if sys.argv[1] == {spaced_arg!r} else 91)"
|
||||
)
|
||||
env = os.environ.copy()
|
||||
env["CODEX_BAZEL_BIN"] = sys.executable
|
||||
env.pop("BAZEL_OUTPUT_USER_ROOT", None)
|
||||
env.pop("GITHUB_ACTIONS", None)
|
||||
|
||||
result = subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
str(Path(run_bazel_with_buildbuddy.__file__)),
|
||||
"-c",
|
||||
child_code,
|
||||
spaced_arg,
|
||||
],
|
||||
env=env,
|
||||
check=False,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
self.assertEqual(result.returncode, 37, result.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
407
.github/scripts/test_rusty_v8_bazel.py
vendored
Normal file
407
.github/scripts/test_rusty_v8_bazel.py
vendored
Normal file
@@ -0,0 +1,407 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import textwrap
|
||||
import unittest
|
||||
from os import environ
|
||||
from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
from unittest.mock import patch
|
||||
|
||||
import rusty_v8_bazel
|
||||
import rusty_v8_module_bazel
|
||||
|
||||
|
||||
class RustyV8BazelTest(unittest.TestCase):
|
||||
def test_consumer_selectors_track_resolved_crate_version(self) -> None:
|
||||
build_bazel = (
|
||||
rusty_v8_bazel.ROOT / "third_party" / "v8" / "BUILD.bazel"
|
||||
).read_text()
|
||||
version_suffix = rusty_v8_bazel.resolved_v8_crate_version().replace(".", "_")
|
||||
|
||||
for selector in [
|
||||
"aarch64_apple_darwin_bazel",
|
||||
"aarch64_pc_windows_gnullvm",
|
||||
"aarch64_pc_windows_msvc",
|
||||
"aarch64_unknown_linux_gnu_bazel",
|
||||
"aarch64_unknown_linux_musl_release",
|
||||
"x86_64_apple_darwin_bazel",
|
||||
"x86_64_pc_windows_gnullvm",
|
||||
"x86_64_pc_windows_msvc",
|
||||
"x86_64_unknown_linux_gnu_bazel",
|
||||
"x86_64_unknown_linux_musl_release",
|
||||
]:
|
||||
self.assertIn(
|
||||
f":v8_{version_suffix}_{selector}",
|
||||
build_bazel,
|
||||
)
|
||||
|
||||
for selector in [
|
||||
"aarch64_apple_darwin",
|
||||
"aarch64_pc_windows_gnullvm",
|
||||
"aarch64_pc_windows_msvc",
|
||||
"aarch64_unknown_linux_gnu",
|
||||
"aarch64_unknown_linux_musl",
|
||||
"x86_64_apple_darwin",
|
||||
"x86_64_pc_windows_gnullvm",
|
||||
"x86_64_pc_windows_msvc",
|
||||
"x86_64_unknown_linux_gnu",
|
||||
"x86_64_unknown_linux_musl",
|
||||
]:
|
||||
self.assertIn(
|
||||
f":src_binding_{selector}_{version_suffix}_bazel",
|
||||
build_bazel,
|
||||
)
|
||||
|
||||
def test_command_version_tracks_remaining_http_file_assets(self) -> None:
|
||||
with TemporaryDirectory() as temp_dir:
|
||||
module_bazel = Path(temp_dir) / "MODULE.bazel"
|
||||
module_bazel.write_text(
|
||||
textwrap.dedent(
|
||||
"""\
|
||||
http_file(
|
||||
name = "rusty_v8_146_4_0_x86_64_unknown_linux_gnu_archive",
|
||||
downloaded_file_path = "librusty_v8_release_x86_64-unknown-linux-gnu.a.gz",
|
||||
urls = ["https://example.test/archive.gz"],
|
||||
)
|
||||
"""
|
||||
)
|
||||
)
|
||||
|
||||
with patch.object(rusty_v8_bazel, "MODULE_BAZEL", module_bazel):
|
||||
self.assertEqual("146.4.0", rusty_v8_bazel.command_version(None))
|
||||
|
||||
def test_bazel_commands_use_shared_ci_options(self) -> None:
|
||||
with patch.dict(environ, {}, clear=True):
|
||||
self.assertEqual(
|
||||
[
|
||||
"bazel",
|
||||
"build",
|
||||
"//third_party/v8:release",
|
||||
],
|
||||
rusty_v8_bazel.bazel_command(
|
||||
"build",
|
||||
"--config=ci-v8",
|
||||
"//third_party/v8:release",
|
||||
),
|
||||
)
|
||||
|
||||
def test_release_pair_labels_and_staged_names_distinguish_sandbox_artifacts(
|
||||
self,
|
||||
) -> None:
|
||||
self.assertEqual(
|
||||
"//third_party/v8:rusty_v8_release_pair_x86_64_unknown_linux_musl",
|
||||
rusty_v8_bazel.release_pair_label("x86_64-unknown-linux-musl"),
|
||||
)
|
||||
self.assertEqual(
|
||||
"//third_party/v8:rusty_v8_sandbox_release_pair_x86_64_unknown_linux_musl",
|
||||
rusty_v8_bazel.release_pair_label(
|
||||
"x86_64-unknown-linux-musl", sandbox=True
|
||||
),
|
||||
)
|
||||
self.assertEqual(
|
||||
"//third_party/v8:rusty_v8_sandbox_release_pair_x86_64_apple_darwin",
|
||||
rusty_v8_bazel.release_pair_label("x86_64-apple-darwin", sandbox=True),
|
||||
)
|
||||
self.assertEqual(
|
||||
"librusty_v8_release_x86_64-unknown-linux-musl.a.gz",
|
||||
rusty_v8_bazel.staged_archive_name(
|
||||
"x86_64-unknown-linux-musl",
|
||||
Path("libv8.a"),
|
||||
rusty_v8_bazel.RELEASE_ARTIFACT_PROFILE,
|
||||
),
|
||||
)
|
||||
self.assertEqual(
|
||||
"rusty_v8_ptrcomp_sandbox_release_x86_64-pc-windows-msvc.lib.gz",
|
||||
rusty_v8_bazel.staged_archive_name(
|
||||
"x86_64-pc-windows-msvc",
|
||||
Path("v8.a"),
|
||||
rusty_v8_bazel.SANDBOX_ARTIFACT_PROFILE,
|
||||
),
|
||||
)
|
||||
self.assertEqual(
|
||||
"src_binding_ptrcomp_sandbox_release_x86_64-unknown-linux-musl.rs",
|
||||
rusty_v8_bazel.staged_binding_name(
|
||||
"x86_64-unknown-linux-musl",
|
||||
rusty_v8_bazel.SANDBOX_ARTIFACT_PROFILE,
|
||||
),
|
||||
)
|
||||
self.assertEqual(
|
||||
"rusty_v8_ptrcomp_sandbox_release_x86_64-unknown-linux-musl.sha256",
|
||||
rusty_v8_bazel.staged_checksums_name(
|
||||
"x86_64-unknown-linux-musl",
|
||||
rusty_v8_bazel.SANDBOX_ARTIFACT_PROFILE,
|
||||
),
|
||||
)
|
||||
|
||||
def test_stage_artifacts(self) -> None:
|
||||
with TemporaryDirectory() as source_dir, TemporaryDirectory() as output_dir:
|
||||
source_root = Path(source_dir)
|
||||
archive = source_root / "librusty_v8.a"
|
||||
binding = source_root / "src_binding.rs"
|
||||
archive.write_bytes(b"archive")
|
||||
binding.write_text("binding")
|
||||
|
||||
rusty_v8_bazel.stage_artifacts(
|
||||
"aarch64-apple-darwin",
|
||||
archive,
|
||||
binding,
|
||||
Path(output_dir),
|
||||
sandbox=True,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
{
|
||||
"librusty_v8_ptrcomp_sandbox_release_aarch64-apple-darwin.a.gz",
|
||||
"src_binding_ptrcomp_sandbox_release_aarch64-apple-darwin.rs",
|
||||
"rusty_v8_ptrcomp_sandbox_release_aarch64-apple-darwin.sha256",
|
||||
},
|
||||
{path.name for path in Path(output_dir).iterdir()},
|
||||
)
|
||||
checksums = (
|
||||
Path(output_dir)
|
||||
/ "rusty_v8_ptrcomp_sandbox_release_aarch64-apple-darwin.sha256"
|
||||
).read_bytes()
|
||||
self.assertNotIn(b"\r", checksums)
|
||||
|
||||
def test_upstream_release_pair_paths(self) -> None:
|
||||
self.assertEqual(
|
||||
(
|
||||
Path(
|
||||
"/tmp/rusty_v8/target/x86_64-apple-darwin/release/gn_out/obj/"
|
||||
"librusty_v8.a"
|
||||
),
|
||||
Path(
|
||||
"/tmp/rusty_v8/target/x86_64-apple-darwin/release/gn_out/"
|
||||
"src_binding.rs"
|
||||
),
|
||||
),
|
||||
rusty_v8_bazel.upstream_release_pair_paths(
|
||||
"x86_64-apple-darwin",
|
||||
Path("/tmp/rusty_v8/target"),
|
||||
),
|
||||
)
|
||||
self.assertEqual(
|
||||
(
|
||||
Path(
|
||||
"/tmp/rusty_v8/target/x86_64-pc-windows-msvc/release/gn_out/"
|
||||
"obj/rusty_v8.lib"
|
||||
),
|
||||
Path(
|
||||
"/tmp/rusty_v8/target/x86_64-pc-windows-msvc/release/gn_out/"
|
||||
"src_binding.rs"
|
||||
),
|
||||
),
|
||||
rusty_v8_bazel.upstream_release_pair_paths(
|
||||
"x86_64-pc-windows-msvc",
|
||||
Path("/tmp/rusty_v8/target"),
|
||||
),
|
||||
)
|
||||
|
||||
def test_stage_upstream_release_pair(self) -> None:
|
||||
with (
|
||||
TemporaryDirectory() as target_dir,
|
||||
TemporaryDirectory() as output_dir,
|
||||
):
|
||||
gn_out = Path(target_dir) / "x86_64-pc-windows-msvc" / "release" / "gn_out"
|
||||
(gn_out / "obj").mkdir(parents=True)
|
||||
(gn_out / "obj" / "rusty_v8.lib").write_bytes(b"archive")
|
||||
(gn_out / "src_binding.rs").write_text("binding")
|
||||
|
||||
rusty_v8_bazel.stage_upstream_release_pair(
|
||||
"x86_64-pc-windows-msvc",
|
||||
Path(output_dir),
|
||||
Path(target_dir),
|
||||
sandbox=True,
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
{
|
||||
"rusty_v8_ptrcomp_sandbox_release_x86_64-pc-windows-msvc.lib.gz",
|
||||
"src_binding_ptrcomp_sandbox_release_x86_64-pc-windows-msvc.rs",
|
||||
"rusty_v8_ptrcomp_sandbox_release_x86_64-pc-windows-msvc.sha256",
|
||||
},
|
||||
{path.name for path in Path(output_dir).iterdir()},
|
||||
)
|
||||
|
||||
def test_ensure_bazel_output_files_rebuilds_existing_outputs(self) -> None:
|
||||
with TemporaryDirectory() as output_dir:
|
||||
output = Path(output_dir) / "libv8.a"
|
||||
output.write_bytes(b"archive")
|
||||
|
||||
with (
|
||||
patch.object(rusty_v8_bazel, "bazel_build") as bazel_build,
|
||||
patch.object(
|
||||
rusty_v8_bazel,
|
||||
"bazel_output_files",
|
||||
return_value=[output],
|
||||
) as bazel_output_files,
|
||||
):
|
||||
self.assertEqual(
|
||||
[output],
|
||||
rusty_v8_bazel.ensure_bazel_output_files(
|
||||
"macos_arm64",
|
||||
["//third_party/v8:pair"],
|
||||
"opt",
|
||||
["ci-macos"],
|
||||
),
|
||||
)
|
||||
|
||||
bazel_build.assert_called_once_with(
|
||||
"macos_arm64",
|
||||
["//third_party/v8:pair"],
|
||||
"opt",
|
||||
["ci-macos"],
|
||||
download_toplevel=True,
|
||||
)
|
||||
bazel_output_files.assert_called_once_with(
|
||||
"macos_arm64",
|
||||
["//third_party/v8:pair"],
|
||||
"opt",
|
||||
["ci-macos"],
|
||||
)
|
||||
|
||||
def test_update_module_bazel_replaces_and_inserts_sha256(self) -> None:
|
||||
module_bazel = textwrap.dedent(
|
||||
"""\
|
||||
http_file(
|
||||
name = "rusty_v8_146_4_0_x86_64_unknown_linux_gnu_archive",
|
||||
downloaded_file_path = "librusty_v8_release_x86_64-unknown-linux-gnu.a.gz",
|
||||
sha256 = "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
urls = [
|
||||
"https://example.test/librusty_v8_release_x86_64-unknown-linux-gnu.a.gz",
|
||||
],
|
||||
)
|
||||
|
||||
http_file(
|
||||
name = "rusty_v8_146_4_0_x86_64_unknown_linux_musl_binding",
|
||||
downloaded_file_path = "src_binding_release_x86_64-unknown-linux-musl.rs",
|
||||
urls = [
|
||||
"https://example.test/src_binding_release_x86_64-unknown-linux-musl.rs",
|
||||
],
|
||||
)
|
||||
|
||||
http_file(
|
||||
name = "rusty_v8_145_0_0_x86_64_unknown_linux_gnu_archive",
|
||||
downloaded_file_path = "librusty_v8_release_x86_64-unknown-linux-gnu.a.gz",
|
||||
sha256 = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||
urls = [
|
||||
"https://example.test/old.gz",
|
||||
],
|
||||
)
|
||||
"""
|
||||
)
|
||||
checksums = {
|
||||
"librusty_v8_release_x86_64-unknown-linux-gnu.a.gz": (
|
||||
"1111111111111111111111111111111111111111111111111111111111111111"
|
||||
),
|
||||
"src_binding_release_x86_64-unknown-linux-musl.rs": (
|
||||
"2222222222222222222222222222222222222222222222222222222222222222"
|
||||
),
|
||||
}
|
||||
|
||||
updated = rusty_v8_module_bazel.update_module_bazel_text(
|
||||
module_bazel,
|
||||
checksums,
|
||||
"146.4.0",
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
textwrap.dedent(
|
||||
"""\
|
||||
http_file(
|
||||
name = "rusty_v8_146_4_0_x86_64_unknown_linux_gnu_archive",
|
||||
downloaded_file_path = "librusty_v8_release_x86_64-unknown-linux-gnu.a.gz",
|
||||
sha256 = "1111111111111111111111111111111111111111111111111111111111111111",
|
||||
urls = [
|
||||
"https://example.test/librusty_v8_release_x86_64-unknown-linux-gnu.a.gz",
|
||||
],
|
||||
)
|
||||
|
||||
http_file(
|
||||
name = "rusty_v8_146_4_0_x86_64_unknown_linux_musl_binding",
|
||||
downloaded_file_path = "src_binding_release_x86_64-unknown-linux-musl.rs",
|
||||
sha256 = "2222222222222222222222222222222222222222222222222222222222222222",
|
||||
urls = [
|
||||
"https://example.test/src_binding_release_x86_64-unknown-linux-musl.rs",
|
||||
],
|
||||
)
|
||||
|
||||
http_file(
|
||||
name = "rusty_v8_145_0_0_x86_64_unknown_linux_gnu_archive",
|
||||
downloaded_file_path = "librusty_v8_release_x86_64-unknown-linux-gnu.a.gz",
|
||||
sha256 = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||
urls = [
|
||||
"https://example.test/old.gz",
|
||||
],
|
||||
)
|
||||
"""
|
||||
),
|
||||
updated,
|
||||
)
|
||||
rusty_v8_module_bazel.check_module_bazel_text(updated, checksums, "146.4.0")
|
||||
|
||||
def test_check_module_bazel_rejects_manifest_drift(self) -> None:
|
||||
module_bazel = textwrap.dedent(
|
||||
"""\
|
||||
http_file(
|
||||
name = "rusty_v8_146_4_0_x86_64_unknown_linux_gnu_archive",
|
||||
downloaded_file_path = "librusty_v8_release_x86_64-unknown-linux-gnu.a.gz",
|
||||
sha256 = "1111111111111111111111111111111111111111111111111111111111111111",
|
||||
urls = [
|
||||
"https://example.test/librusty_v8_release_x86_64-unknown-linux-gnu.a.gz",
|
||||
],
|
||||
)
|
||||
"""
|
||||
)
|
||||
checksums = {
|
||||
"librusty_v8_release_x86_64-unknown-linux-gnu.a.gz": (
|
||||
"1111111111111111111111111111111111111111111111111111111111111111"
|
||||
),
|
||||
"orphan.gz": (
|
||||
"2222222222222222222222222222222222222222222222222222222222222222"
|
||||
),
|
||||
}
|
||||
|
||||
with self.assertRaisesRegex(
|
||||
rusty_v8_module_bazel.RustyV8ChecksumError,
|
||||
"manifest has orphan.gz",
|
||||
):
|
||||
rusty_v8_module_bazel.check_module_bazel_text(
|
||||
module_bazel,
|
||||
checksums,
|
||||
"146.4.0",
|
||||
)
|
||||
|
||||
def test_rusty_v8_http_file_versions(self) -> None:
|
||||
module_bazel = textwrap.dedent(
|
||||
"""\
|
||||
http_file(
|
||||
name = "rusty_v8_146_4_0_x86_64_unknown_linux_gnu_archive",
|
||||
downloaded_file_path = "archive.gz",
|
||||
urls = ["https://example.test/archive.gz"],
|
||||
)
|
||||
|
||||
http_file(
|
||||
name = "rusty_v8_147_4_0_x86_64_unknown_linux_gnu_archive",
|
||||
downloaded_file_path = "new-archive.gz",
|
||||
urls = ["https://example.test/new-archive.gz"],
|
||||
)
|
||||
|
||||
http_file(
|
||||
name = "unrelated_archive",
|
||||
downloaded_file_path = "other.gz",
|
||||
urls = ["https://example.test/other.gz"],
|
||||
)
|
||||
"""
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
["146.4.0", "147.4.0"],
|
||||
rusty_v8_module_bazel.rusty_v8_http_file_versions(module_bazel),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
147
.github/scripts/test_select_windows_bazel_targets.py
vendored
Normal file
147
.github/scripts/test_select_windows_bazel_targets.py
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from select_windows_bazel_targets import DURATIONS_PATH
|
||||
from select_windows_bazel_targets import assign_targets
|
||||
from select_windows_bazel_targets import read_durations
|
||||
|
||||
|
||||
class SelectWindowsBazelTargetsTest(unittest.TestCase):
|
||||
def test_balances_targets_with_complete_deterministic_coverage(self) -> None:
|
||||
durations = {
|
||||
f"//test:{name}": duration
|
||||
for name, duration in zip("abcdefgh", range(8, 0, -1))
|
||||
}
|
||||
targets = list(durations)
|
||||
|
||||
assignments, loads = assign_targets(targets, durations, 4)
|
||||
|
||||
self.assertEqual(loads, [9, 9, 9, 9])
|
||||
self.assertEqual(
|
||||
sorted(target for shard in assignments for target in shard), sorted(targets)
|
||||
)
|
||||
self.assertEqual(
|
||||
assign_targets(list(reversed(targets)), durations, 4), (assignments, loads)
|
||||
)
|
||||
self.assertTrue(all(shard == sorted(shard) for shard in assignments))
|
||||
|
||||
def test_missing_weights_use_one_and_unused_weights_do_not_create_targets(
|
||||
self,
|
||||
) -> None:
|
||||
targets = ["//test:c", "//test:a", "//test:b"]
|
||||
|
||||
assignments, loads = assign_targets(targets, {"//test:stale": 100}, 2)
|
||||
|
||||
self.assertEqual(assignments, [["//test:a", "//test:c"], ["//test:b"]])
|
||||
self.assertEqual(loads, [2, 1])
|
||||
|
||||
def test_rejects_empty_or_duplicate_target_input(self) -> None:
|
||||
for targets in ([], [""], ["//test:a", "//test:a"]):
|
||||
with self.subTest(targets=targets), self.assertRaises(ValueError):
|
||||
assign_targets(targets, {}, 4)
|
||||
|
||||
def test_reads_duration_file_and_rejects_invalid_weights(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
path = Path(temp_dir) / "durations.tsv"
|
||||
path.write_text(
|
||||
"# comment\n\n//test:a\t12\n//test:b\t1\n", encoding="utf-8"
|
||||
)
|
||||
self.assertEqual(read_durations(path), {"//test:a": 12, "//test:b": 1})
|
||||
|
||||
for contents in (
|
||||
"//test:a 12\n",
|
||||
"//test:a\t0\n",
|
||||
"//test:a\t-1\n",
|
||||
"//test:a\t1.5\n",
|
||||
"//test:a\t1\n//test:a\t2\n",
|
||||
):
|
||||
with self.subTest(contents=contents), self.assertRaises(ValueError):
|
||||
path.write_text(contents, encoding="utf-8")
|
||||
read_durations(path)
|
||||
|
||||
def test_cli_uses_checked_in_weights_and_writes_only_lf_delimited_targets(
|
||||
self,
|
||||
) -> None:
|
||||
durations = read_durations(DURATIONS_PATH)
|
||||
known = sorted(durations, key=lambda target: (-durations[target], target))[:4]
|
||||
self.assertEqual(len(known), 4)
|
||||
targets = [*known, "//test:new-target"]
|
||||
expected, _ = assign_targets(targets, durations, 4)
|
||||
script = DURATIONS_PATH.with_name("select_windows_bazel_targets.py")
|
||||
|
||||
for shard, assignment in enumerate(expected, 1):
|
||||
command = [
|
||||
sys.executable,
|
||||
str(script),
|
||||
"--shard",
|
||||
str(shard),
|
||||
"--shard-count",
|
||||
"4",
|
||||
]
|
||||
for ordered_targets in (targets, list(reversed(targets))):
|
||||
with self.subTest(shard=shard, ordered_targets=ordered_targets):
|
||||
result = subprocess.run(
|
||||
command,
|
||||
input=("\r\n".join(ordered_targets) + "\r\n").encode(),
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
self.assertEqual(
|
||||
result.stdout, ("\n".join(assignment) + "\n").encode()
|
||||
)
|
||||
self.assertIn(b"default weights=1", result.stderr)
|
||||
|
||||
def test_cli_uses_only_the_requested_duration_file(self) -> None:
|
||||
script = DURATIONS_PATH.with_name("select_windows_bazel_targets.py").resolve()
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
path = Path(temp_dir) / "durations.tsv"
|
||||
path.write_text("//test:a\t1\n//test:b\t9\n", encoding="utf-8")
|
||||
command = [sys.executable, str(script), "--shard-count", "2"]
|
||||
for shard, expected in ((1, b"//test:b\n"), (2, b"//test:a\n//test:c\n")):
|
||||
with self.subTest(shard=shard):
|
||||
result = subprocess.run(
|
||||
[*command, "--shard", str(shard), "--durations", path.name],
|
||||
input=b"//test:a\n//test:b\n//test:c\n",
|
||||
cwd=temp_dir,
|
||||
capture_output=True,
|
||||
check=True,
|
||||
)
|
||||
self.assertEqual(result.stdout, expected)
|
||||
self.assertIn(b"estimated test-seconds=[9, 2]", result.stderr)
|
||||
self.assertIn(b"unused weights=0", result.stderr)
|
||||
|
||||
result = subprocess.run(
|
||||
[*command, "--shard", "1", "--durations", "missing.tsv"],
|
||||
input=b"//test:a\n",
|
||||
cwd=temp_dir,
|
||||
capture_output=True,
|
||||
check=False,
|
||||
)
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertEqual(result.stdout, b"")
|
||||
self.assertIn(b"missing.tsv", result.stderr)
|
||||
|
||||
def test_cli_rejects_bad_or_empty_selection_without_partial_output(self) -> None:
|
||||
script = DURATIONS_PATH.with_name("select_windows_bazel_targets.py")
|
||||
for targets, error in (
|
||||
(b"", b"no Bazel test targets were provided"),
|
||||
(b"//test:a\n//test:a\n", b"duplicate Bazel test target labels"),
|
||||
(b"//test:a\n", b"no Bazel test targets selected for shard 2/2"),
|
||||
):
|
||||
with self.subTest(targets=targets):
|
||||
result = subprocess.run(
|
||||
[sys.executable, str(script), "--shard", "2", "--shard-count", "2"],
|
||||
input=targets,
|
||||
capture_output=True,
|
||||
check=False,
|
||||
)
|
||||
self.assertNotEqual(result.returncode, 0)
|
||||
self.assertEqual(result.stdout, b"")
|
||||
self.assertIn(error, result.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
117
.github/scripts/test_v8_canary_changes.py
vendored
Normal file
117
.github/scripts/test_v8_canary_changes.py
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from v8_canary_changes import changed_files
|
||||
from v8_canary_changes import canary_required
|
||||
from v8_canary_changes import merge_base
|
||||
from v8_canary_changes import resolved_v8_version
|
||||
from v8_canary_changes import windows_source_required
|
||||
|
||||
|
||||
class V8CanaryChangesTest(unittest.TestCase):
|
||||
def test_resolved_v8_version(self) -> None:
|
||||
cargo_lock = b"""\
|
||||
[[package]]
|
||||
name = "other"
|
||||
version = "1.0.0"
|
||||
|
||||
[[package]]
|
||||
name = "v8"
|
||||
version = "149.2.0"
|
||||
"""
|
||||
|
||||
self.assertEqual(resolved_v8_version(cargo_lock), "149.2.0")
|
||||
|
||||
def test_unrelated_cargo_manifest_change_does_not_require_source_build(
|
||||
self,
|
||||
) -> None:
|
||||
self.assertFalse(
|
||||
windows_source_required(
|
||||
{"codex-rs/Cargo.toml"},
|
||||
"149.2.0",
|
||||
"149.2.0",
|
||||
)
|
||||
)
|
||||
|
||||
def test_v8_version_change_requires_source_build(self) -> None:
|
||||
self.assertTrue(windows_source_required(set(), "149.2.0", "150.0.0"))
|
||||
|
||||
def test_module_helper_change_requires_source_build(self) -> None:
|
||||
self.assertTrue(
|
||||
windows_source_required(
|
||||
{".github/scripts/rusty_v8_module_bazel.py"},
|
||||
"149.2.0",
|
||||
"149.2.0",
|
||||
)
|
||||
)
|
||||
|
||||
def test_shared_ci_setup_changes_require_canary_and_source_build(self) -> None:
|
||||
for path in (
|
||||
".github/actions/setup-ci/action.yml",
|
||||
".github/scripts/setup-dev-drive.ps1",
|
||||
):
|
||||
with self.subTest(path=path):
|
||||
changed_files = {path}
|
||||
self.assertTrue(canary_required(changed_files, "149.2.0", "149.2.0"))
|
||||
self.assertTrue(
|
||||
windows_source_required(changed_files, "149.2.0", "149.2.0")
|
||||
)
|
||||
|
||||
def test_security_backport_changes_require_canary_and_source_build(self) -> None:
|
||||
changed_files = {"patches/v8_array_sort_elements_kind.patch"}
|
||||
|
||||
self.assertTrue(canary_required(changed_files, "152.2.0", "152.2.0"))
|
||||
self.assertTrue(windows_source_required(changed_files, "152.2.0", "152.2.0"))
|
||||
|
||||
def test_manual_dispatch_requires_source_build(self) -> None:
|
||||
self.assertTrue(
|
||||
windows_source_required(
|
||||
set(),
|
||||
"149.2.0",
|
||||
"149.2.0",
|
||||
force=True,
|
||||
)
|
||||
)
|
||||
|
||||
def test_changed_files_excludes_changes_made_only_on_base_branch(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as temp_dir:
|
||||
root = Path(temp_dir)
|
||||
self.run_git(root, "init", "--initial-branch=main")
|
||||
self.run_git(root, "config", "user.name", "Test User")
|
||||
self.run_git(root, "config", "user.email", "test@example.com")
|
||||
|
||||
self.write_and_commit(root, "initial", "initial.txt")
|
||||
common = self.run_git(root, "rev-parse", "HEAD")
|
||||
self.run_git(root, "switch", "-c", "feature")
|
||||
self.run_git(root, "switch", "main")
|
||||
self.write_and_commit(root, "base-only", "base-only.txt")
|
||||
base = self.run_git(root, "rev-parse", "HEAD")
|
||||
|
||||
self.run_git(root, "switch", "feature")
|
||||
self.write_and_commit(root, "feature-only", "feature-only.txt")
|
||||
head = self.run_git(root, "rev-parse", "HEAD")
|
||||
|
||||
self.assertEqual(
|
||||
changed_files(base, head, root=root),
|
||||
{"feature-only.txt"},
|
||||
)
|
||||
self.assertEqual(merge_base(base, head, root=root), common)
|
||||
|
||||
def write_and_commit(self, root: Path, contents: str, path: str) -> None:
|
||||
(root / path).write_text(contents)
|
||||
self.run_git(root, "add", path)
|
||||
self.run_git(root, "commit", "-m", contents)
|
||||
|
||||
def run_git(self, root: Path, *args: str) -> str:
|
||||
return subprocess.check_output(
|
||||
["git", *args],
|
||||
cwd=root,
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
).strip()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
96
.github/scripts/test_verify_pypi_release.py
vendored
Normal file
96
.github/scripts/test_verify_pypi_release.py
vendored
Normal file
@@ -0,0 +1,96 @@
|
||||
import http.client
|
||||
import io
|
||||
import json
|
||||
import unittest
|
||||
import urllib.error
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
from verify_pypi_release import verify_release
|
||||
|
||||
|
||||
class VerifyPyPIReleaseTest(unittest.TestCase):
|
||||
def test_waits_for_complete_release_after_registry_error(self) -> None:
|
||||
wheel = "openai_codex-1.2.3-py3-none-any.whl"
|
||||
sdist = "openai_codex-1.2.3.tar.gz"
|
||||
reset_response = MagicMock()
|
||||
reset_response.__enter__.return_value.read.side_effect = ConnectionResetError(
|
||||
"connection reset while reading response"
|
||||
)
|
||||
responses = [
|
||||
urllib.error.URLError("registry unavailable"),
|
||||
TimeoutError("registry timed out"),
|
||||
http.client.IncompleteRead(b"{", 20),
|
||||
reset_response,
|
||||
io.StringIO('{"urls":'),
|
||||
*[
|
||||
io.StringIO(json.dumps(data))
|
||||
for data in (
|
||||
None,
|
||||
[],
|
||||
{},
|
||||
{"urls": None},
|
||||
{"urls": {}},
|
||||
{"urls": [None]},
|
||||
{"urls": [{}]},
|
||||
{"urls": [{"filename": 42}]},
|
||||
)
|
||||
],
|
||||
io.StringIO(json.dumps({"urls": [{"filename": wheel}]})),
|
||||
io.StringIO(
|
||||
json.dumps({"urls": [{"filename": wheel}, {"filename": sdist}]})
|
||||
),
|
||||
]
|
||||
with (
|
||||
patch(
|
||||
"verify_pypi_release.urllib.request.urlopen", side_effect=responses
|
||||
) as urlopen,
|
||||
patch("verify_pypi_release.time.sleep") as sleep,
|
||||
):
|
||||
verify_release("openai-codex", "1.2.3")
|
||||
|
||||
self.assertEqual(urlopen.call_count, 15)
|
||||
self.assertEqual(sleep.call_count, 14)
|
||||
urlopen.assert_called_with(
|
||||
"https://pypi.org/pypi/openai-codex/1.2.3/json", timeout=30
|
||||
)
|
||||
|
||||
def test_uses_canonical_version_for_lookup_and_artifact_names(self) -> None:
|
||||
data = {
|
||||
"urls": [
|
||||
{"filename": name}
|
||||
for name in (
|
||||
"openai_codex-1.2.3b1-py3-none-any.whl",
|
||||
"openai_codex-1.2.3b1.tar.gz",
|
||||
)
|
||||
]
|
||||
}
|
||||
with (
|
||||
patch(
|
||||
"verify_pypi_release.urllib.request.urlopen",
|
||||
return_value=io.StringIO(json.dumps(data)),
|
||||
) as urlopen,
|
||||
patch("verify_pypi_release.time.sleep") as sleep,
|
||||
):
|
||||
verify_release("openai-codex", "1.2.3b01")
|
||||
urlopen.assert_called_once_with(
|
||||
"https://pypi.org/pypi/openai-codex/1.2.3b1/json", timeout=30
|
||||
)
|
||||
sleep.assert_not_called()
|
||||
|
||||
def test_fails_after_bounded_retries_when_runtime_wheels_are_missing(self) -> None:
|
||||
with (
|
||||
patch(
|
||||
"verify_pypi_release.urllib.request.urlopen",
|
||||
side_effect=lambda *args, **kwargs: io.StringIO('{"urls": []}'),
|
||||
) as urlopen,
|
||||
patch("verify_pypi_release.time.sleep") as sleep,
|
||||
self.assertRaisesRegex(SystemExit, "did not become available on PyPI"),
|
||||
):
|
||||
verify_release("openai-codex-cli-bin", "1.2.3a4.post5")
|
||||
|
||||
self.assertEqual(urlopen.call_count, 30)
|
||||
self.assertEqual(sleep.call_count, 29)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
83
.github/scripts/test_voice_cygwin_inputs.py
vendored
Normal file
83
.github/scripts/test_voice_cygwin_inputs.py
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
"""Offline checks for the public Windows build-input bootstrap."""
|
||||
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import io
|
||||
from pathlib import Path
|
||||
import tarfile
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
|
||||
SCRIPT = Path(__file__).with_name("voice-cygwin-inputs.py")
|
||||
SPEC = importlib.util.spec_from_file_location("voice_cygwin_inputs", SCRIPT)
|
||||
inputs = importlib.util.module_from_spec(SPEC)
|
||||
SPEC.loader.exec_module(inputs)
|
||||
|
||||
|
||||
class VoiceCygwinInputsTests(unittest.TestCase):
|
||||
def test_input_paths_cannot_escape_the_local_cache(self):
|
||||
manifest = {
|
||||
"metadata": [
|
||||
{"file": "x86_64/setup.xz"},
|
||||
{"file": "x86_64/setup.xz.sig"},
|
||||
],
|
||||
"packages": [{"file": "../outside.tar.xz"}],
|
||||
}
|
||||
with self.assertRaisesRegex(ValueError, "unsafe Cygwin input"):
|
||||
inputs.records(manifest)
|
||||
|
||||
def test_extract_verifies_archive_and_every_input_before_offline_installation(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
payloads = {
|
||||
"x86_64/setup.xz": b"metadata",
|
||||
"x86_64/setup.xz.sig": b"signature",
|
||||
"x86_64/release/bash/bash.tar.xz": b"package",
|
||||
}
|
||||
records = [
|
||||
{
|
||||
"file": name,
|
||||
"bytes": len(data),
|
||||
"sha512": hashlib.sha512(data).hexdigest(),
|
||||
}
|
||||
for name, data in payloads.items()
|
||||
]
|
||||
archive = root / "inputs.tar.gz"
|
||||
|
||||
def write_archive(contents):
|
||||
with tarfile.open(archive, "w:gz") as bundle:
|
||||
for name, data in contents.items():
|
||||
info = tarfile.TarInfo(name)
|
||||
info.size = len(data)
|
||||
bundle.addfile(info, io.BytesIO(data))
|
||||
return {
|
||||
"bytes": archive.stat().st_size,
|
||||
"sha256": hashlib.sha256(archive.read_bytes()).hexdigest(),
|
||||
}
|
||||
|
||||
manifest = {
|
||||
"metadata": records[:2],
|
||||
"packages": records[2:],
|
||||
"archive": write_archive(payloads),
|
||||
}
|
||||
destination = root / "cache"
|
||||
inputs.extract(manifest, archive, destination)
|
||||
self.assertEqual(
|
||||
{
|
||||
record["file"]: (destination / record["file"]).read_bytes()
|
||||
for record in records
|
||||
},
|
||||
payloads,
|
||||
)
|
||||
|
||||
(destination / records[2]["file"]).unlink()
|
||||
payloads[records[2]["file"]] = b"wrong"
|
||||
manifest["archive"] = write_archive(payloads)
|
||||
with self.assertRaisesRegex(ValueError, "Cygwin input mismatch"):
|
||||
inputs.extract(manifest, archive, root / "rejected")
|
||||
self.assertFalse((root / "rejected").exists())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
195
.github/scripts/v8_canary_changes.py
vendored
Normal file
195
.github/scripts/v8_canary_changes.py
vendored
Normal file
@@ -0,0 +1,195 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Decide which V8 canary work is needed for a commit range.
|
||||
|
||||
The workflow deliberately has no trigger-level path filters because it is both
|
||||
directly triggered for pull requests and called by postmerge-ci. Keeping the
|
||||
patterns here gives those entrypoints one source of truth; unrelated events
|
||||
still run metadata but skip the expensive build matrices.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import tomllib
|
||||
from fnmatch import fnmatchcase
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
# These patterns replace the old pull_request/push path filters. Include parent
|
||||
# workflow changes because they can alter whether the canary is invoked.
|
||||
CANARY_PATH_PATTERNS = {
|
||||
".bazelrc",
|
||||
".github/actions/prepare-bazel-ci/**",
|
||||
".github/actions/setup-ci/**",
|
||||
".github/scripts/run_bazel_with_buildbuddy.py",
|
||||
".github/scripts/rusty_v8_bazel.py",
|
||||
".github/scripts/rusty_v8_module_bazel.py",
|
||||
".github/scripts/setup-dev-drive.ps1",
|
||||
".github/scripts/v8_canary_changes.py",
|
||||
".github/workflows/postmerge-ci.yml",
|
||||
".github/workflows/rusty-v8-release.yml",
|
||||
".github/workflows/v8-canary.yml",
|
||||
"MODULE.bazel",
|
||||
"MODULE.bazel.lock",
|
||||
"codex-rs/Cargo.toml",
|
||||
"codex-rs/v8-poc/**",
|
||||
"patches/BUILD.bazel",
|
||||
"patches/llvm_*.patch",
|
||||
"patches/rules_cc_*.patch",
|
||||
"patches/v8_*.patch",
|
||||
"third_party/v8/**",
|
||||
}
|
||||
# Windows source builds are a narrower, more expensive subset of the canary.
|
||||
# A V8 version change also requires them even when no path below changed.
|
||||
WINDOWS_SOURCE_BUILD_PATHS = {
|
||||
".github/actions/setup-ci/**",
|
||||
".github/scripts/rusty_v8_bazel.py",
|
||||
".github/scripts/rusty_v8_module_bazel.py",
|
||||
".github/scripts/setup-dev-drive.ps1",
|
||||
".github/scripts/v8_canary_changes.py",
|
||||
".github/workflows/rusty-v8-release.yml",
|
||||
".github/workflows/v8-canary.yml",
|
||||
"patches/v8_array_sort_elements_kind.patch",
|
||||
}
|
||||
|
||||
|
||||
def matching_canary_paths(changed_files: set[str]) -> set[str]:
|
||||
"""Return changed paths that require the general V8 build matrix."""
|
||||
return {
|
||||
path
|
||||
for path in changed_files
|
||||
if any(fnmatchcase(path, pattern) for pattern in CANARY_PATH_PATTERNS)
|
||||
}
|
||||
|
||||
|
||||
def canary_required(
|
||||
changed_files: set[str],
|
||||
base_v8_version: str,
|
||||
head_v8_version: str,
|
||||
*,
|
||||
force: bool = False,
|
||||
) -> bool:
|
||||
"""Return whether the general V8 build matrix should run."""
|
||||
return (
|
||||
force
|
||||
or base_v8_version != head_v8_version
|
||||
or bool(matching_canary_paths(changed_files))
|
||||
)
|
||||
|
||||
|
||||
def matching_windows_source_paths(changed_files: set[str]) -> set[str]:
|
||||
"""Return changed paths that require Windows rusty_v8 source builds."""
|
||||
return {
|
||||
path
|
||||
for path in changed_files
|
||||
if any(fnmatchcase(path, pattern) for pattern in WINDOWS_SOURCE_BUILD_PATHS)
|
||||
}
|
||||
|
||||
|
||||
def resolved_v8_version(cargo_lock: bytes) -> str:
|
||||
versions = sorted(
|
||||
{
|
||||
package["version"]
|
||||
for package in tomllib.loads(cargo_lock.decode())["package"]
|
||||
if package["name"] == "v8"
|
||||
}
|
||||
)
|
||||
if len(versions) != 1:
|
||||
raise ValueError(f"expected exactly one resolved v8 version, found: {versions}")
|
||||
return versions[0]
|
||||
|
||||
|
||||
def windows_source_required(
|
||||
changed_files: set[str],
|
||||
base_v8_version: str,
|
||||
head_v8_version: str,
|
||||
*,
|
||||
force: bool = False,
|
||||
) -> bool:
|
||||
"""Return whether Windows must rebuild rusty_v8 from source."""
|
||||
return (
|
||||
force
|
||||
or base_v8_version != head_v8_version
|
||||
or bool(matching_windows_source_paths(changed_files))
|
||||
)
|
||||
|
||||
|
||||
def git_output(*args: str, root: Path = ROOT) -> bytes:
|
||||
return subprocess.check_output(["git", *args], cwd=root)
|
||||
|
||||
|
||||
def v8_version_at_revision(revision: str, *, root: Path = ROOT) -> str:
|
||||
return resolved_v8_version(
|
||||
git_output("show", f"{revision}:codex-rs/Cargo.lock", root=root)
|
||||
)
|
||||
|
||||
|
||||
def merge_base(base: str, head: str, *, root: Path = ROOT) -> str:
|
||||
return git_output("merge-base", base, head, root=root).decode().strip()
|
||||
|
||||
|
||||
def changed_files(base: str, head: str, *, root: Path = ROOT) -> set[str]:
|
||||
# Three-dot diff gives PRs merge-base semantics while remaining equivalent
|
||||
# to before/after for ordinary linear pushes to main.
|
||||
output = git_output(
|
||||
"diff",
|
||||
"--name-only",
|
||||
"--no-renames",
|
||||
f"{base}...{head}",
|
||||
root=root,
|
||||
)
|
||||
return set(output.decode().splitlines())
|
||||
|
||||
|
||||
def parse_args() -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--base")
|
||||
parser.add_argument("--head")
|
||||
parser.add_argument("--force", action="store_true")
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def main() -> None:
|
||||
args = parse_args()
|
||||
if args.force:
|
||||
# workflow_dispatch has no comparison range, and callers use it as a
|
||||
# manual retry path, so it intentionally runs every variant.
|
||||
canary = True
|
||||
canary_reason = "manual workflow dispatch"
|
||||
windows_source = True
|
||||
windows_source_reason = "manual workflow dispatch"
|
||||
elif not args.base or not args.head:
|
||||
raise SystemExit("--base and --head are required unless --force is set")
|
||||
else:
|
||||
files = changed_files(args.base, args.head)
|
||||
base_version = v8_version_at_revision(merge_base(args.base, args.head))
|
||||
head_version = v8_version_at_revision(args.head)
|
||||
|
||||
matched_canary_paths = sorted(matching_canary_paths(files))
|
||||
canary = canary_required(files, base_version, head_version)
|
||||
windows_source = windows_source_required(files, base_version, head_version)
|
||||
if base_version != head_version:
|
||||
canary_reason = f"v8 version changed from {base_version} to {head_version}"
|
||||
windows_source_reason = canary_reason
|
||||
else:
|
||||
canary_reason = (
|
||||
", ".join(matched_canary_paths)
|
||||
if matched_canary_paths
|
||||
else "no relevant changes"
|
||||
)
|
||||
matched_windows_paths = sorted(matching_windows_source_paths(files))
|
||||
windows_source_reason = (
|
||||
", ".join(matched_windows_paths)
|
||||
if matched_windows_paths
|
||||
else "no relevant changes"
|
||||
)
|
||||
|
||||
print(f"canary_required={str(canary).lower()}")
|
||||
print(f"canary_reason={canary_reason}")
|
||||
print(f"windows_source_required={str(windows_source).lower()}")
|
||||
print(f"windows_source_reason={windows_source_reason}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
234
.github/scripts/verify_bazel_clippy_lints.py
vendored
Normal file
234
.github/scripts/verify_bazel_clippy_lints.py
vendored
Normal file
@@ -0,0 +1,234 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import re
|
||||
import sys
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
DEFAULT_CARGO_TOML = ROOT / "codex-rs" / "Cargo.toml"
|
||||
DEFAULT_BAZELRC = ROOT / ".bazelrc"
|
||||
BAZEL_CLIPPY_FLAG_PREFIX = "build:clippy --@rules_rust//rust/settings:clippy_flag="
|
||||
BAZEL_SPECIAL_FLAGS = {"-Dwarnings"}
|
||||
VALID_LEVELS = {"allow", "warn", "deny", "forbid"}
|
||||
LONG_FLAG_RE = re.compile(
|
||||
r"^--(?P<level>allow|warn|deny|forbid)=clippy::(?P<lint>[a-z0-9_]+)$"
|
||||
)
|
||||
SHORT_FLAG_RE = re.compile(r"^-(?P<level>[AWDF])clippy::(?P<lint>[a-z0-9_]+)$")
|
||||
SHORT_LEVEL_NAMES = {
|
||||
"A": "allow",
|
||||
"W": "warn",
|
||||
"D": "deny",
|
||||
"F": "forbid",
|
||||
}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(
|
||||
description=(
|
||||
"Verify that Bazel clippy flags in .bazelrc stay in sync with "
|
||||
"codex-rs/Cargo.toml [workspace.lints.clippy]."
|
||||
)
|
||||
)
|
||||
parser.add_argument(
|
||||
"--cargo-toml",
|
||||
type=Path,
|
||||
default=DEFAULT_CARGO_TOML,
|
||||
help="Path to the workspace Cargo.toml to inspect.",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--bazelrc",
|
||||
type=Path,
|
||||
default=DEFAULT_BAZELRC,
|
||||
help="Path to the .bazelrc file to inspect.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
cargo_toml = args.cargo_toml.resolve()
|
||||
bazelrc = args.bazelrc.resolve()
|
||||
|
||||
cargo_lints = load_workspace_clippy_lints(cargo_toml)
|
||||
bazel_lints = load_bazel_clippy_lints(bazelrc)
|
||||
|
||||
missing = sorted(cargo_lints.keys() - bazel_lints.keys())
|
||||
extra = sorted(bazel_lints.keys() - cargo_lints.keys())
|
||||
mismatched = sorted(
|
||||
lint
|
||||
for lint in cargo_lints.keys() & bazel_lints.keys()
|
||||
if cargo_lints[lint] != bazel_lints[lint]
|
||||
)
|
||||
|
||||
if missing or extra or mismatched:
|
||||
print_sync_error(
|
||||
cargo_toml=cargo_toml,
|
||||
bazelrc=bazelrc,
|
||||
cargo_lints=cargo_lints,
|
||||
bazel_lints=bazel_lints,
|
||||
missing=missing,
|
||||
extra=extra,
|
||||
mismatched=mismatched,
|
||||
)
|
||||
return 1
|
||||
|
||||
print(
|
||||
"Bazel clippy flags in "
|
||||
f"{display_path(bazelrc)} match "
|
||||
f"{display_path(cargo_toml)} [workspace.lints.clippy]."
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
def load_workspace_clippy_lints(cargo_toml: Path) -> dict[str, str]:
|
||||
workspace = tomllib.loads(cargo_toml.read_text())["workspace"]
|
||||
clippy_lints = workspace["lints"]["clippy"]
|
||||
parsed: dict[str, str] = {}
|
||||
for lint, level in clippy_lints.items():
|
||||
if not isinstance(level, str):
|
||||
raise SystemExit(
|
||||
f"expected string lint level for clippy::{lint} in {cargo_toml}, got {level!r}"
|
||||
)
|
||||
normalized = level.strip().lower()
|
||||
if normalized not in VALID_LEVELS:
|
||||
raise SystemExit(
|
||||
f"unsupported lint level {level!r} for clippy::{lint} in {cargo_toml}"
|
||||
)
|
||||
parsed[lint] = normalized
|
||||
return parsed
|
||||
|
||||
|
||||
def load_bazel_clippy_lints(bazelrc: Path) -> dict[str, str]:
|
||||
parsed: dict[str, str] = {}
|
||||
line_numbers: dict[str, int] = {}
|
||||
|
||||
for lineno, line in enumerate(bazelrc.read_text().splitlines(), start=1):
|
||||
if not line.startswith(BAZEL_CLIPPY_FLAG_PREFIX):
|
||||
continue
|
||||
|
||||
flag = line.removeprefix(BAZEL_CLIPPY_FLAG_PREFIX).strip()
|
||||
if flag in BAZEL_SPECIAL_FLAGS:
|
||||
continue
|
||||
|
||||
parsed_flag = parse_bazel_lint_flag(flag)
|
||||
if parsed_flag is None:
|
||||
continue
|
||||
|
||||
lint, level = parsed_flag
|
||||
if lint in parsed:
|
||||
raise SystemExit(
|
||||
f"duplicate Bazel clippy entry for clippy::{lint} at "
|
||||
f"{bazelrc}:{line_numbers[lint]} and {bazelrc}:{lineno}"
|
||||
)
|
||||
parsed[lint] = level
|
||||
line_numbers[lint] = lineno
|
||||
|
||||
return parsed
|
||||
|
||||
|
||||
def parse_bazel_lint_flag(flag: str) -> tuple[str, str] | None:
|
||||
long_match = LONG_FLAG_RE.match(flag)
|
||||
if long_match:
|
||||
return long_match["lint"], long_match["level"]
|
||||
|
||||
short_match = SHORT_FLAG_RE.match(flag)
|
||||
if short_match:
|
||||
return short_match["lint"], SHORT_LEVEL_NAMES[short_match["level"]]
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def print_sync_error(
|
||||
*,
|
||||
cargo_toml: Path,
|
||||
bazelrc: Path,
|
||||
cargo_lints: dict[str, str],
|
||||
bazel_lints: dict[str, str],
|
||||
missing: list[str],
|
||||
extra: list[str],
|
||||
mismatched: list[str],
|
||||
) -> None:
|
||||
cargo_toml_display = display_path(cargo_toml)
|
||||
bazelrc_display = display_path(bazelrc)
|
||||
example_manifest = find_workspace_lints_example_manifest()
|
||||
|
||||
print(
|
||||
"ERROR: Bazel clippy flags are out of sync with Cargo workspace clippy lints.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
print(file=sys.stderr)
|
||||
print(
|
||||
f"Cargo defines the source of truth in {cargo_toml_display} "
|
||||
"[workspace.lints.clippy].",
|
||||
file=sys.stderr,
|
||||
)
|
||||
if example_manifest is not None:
|
||||
print(
|
||||
"Cargo applies those lint levels to member crates that opt into "
|
||||
f"`[lints] workspace = true`, for example {example_manifest}.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
print(
|
||||
"Bazel clippy does not ingest Cargo lint levels automatically, and "
|
||||
"`clippy.toml` can configure lint behavior but cannot set allow/warn/deny/forbid.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
print(
|
||||
f"Update {bazelrc_display} so its `build:clippy` "
|
||||
"`clippy_flag` entries match Cargo.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
if missing:
|
||||
print(file=sys.stderr)
|
||||
print("Missing Bazel entries:", file=sys.stderr)
|
||||
for lint in missing:
|
||||
print(f" {render_bazelrc_line(lint, cargo_lints[lint])}", file=sys.stderr)
|
||||
|
||||
if mismatched:
|
||||
print(file=sys.stderr)
|
||||
print("Mismatched lint levels:", file=sys.stderr)
|
||||
for lint in mismatched:
|
||||
cargo_level = cargo_lints[lint]
|
||||
bazel_level = bazel_lints[lint]
|
||||
print(
|
||||
f" clippy::{lint}: Cargo has {cargo_level}, Bazel has {bazel_level}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
print(
|
||||
f" expected: {render_bazelrc_line(lint, cargo_level)}",
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
if extra:
|
||||
print(file=sys.stderr)
|
||||
print("Extra Bazel entries with no Cargo counterpart:", file=sys.stderr)
|
||||
for lint in extra:
|
||||
print(f" {render_bazelrc_line(lint, bazel_lints[lint])}", file=sys.stderr)
|
||||
|
||||
|
||||
def render_bazelrc_line(lint: str, level: str) -> str:
|
||||
return f"{BAZEL_CLIPPY_FLAG_PREFIX}--{level}=clippy::{lint}"
|
||||
|
||||
|
||||
def display_path(path: Path) -> str:
|
||||
try:
|
||||
return str(path.relative_to(ROOT))
|
||||
except ValueError:
|
||||
return str(path)
|
||||
|
||||
|
||||
def find_workspace_lints_example_manifest() -> str | None:
|
||||
for cargo_toml in sorted((ROOT / "codex-rs").glob("**/Cargo.toml")):
|
||||
if cargo_toml == DEFAULT_CARGO_TOML:
|
||||
continue
|
||||
data = tomllib.loads(cargo_toml.read_text())
|
||||
if data.get("lints", {}).get("workspace") is True:
|
||||
return str(cargo_toml.relative_to(ROOT))
|
||||
return None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
394
.github/scripts/verify_cargo_workspace_manifests.py
vendored
Normal file
394
.github/scripts/verify_cargo_workspace_manifests.py
vendored
Normal file
@@ -0,0 +1,394 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Verify that codex-rs Cargo manifests follow workspace manifest policy.
|
||||
|
||||
Checks:
|
||||
- Crates inherit `[workspace.package]` metadata.
|
||||
- Crates opt into `[lints] workspace = true`.
|
||||
- Crate names follow the codex-rs directory naming conventions.
|
||||
- Workspace manifests do not introduce workspace crate feature toggles.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
CARGO_RS_ROOT = ROOT / "codex-rs"
|
||||
WORKSPACE_PACKAGE_FIELDS = ("version", "edition", "license")
|
||||
TOP_LEVEL_NAME_EXCEPTIONS = {
|
||||
"windows-sandbox-rs": "codex-windows-sandbox",
|
||||
}
|
||||
UTILITY_NAME_EXCEPTIONS = {
|
||||
"path-utils": "codex-utils-path",
|
||||
}
|
||||
MANIFEST_FEATURE_EXCEPTIONS = {
|
||||
"codex-rs/v8-poc/Cargo.toml": {"sandbox": ("v8/v8_enable_sandbox",)},
|
||||
}
|
||||
OPTIONAL_DEPENDENCY_EXCEPTIONS = set()
|
||||
INTERNAL_DEPENDENCY_FEATURE_EXCEPTIONS = {}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
internal_package_names = workspace_package_names()
|
||||
used_manifest_feature_exceptions: set[str] = set()
|
||||
used_optional_dependency_exceptions: set[tuple[str, str, str]] = set()
|
||||
used_internal_dependency_feature_exceptions: set[tuple[str, str, str]] = set()
|
||||
failures_by_path: dict[str, list[str]] = {}
|
||||
|
||||
for path in manifests_to_verify():
|
||||
if errors := manifest_errors(
|
||||
path,
|
||||
internal_package_names,
|
||||
used_manifest_feature_exceptions,
|
||||
used_optional_dependency_exceptions,
|
||||
used_internal_dependency_feature_exceptions,
|
||||
):
|
||||
failures_by_path[manifest_key(path)] = errors
|
||||
|
||||
add_unused_exception_errors(
|
||||
failures_by_path,
|
||||
used_manifest_feature_exceptions,
|
||||
used_optional_dependency_exceptions,
|
||||
used_internal_dependency_feature_exceptions,
|
||||
)
|
||||
|
||||
if not failures_by_path:
|
||||
return 0
|
||||
|
||||
print(
|
||||
"Cargo manifests under codex-rs must inherit workspace package metadata, "
|
||||
"opt into workspace lints, and avoid introducing new workspace crate "
|
||||
"features."
|
||||
)
|
||||
print(
|
||||
"Workspace crate features are disallowed because our Bazel build setup "
|
||||
"does not honor them today, which can let issues hidden behind feature "
|
||||
"gates go unnoticed, and because they add extra crate build "
|
||||
"permutations we want to avoid."
|
||||
)
|
||||
print(
|
||||
"Cargo only applies `codex-rs/Cargo.toml` `[workspace.lints.clippy]` "
|
||||
"entries to a crate when that crate declares:"
|
||||
)
|
||||
print()
|
||||
print("[lints]")
|
||||
print("workspace = true")
|
||||
print()
|
||||
print(
|
||||
"Without that opt-in, `cargo clippy` can miss violations that Bazel clippy "
|
||||
"catches."
|
||||
)
|
||||
print()
|
||||
print(
|
||||
"Package-name checks apply to `codex-rs/<crate>/Cargo.toml` and "
|
||||
"`codex-rs/utils/<crate>/Cargo.toml`."
|
||||
)
|
||||
print(
|
||||
"Workspace crate features are forbidden; add a targeted exception here "
|
||||
"only if there is a deliberate temporary migration in flight."
|
||||
)
|
||||
print()
|
||||
for path in sorted(failures_by_path):
|
||||
errors = failures_by_path[path]
|
||||
print(f"{path}:")
|
||||
for error in errors:
|
||||
print(f" - {error}")
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
def manifest_errors(
|
||||
path: Path,
|
||||
internal_package_names: set[str],
|
||||
used_manifest_feature_exceptions: set[str],
|
||||
used_optional_dependency_exceptions: set[tuple[str, str, str]],
|
||||
used_internal_dependency_feature_exceptions: set[tuple[str, str, str]],
|
||||
) -> list[str]:
|
||||
manifest = load_manifest(path)
|
||||
package = manifest.get("package")
|
||||
if not isinstance(package, dict) and path != CARGO_RS_ROOT / "Cargo.toml":
|
||||
return []
|
||||
|
||||
errors = []
|
||||
if isinstance(package, dict):
|
||||
for field in WORKSPACE_PACKAGE_FIELDS:
|
||||
if not is_workspace_reference(package.get(field)):
|
||||
errors.append(f"set `{field}.workspace = true` in `[package]`")
|
||||
|
||||
lints = manifest.get("lints")
|
||||
if not (isinstance(lints, dict) and lints.get("workspace") is True):
|
||||
errors.append("add `[lints]` with `workspace = true`")
|
||||
|
||||
expected_name = expected_package_name(path)
|
||||
if expected_name is not None:
|
||||
actual_name = package.get("name")
|
||||
if actual_name != expected_name:
|
||||
errors.append(
|
||||
f"set `[package].name` to `{expected_name}` (found `{actual_name}`)"
|
||||
)
|
||||
|
||||
path_key = manifest_key(path)
|
||||
features = manifest.get("features")
|
||||
if features is not None:
|
||||
normalized_features = normalize_feature_mapping(features)
|
||||
expected_features = MANIFEST_FEATURE_EXCEPTIONS.get(path_key)
|
||||
if expected_features is None:
|
||||
errors.append(
|
||||
"remove `[features]`; new workspace crate features are not allowed"
|
||||
)
|
||||
else:
|
||||
used_manifest_feature_exceptions.add(path_key)
|
||||
if normalized_features != expected_features:
|
||||
errors.append(
|
||||
"limit `[features]` to the existing exception list while "
|
||||
"workspace crate features are being removed "
|
||||
f"(expected {render_feature_mapping(expected_features)})"
|
||||
)
|
||||
|
||||
for section_name, dependencies in dependency_sections(manifest):
|
||||
for dependency_name, dependency in dependencies.items():
|
||||
if not isinstance(dependency, dict):
|
||||
continue
|
||||
|
||||
if dependency.get("optional") is True:
|
||||
exception_key = (path_key, section_name, dependency_name)
|
||||
if exception_key in OPTIONAL_DEPENDENCY_EXCEPTIONS:
|
||||
used_optional_dependency_exceptions.add(exception_key)
|
||||
else:
|
||||
errors.append(
|
||||
"remove `optional = true` from "
|
||||
f"`{dependency_entry_label(section_name, dependency_name)}`; "
|
||||
"new optional dependencies are not allowed because they "
|
||||
"create crate features"
|
||||
)
|
||||
|
||||
if not is_internal_dependency(
|
||||
path, dependency_name, dependency, internal_package_names
|
||||
):
|
||||
continue
|
||||
|
||||
dependency_features = dependency.get("features")
|
||||
if dependency_features is not None:
|
||||
normalized_dependency_features = normalize_string_list(
|
||||
dependency_features
|
||||
)
|
||||
exception_key = (path_key, section_name, dependency_name)
|
||||
expected_dependency_features = (
|
||||
INTERNAL_DEPENDENCY_FEATURE_EXCEPTIONS.get(exception_key)
|
||||
)
|
||||
if expected_dependency_features is None:
|
||||
errors.append(
|
||||
"remove `features = [...]` from workspace dependency "
|
||||
f"`{dependency_entry_label(section_name, dependency_name)}`; "
|
||||
"new workspace crate feature activations are not allowed"
|
||||
)
|
||||
else:
|
||||
used_internal_dependency_feature_exceptions.add(exception_key)
|
||||
if normalized_dependency_features != expected_dependency_features:
|
||||
errors.append(
|
||||
"limit workspace dependency features on "
|
||||
f"`{dependency_entry_label(section_name, dependency_name)}` "
|
||||
"to the existing exception list while workspace crate "
|
||||
"features are being removed "
|
||||
f"(expected {render_string_list(expected_dependency_features)})"
|
||||
)
|
||||
|
||||
if dependency.get("default-features") is False:
|
||||
errors.append(
|
||||
"remove `default-features = false` from workspace dependency "
|
||||
f"`{dependency_entry_label(section_name, dependency_name)}`; "
|
||||
"new workspace crate feature toggles are not allowed"
|
||||
)
|
||||
|
||||
return errors
|
||||
|
||||
|
||||
def expected_package_name(path: Path) -> str | None:
|
||||
parts = path.relative_to(CARGO_RS_ROOT).parts
|
||||
if len(parts) == 2 and parts[1] == "Cargo.toml":
|
||||
directory = parts[0]
|
||||
return TOP_LEVEL_NAME_EXCEPTIONS.get(
|
||||
directory,
|
||||
directory if directory.startswith("codex-") else f"codex-{directory}",
|
||||
)
|
||||
if len(parts) == 3 and parts[0] == "utils" and parts[2] == "Cargo.toml":
|
||||
directory = parts[1]
|
||||
return UTILITY_NAME_EXCEPTIONS.get(directory, f"codex-utils-{directory}")
|
||||
return None
|
||||
|
||||
|
||||
def is_workspace_reference(value: object) -> bool:
|
||||
return isinstance(value, dict) and value.get("workspace") is True
|
||||
|
||||
|
||||
def manifest_key(path: Path) -> str:
|
||||
return str(path.relative_to(ROOT))
|
||||
|
||||
|
||||
def normalize_feature_mapping(value: object) -> dict[str, tuple[str, ...]] | None:
|
||||
if not isinstance(value, dict):
|
||||
return None
|
||||
|
||||
normalized = {}
|
||||
for key, features in value.items():
|
||||
if not isinstance(key, str):
|
||||
return None
|
||||
normalized_features = normalize_string_list(features)
|
||||
if normalized_features is None:
|
||||
return None
|
||||
normalized[key] = normalized_features
|
||||
return normalized
|
||||
|
||||
|
||||
def normalize_string_list(value: object) -> tuple[str, ...] | None:
|
||||
if not isinstance(value, list) or not all(isinstance(item, str) for item in value):
|
||||
return None
|
||||
return tuple(value)
|
||||
|
||||
|
||||
def render_feature_mapping(features: dict[str, tuple[str, ...]]) -> str:
|
||||
entries = [
|
||||
f"{name} = {render_string_list(items)}" for name, items in features.items()
|
||||
]
|
||||
return ", ".join(entries)
|
||||
|
||||
|
||||
def render_string_list(items: tuple[str, ...]) -> str:
|
||||
return "[" + ", ".join(f'"{item}"' for item in items) + "]"
|
||||
|
||||
|
||||
def dependency_sections(manifest: dict) -> list[tuple[str, dict]]:
|
||||
sections = []
|
||||
for section_name in ("dependencies", "dev-dependencies", "build-dependencies"):
|
||||
dependencies = manifest.get(section_name)
|
||||
if isinstance(dependencies, dict):
|
||||
sections.append((section_name, dependencies))
|
||||
|
||||
workspace = manifest.get("workspace")
|
||||
if isinstance(workspace, dict):
|
||||
workspace_dependencies = workspace.get("dependencies")
|
||||
if isinstance(workspace_dependencies, dict):
|
||||
sections.append(("workspace.dependencies", workspace_dependencies))
|
||||
|
||||
target = manifest.get("target")
|
||||
if not isinstance(target, dict):
|
||||
return sections
|
||||
|
||||
for target_name, tables in target.items():
|
||||
if not isinstance(tables, dict):
|
||||
continue
|
||||
for section_name in ("dependencies", "dev-dependencies", "build-dependencies"):
|
||||
dependencies = tables.get(section_name)
|
||||
if isinstance(dependencies, dict):
|
||||
sections.append((f"target.{target_name}.{section_name}", dependencies))
|
||||
|
||||
return sections
|
||||
|
||||
|
||||
def dependency_entry_label(section_name: str, dependency_name: str) -> str:
|
||||
return f"[{section_name}].{dependency_name}"
|
||||
|
||||
|
||||
def is_internal_dependency(
|
||||
manifest_path: Path,
|
||||
dependency_name: str,
|
||||
dependency: dict,
|
||||
internal_package_names: set[str],
|
||||
) -> bool:
|
||||
package_name = dependency.get("package", dependency_name)
|
||||
if isinstance(package_name, str) and package_name in internal_package_names:
|
||||
return True
|
||||
|
||||
dependency_path = dependency.get("path")
|
||||
if not isinstance(dependency_path, str):
|
||||
return False
|
||||
|
||||
resolved_dependency_path = (manifest_path.parent / dependency_path).resolve()
|
||||
try:
|
||||
resolved_dependency_path.relative_to(CARGO_RS_ROOT)
|
||||
except ValueError:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def add_unused_exception_errors(
|
||||
failures_by_path: dict[str, list[str]],
|
||||
used_manifest_feature_exceptions: set[str],
|
||||
used_optional_dependency_exceptions: set[tuple[str, str, str]],
|
||||
used_internal_dependency_feature_exceptions: set[tuple[str, str, str]],
|
||||
) -> None:
|
||||
for path_key in sorted(
|
||||
set(MANIFEST_FEATURE_EXCEPTIONS) - used_manifest_feature_exceptions
|
||||
):
|
||||
add_failure(
|
||||
failures_by_path,
|
||||
path_key,
|
||||
"remove the stale `[features]` exception from "
|
||||
"`MANIFEST_FEATURE_EXCEPTIONS`",
|
||||
)
|
||||
|
||||
for path_key, section_name, dependency_name in sorted(
|
||||
OPTIONAL_DEPENDENCY_EXCEPTIONS - used_optional_dependency_exceptions
|
||||
):
|
||||
add_failure(
|
||||
failures_by_path,
|
||||
path_key,
|
||||
"remove the stale optional-dependency exception for "
|
||||
f"`{dependency_entry_label(section_name, dependency_name)}` from "
|
||||
"`OPTIONAL_DEPENDENCY_EXCEPTIONS`",
|
||||
)
|
||||
|
||||
for path_key, section_name, dependency_name in sorted(
|
||||
set(INTERNAL_DEPENDENCY_FEATURE_EXCEPTIONS)
|
||||
- used_internal_dependency_feature_exceptions
|
||||
):
|
||||
add_failure(
|
||||
failures_by_path,
|
||||
path_key,
|
||||
"remove the stale internal dependency feature exception for "
|
||||
f"`{dependency_entry_label(section_name, dependency_name)}` from "
|
||||
"`INTERNAL_DEPENDENCY_FEATURE_EXCEPTIONS`",
|
||||
)
|
||||
|
||||
|
||||
def add_failure(
|
||||
failures_by_path: dict[str, list[str]], path_key: str, error: str
|
||||
) -> None:
|
||||
failures_by_path.setdefault(path_key, []).append(error)
|
||||
|
||||
|
||||
def workspace_package_names() -> set[str]:
|
||||
package_names = set()
|
||||
for path in cargo_manifests():
|
||||
manifest = load_manifest(path)
|
||||
package = manifest.get("package")
|
||||
if not isinstance(package, dict):
|
||||
continue
|
||||
package_name = package.get("name")
|
||||
if isinstance(package_name, str):
|
||||
package_names.add(package_name)
|
||||
return package_names
|
||||
|
||||
|
||||
def load_manifest(path: Path) -> dict:
|
||||
return tomllib.loads(path.read_text())
|
||||
|
||||
|
||||
def cargo_manifests() -> list[Path]:
|
||||
return sorted(
|
||||
path
|
||||
for path in CARGO_RS_ROOT.rglob("Cargo.toml")
|
||||
if path != CARGO_RS_ROOT / "Cargo.toml"
|
||||
)
|
||||
|
||||
|
||||
def manifests_to_verify() -> list[Path]:
|
||||
return [CARGO_RS_ROOT / "Cargo.toml", *cargo_manifests()]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
76
.github/scripts/verify_pypi_release.py
vendored
Normal file
76
.github/scripts/verify_pypi_release.py
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Wait for every Python release artifact to become visible on PyPI."""
|
||||
|
||||
import argparse
|
||||
import http.client
|
||||
import json
|
||||
import time
|
||||
import urllib.request
|
||||
|
||||
from packaging.version import Version
|
||||
|
||||
RUNTIME_PLATFORM_TAGS = {
|
||||
"macosx_10_9_x86_64",
|
||||
"macosx_11_0_arm64",
|
||||
"manylinux_2_17_aarch64",
|
||||
"manylinux_2_17_x86_64",
|
||||
"musllinux_1_1_aarch64",
|
||||
"musllinux_1_1_x86_64",
|
||||
"win_amd64",
|
||||
"win_arm64",
|
||||
}
|
||||
|
||||
|
||||
def verify_release(package: str, version: str) -> None:
|
||||
version = str(Version(version))
|
||||
name = package.replace("-", "_")
|
||||
if package == "openai-codex-cli-bin":
|
||||
expected = {
|
||||
f"{name}-{version}-py3-none-{tag}.whl" for tag in RUNTIME_PLATFORM_TAGS
|
||||
}
|
||||
else:
|
||||
expected = {f"{name}-{version}-py3-none-any.whl", f"{name}-{version}.tar.gz"}
|
||||
|
||||
for attempt in range(30):
|
||||
try:
|
||||
with urllib.request.urlopen(
|
||||
f"https://pypi.org/pypi/{package}/{version}/json", timeout=30
|
||||
) as response:
|
||||
data = json.load(response)
|
||||
if not isinstance(data, dict) or not isinstance(data.get("urls"), list):
|
||||
raise ValueError("Expected a PyPI response with a urls list")
|
||||
if any(
|
||||
not isinstance(file, dict)
|
||||
or not isinstance(file.get("filename"), str)
|
||||
for file in data["urls"]
|
||||
):
|
||||
raise ValueError("Expected each PyPI file to have a filename")
|
||||
actual = {file["filename"] for file in data["urls"]}
|
||||
except (
|
||||
OSError,
|
||||
http.client.HTTPException,
|
||||
ValueError,
|
||||
) as error:
|
||||
print(f"Could not read {package} {version} from PyPI: {error}.")
|
||||
else:
|
||||
if actual == expected:
|
||||
print(f"All {package} {version} files are available on PyPI.")
|
||||
return
|
||||
print(f"Missing files: {sorted(expected - actual)}")
|
||||
print(f"Unexpected files: {sorted(actual - expected)}")
|
||||
if attempt < 29:
|
||||
time.sleep(10)
|
||||
|
||||
raise SystemExit(f"{package} {version} files did not become available on PyPI.")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("package", choices=["openai-codex-cli-bin", "openai-codex"])
|
||||
parser.add_argument("version")
|
||||
args = parser.parse_args()
|
||||
verify_release(args.package, args.version)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
91
.github/scripts/verify_tui_core_boundary.py
vendored
Normal file
91
.github/scripts/verify_tui_core_boundary.py
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
"""Verify codex-tui does not depend on or import codex-core directly."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
import sys
|
||||
import tomllib
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
TUI_ROOT = ROOT / "codex-rs" / "tui"
|
||||
TUI_MANIFEST = TUI_ROOT / "Cargo.toml"
|
||||
FORBIDDEN_PACKAGE = "codex-core"
|
||||
FORBIDDEN_SOURCE_PATTERNS = (
|
||||
re.compile(r"\bcodex_core::"),
|
||||
re.compile(r"\buse\s+codex_core\b"),
|
||||
re.compile(r"\bextern\s+crate\s+codex_core\b"),
|
||||
)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
failures = []
|
||||
failures.extend(manifest_failures())
|
||||
failures.extend(source_failures())
|
||||
|
||||
if not failures:
|
||||
return 0
|
||||
|
||||
print("codex-tui must not depend on or import codex-core directly.")
|
||||
print(
|
||||
"Use the app-server protocol/client boundary instead; temporary embedded "
|
||||
"startup gaps belong behind codex_app_server_client::legacy_core."
|
||||
)
|
||||
print()
|
||||
for failure in failures:
|
||||
print(f"- {failure}")
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
def manifest_failures() -> list[str]:
|
||||
manifest = tomllib.loads(TUI_MANIFEST.read_text())
|
||||
failures = []
|
||||
for section_name, dependencies in dependency_sections(manifest):
|
||||
if FORBIDDEN_PACKAGE in dependencies:
|
||||
failures.append(
|
||||
f"{relative_path(TUI_MANIFEST)} declares `{FORBIDDEN_PACKAGE}` "
|
||||
f"in `[{section_name}]`"
|
||||
)
|
||||
return failures
|
||||
|
||||
|
||||
def dependency_sections(manifest: dict) -> list[tuple[str, dict]]:
|
||||
sections: list[tuple[str, dict]] = []
|
||||
for section_name in ("dependencies", "dev-dependencies", "build-dependencies"):
|
||||
dependencies = manifest.get(section_name)
|
||||
if isinstance(dependencies, dict):
|
||||
sections.append((section_name, dependencies))
|
||||
|
||||
for target_name, target in manifest.get("target", {}).items():
|
||||
if not isinstance(target, dict):
|
||||
continue
|
||||
for section_name in ("dependencies", "dev-dependencies", "build-dependencies"):
|
||||
dependencies = target.get(section_name)
|
||||
if isinstance(dependencies, dict):
|
||||
sections.append((f"target.{target_name}.{section_name}", dependencies))
|
||||
|
||||
return sections
|
||||
|
||||
|
||||
def source_failures() -> list[str]:
|
||||
failures = []
|
||||
for path in sorted(TUI_ROOT.glob("**/*.rs")):
|
||||
text = path.read_text()
|
||||
for line_number, line in enumerate(text.splitlines(), start=1):
|
||||
if any(pattern.search(line) for pattern in FORBIDDEN_SOURCE_PATTERNS):
|
||||
failures.append(
|
||||
f"{relative_path(path)}:{line_number} imports `codex_core`"
|
||||
)
|
||||
return failures
|
||||
|
||||
|
||||
def relative_path(path: Path) -> str:
|
||||
return str(path.relative_to(ROOT))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
98
.github/scripts/voice-cygwin-inputs.py
vendored
Normal file
98
.github/scripts/voice-cygwin-inputs.py
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
"""Verify the pinned Cygwin build-input archive before offline installation."""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
from pathlib import Path, PurePosixPath
|
||||
import shutil
|
||||
import tarfile
|
||||
|
||||
|
||||
def records(manifest):
|
||||
metadata = manifest["metadata"]
|
||||
if {item["file"] for item in metadata} != {
|
||||
"x86_64/setup.xz",
|
||||
"x86_64/setup.xz.sig",
|
||||
}:
|
||||
raise ValueError("signed setup metadata is required")
|
||||
entries = metadata + manifest["packages"]
|
||||
expected = {entry["file"]: entry for entry in entries}
|
||||
if len(expected) != len(entries):
|
||||
raise ValueError("duplicate Cygwin input")
|
||||
for name in expected:
|
||||
path = PurePosixPath(name)
|
||||
if (
|
||||
not path.parts
|
||||
or path.is_absolute()
|
||||
or ".." in path.parts
|
||||
or path.as_posix() != name
|
||||
or "\\" in name
|
||||
or ":" in name
|
||||
):
|
||||
raise ValueError(f"unsafe Cygwin input: {name}")
|
||||
return expected
|
||||
|
||||
|
||||
def extract(manifest, archive, destination):
|
||||
expected = records(manifest)
|
||||
pin = manifest["archive"]
|
||||
with archive.open("rb") as stream:
|
||||
if (
|
||||
archive.stat().st_size != pin["bytes"]
|
||||
or hashlib.file_digest(stream, "sha256").hexdigest() != pin["sha256"]
|
||||
):
|
||||
raise ValueError("Cygwin archive digest or size mismatch")
|
||||
stream.seek(0)
|
||||
with tarfile.open(fileobj=stream, mode="r:gz") as bundle:
|
||||
members = bundle.getmembers()
|
||||
if len(members) != len(expected) or {m.name for m in members} != set(
|
||||
expected
|
||||
):
|
||||
raise ValueError("missing, extra, or duplicate Cygwin inputs")
|
||||
for member in members:
|
||||
if not member.isfile() or member.issparse():
|
||||
raise ValueError(f"non-regular Cygwin input: {member.name}")
|
||||
with bundle.extractfile(member) as source:
|
||||
if (
|
||||
member.size != expected[member.name]["bytes"]
|
||||
or hashlib.file_digest(source, "sha512").hexdigest()
|
||||
!= expected[member.name]["sha512"]
|
||||
):
|
||||
raise ValueError(f"Cygwin input mismatch: {member.name}")
|
||||
destination.mkdir(parents=True)
|
||||
try:
|
||||
bundle.extractall(destination, members=members, filter="data")
|
||||
except BaseException:
|
||||
shutil.rmtree(destination)
|
||||
raise
|
||||
|
||||
|
||||
def check_installed(manifest, inventory):
|
||||
installed = sorted(
|
||||
tuple(line.split())
|
||||
for line in inventory.read_text().splitlines()
|
||||
if len(line.split()) == 2 and not line.startswith("Package ")
|
||||
)
|
||||
expected = sorted((item["name"], item["version"]) for item in manifest["packages"])
|
||||
if installed != expected:
|
||||
raise ValueError("installed Cygwin packages differ from reviewed inputs")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("command", choices=("extract", "check-installed"))
|
||||
parser.add_argument("--archive", type=Path)
|
||||
parser.add_argument("--directory", type=Path)
|
||||
parser.add_argument("--inventory", type=Path)
|
||||
args = parser.parse_args()
|
||||
pinned = json.loads(
|
||||
Path(__file__).with_name("voice-cygwin-snapshot.json").read_text()
|
||||
)
|
||||
if args.command == "extract":
|
||||
if args.archive is None or args.directory is None:
|
||||
parser.error("extract requires --archive and --directory")
|
||||
extract(pinned, args.archive, args.directory)
|
||||
else:
|
||||
if args.inventory is None:
|
||||
parser.error("check-installed requires --inventory")
|
||||
check_installed(pinned, args.inventory)
|
||||
145
.github/scripts/voice-cygwin-snapshot.json
vendored
Normal file
145
.github/scripts/voice-cygwin-snapshot.json
vendored
Normal file
@@ -0,0 +1,145 @@
|
||||
{
|
||||
"schemaVersion": 1,
|
||||
"sourceMirror": "https://mirrors.kernel.org/sourceware/cygwin/",
|
||||
"cacheDirectory": "https%3a%2f%2fmirrors.kernel.org%2fsourceware%2fcygwin%2f",
|
||||
"requestedPackages": [
|
||||
"bash",
|
||||
"make",
|
||||
"automake1.18",
|
||||
"coreutils",
|
||||
"diffutils",
|
||||
"findutils",
|
||||
"grep",
|
||||
"sed",
|
||||
"gawk"
|
||||
],
|
||||
"signingFingerprint": "56405CF6FCC81574682A5D561A698DE9E2E56300",
|
||||
"archive": {
|
||||
"tag": "voice-cygwin-108b38cf67cbb731",
|
||||
"name": "cygwin-build-inputs.tar.gz",
|
||||
"bytes": 62276721,
|
||||
"sha256": "108b38cf67cbb731801e5ca8d8412b8f349961e4e71d8e3d5a1768f1a8d15c50"
|
||||
},
|
||||
"metadata": [
|
||||
{
|
||||
"file": "x86_64/setup.xz",
|
||||
"bytes": 3598392,
|
||||
"sha512": "306bffefa1e86178d9c6ff78a8add2e1af3c96f7cd698d62b58d0237a568e1a9f1b30016ed5891f9fe1d1c8a1e58089c3d9cb8989eb7bed758a928f212078e25"
|
||||
},
|
||||
{
|
||||
"file": "x86_64/setup.xz.sig",
|
||||
"bytes": 566,
|
||||
"sha512": "7c466da6446bbef67762ff4038dd4986018ed09432bd6ee6ca9e33150874dbb9d61c7e4b06bd925f932a55fda345401224689bbaddc135d7300651f67ec8160b"
|
||||
}
|
||||
],
|
||||
"sourceArchive": {
|
||||
"name": "cygwin-build-sources.tar",
|
||||
"bytes": 368824320,
|
||||
"sha256": "13a42ea4e6465f77c32f91e4162f41bcfeab7c0eca47701bb6a8b9aca1eb99f4"
|
||||
},
|
||||
"packages": [
|
||||
{"name": "_autorebase", "version": "001091-1", "file": "noarch/release/_autorebase/_autorebase-001091-1.tar.zst", "bytes": 4696, "sha512": "a9416ce992ca57f3a6208f46517520d21dfac61988ac84cbb5b17b76e053a0845c15368ccb8ca9c483d8935f9e3db81568433c0d08d0265ec5e6916ea30f2831"},
|
||||
{"name": "alternatives", "version": "1.31-1", "file": "x86_64/release/alternatives/alternatives-1.31-1.tar.xz", "bytes": 123748, "sha512": "94adf3376e7fcaf937594be718f54a99f2a2b66367eb2bb294b6fd4a933a9515954a9e9f309ed74cc62fbb353adb053d8500bbaf42994e4355f7180664afa62c"},
|
||||
{"name": "autoconf", "version": "15-3", "file": "noarch/release/autoconf/autoconf-15-3-noarch.tar.zst", "bytes": 2396, "sha512": "edaa6c97c5b50e138acef4b80406bfdd0988da3360cc622be2541593f6e926a4fbe1088ff608ddadfacf275b3924605d54f59e140cc7c79b31f4885e5878ad6f"},
|
||||
{"name": "autoconf2.1", "version": "2.13-12", "file": "noarch/release/autoconf2.1/autoconf2.1-2.13-12.tar.bz2", "bytes": 204911, "sha512": "96f8f592fff4665512c0023d6a7844fdc281ba99dc98dee9e55c37523b3a1279ae8fd31559fa6426edb1da7559a483b3eae99ae7911d50646ec60338ef209c18"},
|
||||
{"name": "autoconf2.5", "version": "2.69-5", "file": "noarch/release/autoconf2.5/autoconf2.5-2.69-5.tar.zst", "bytes": 341597, "sha512": "3739719f29ad3ab1c1045b72ccbfe6c58e3f7696ac063c2ff4e09e11e1a9015f289fa8fc267a62b43cb2f6b682b83d3b4b6450040e733f9f41d086dc4a2f36b9"},
|
||||
{"name": "autoconf2.7", "version": "2.73-1", "file": "noarch/release/autoconf2.7/autoconf2.7-2.73-1-noarch.tar.zst", "bytes": 906344, "sha512": "0493d68a7ea9cd61e403b6b7086b5302bad5bc1cc35715349f59605a795ac7a9f901c444cb387e5f44d1860de3e5d0fcfceee4ee2726d68904cfc5e2db6e90e9"},
|
||||
{"name": "automake1.18", "version": "1.18.1-1", "file": "noarch/release/automake1.18/automake1.18-1.18.1-1-noarch.tar.zst", "bytes": 921189, "sha512": "416ef8041505ecddc23e9e72394ef3a81311c6c378b8b6d348e989584c77924d40aa427b47ab4d3a9a2b83438d13995bb7c6302afb73af3d3af7f2e9061579c0"},
|
||||
{"name": "base-cygwin", "version": "3.8-2", "file": "noarch/release/base-cygwin/base-cygwin-3.8-2.tar.xz", "bytes": 1260, "sha512": "e03949b4ae6b692858e1d29fb764afbda990c07a6b70b0eb7219fc12f28dfba3cf7e757a7570c31e315be79f091b012d6a6ddafdb4b0b8961afe9af9f4977fab"},
|
||||
{"name": "base-files", "version": "4.3-3", "file": "noarch/release/base-files/base-files-4.3-3.tar.zst", "bytes": 46481, "sha512": "dfafbe28fbe89d9b72a2eeb10901712e04de71d9089a85cfd2b8d45ffd739bdd49dadb7b57d098f01b8902456f5b839e9d4a10dbd6a8001573e035fde6797b63"},
|
||||
{"name": "bash", "version": "5.2.21-1", "file": "x86_64/release/bash/bash-5.2.21-1.tar.xz", "bytes": 1650932, "sha512": "c3a5594f1c248dd27a3b5aa10c31fb1651072eae878479d3d8cab09c28354ce4509a2fe230f176ad200a6484a561bc10c2dc9c74c4e9f03164190dac2e683d65"},
|
||||
{"name": "bzip2", "version": "1.0.8-2", "file": "x86_64/release/bzip2/bzip2-1.0.8-2-x86_64.tar.xz", "bytes": 36396, "sha512": "86e4b0b21b64d17b9fb60260a787626125102b0cb786de67893cb1d39a109457637bdb93956c992429f1135f64b07def64dd0116682a6190b635ba12f81395d7"},
|
||||
{"name": "ca-certificates", "version": "2025.2.80_v9.0.304-1", "file": "noarch/release/ca-certificates/ca-certificates-2025.2.80_v9.0.304-1-noarch.tar.zst", "bytes": 902180, "sha512": "49d08f490db12855f8794cd5cfc721940504d36deffdd3b9aea0fc75909e27471f795d48c739630498fd4baeecb76ee0adb5e5c4cecab4db2ea39b03391a02d0"},
|
||||
{"name": "coreutils", "version": "9.0-1", "file": "x86_64/release/coreutils/coreutils-9.0-1.tar.xz", "bytes": 2767296, "sha512": "530f47640d878f5953580f3556c492a93786191abe573322026b70206a46c7f17d05927784db3e7f2c044d1555f35941880316f7288b887eaec770a9eda4c687"},
|
||||
{"name": "crypto-policies", "version": "20190218-1", "file": "noarch/release/crypto-policies/crypto-policies-20190218-1.tar.xz", "bytes": 14032, "sha512": "44d50ff08528df786eeb26ec1d312445ec92d77ecc9f448a3b741f7647e187f11eabdc0b38f8ab8de803e21d2e610f67eb44de7554f3fa83f6e8172e609b0054"},
|
||||
{"name": "cygutils", "version": "1.4.17-4", "file": "x86_64/release/cygutils/cygutils-1.4.17-4-x86_64.tar.xz", "bytes": 90580, "sha512": "a9c63f8ac86e529fa8809c9637bb80651721003160726e2058c361687e5df6377c4cdbea2d023677b23e1d166bbce37d5a412f7d1135baf075ae2631fdeb77b2"},
|
||||
{"name": "cygwin", "version": "3.6.10-1", "file": "x86_64/release/cygwin/cygwin-3.6.10-1-x86_64.tar.xz", "bytes": 1626060, "sha512": "50e5a100f5229eecba279799363a30d599f8c6ad06967eabc4fc8ed9105736576a522539abc250110282cf18da8536d4e408823cc6c0d2abd8692a91d9fd3341"},
|
||||
{"name": "dash", "version": "0.5.12-5", "file": "x86_64/release/dash/dash-0.5.12-5.tar.xz", "bytes": 79612, "sha512": "8891165224ca8531ad7b601309bc1a74f8b68dad24721060fd3db5d12ae504e3c96bbd0217006bbcbe0650d13283f04c1f58412bde54c40f19acb5291dfaced9"},
|
||||
{"name": "diffutils", "version": "3.12-1", "file": "x86_64/release/diffutils/diffutils-3.12-1-x86_64.tar.xz", "bytes": 431400, "sha512": "2a9d8fa0acd5a6108f74afe515f55a2a7cade6fa7f96368e46a6f33cf3b49d270b50dc3cee0320740c8f1729edcbf8dd3824f4b268261fba7aeed0d75a4e943c"},
|
||||
{"name": "editrights", "version": "1.04-1", "file": "x86_64/release/editrights/editrights-1.04-1.tar.xz", "bytes": 7112, "sha512": "aadc188201441ee1ff5710df0e5550c8ca5cb65421d025c5845921510560a2875c317d1f35b6ea8abbb5077172c0de7fc8f2f55ae95dc8d1e59d26c963c93aa7"},
|
||||
{"name": "file", "version": "5.46-1", "file": "x86_64/release/file/file-5.46-1-x86_64.tar.xz", "bytes": 840940, "sha512": "e4b52477d353557d36af625a6a55c97a11ae41053ce17602624210df2a6d2683f46250c2b9f6db5a9f9e5fcccb7b0be4b24705a36d196cee677bf47d90dfee99"},
|
||||
{"name": "findutils", "version": "4.11.0-1", "file": "x86_64/release/findutils/findutils-4.11.0-1-x86_64.tar.xz", "bytes": 768172, "sha512": "cbb1359fd81c55f98da1485f84f11f905a7a3fe9ce1676424e86da4d7f0effa5fc298546bd5c62c9707e8ddf93c31597d6da01e60be0610c50b9b22ef9475814"},
|
||||
{"name": "gawk", "version": "5.4.0-1", "file": "x86_64/release/gawk/gawk-5.4.0-1-x86_64.tar.xz", "bytes": 1496256, "sha512": "3604c99921d0cff387279aec1d3b332e8afcd2746b052304c0511221efdb6ae6d4a3117b36593e44adc43c67b6f6c4c48bccf6b686e2e1a5cac644c89613d829"},
|
||||
{"name": "getent", "version": "2.18.90-5", "file": "x86_64/release/getent/getent-2.18.90-5.tar.xz", "bytes": 17864, "sha512": "b860f3d01f32da7312a0ce118bdaa53e2418c53f0ac5cfd52b3e4267f353fa21ae27fd2649eb9c6bff48b3d10a0a9f7bcaa2d644f770f0f3916f5d969beedd65"},
|
||||
{"name": "gettext-locale-alias", "version": "0.26-1", "file": "x86_64/release/gettext/gettext-locale-alias/gettext-locale-alias-0.26-1-x86_64.tar.xz", "bytes": 1596, "sha512": "289feafbe00598a2451527b64b0187ab62115577ceaa960774b020270e5a8c5bff4038f389a44c7d9eb870f7e2741c7bb2b27be507843cc8c4ae5c33bc74c8f3"},
|
||||
{"name": "grep", "version": "3.12-1", "file": "x86_64/release/grep/grep-3.12-1-x86_64.tar.xz", "bytes": 418788, "sha512": "2ba28b5d93c352bc3f3f0f232e2052e6651b71cc535841f4ff8cedb23e61e9e4c030d7d5516ed9c797074e1a59cbf3a56732ca678cb0e986e86dcbbf25955976"},
|
||||
{"name": "groff", "version": "1.24.1-1", "file": "x86_64/release/groff/groff-1.24.1-1-x86_64.tar.zst", "bytes": 5878965, "sha512": "9e8aaab0e6f464df3fec6b96fed6679673091aaeafaa463ed518081cb156ef7441fb5f9341a251f602334862640ea0b0fc1b158746c08a1e2529cceeb37e9802"},
|
||||
{"name": "gzip", "version": "1.14-1", "file": "x86_64/release/gzip/gzip-1.14-1-x86_64.tar.xz", "bytes": 164124, "sha512": "57995d2e90bf435ffff8f61cd79c4970ad7260e0c407ab52d4dbacb0540a74c7f8fd0d8bd905316eff31525d9b0367284f9f250950f78f179e5260ce59be3a98"},
|
||||
{"name": "hostname", "version": "3.13-1", "file": "x86_64/release/hostname/hostname-3.13-1.tar.bz2", "bytes": 14024, "sha512": "75114326fa4575b8341434658a881feb81a6565e7e0adf8fd100dde87022d3818b5fc3df430bd9b3298d818a1d23f6b6c4bc7ff33efb3ded5f0ea0bf118c1aae"},
|
||||
{"name": "info", "version": "7.3-1", "file": "x86_64/release/texinfo/info/info-7.3-1-x86_64.tar.zst", "bytes": 607040, "sha512": "3af0e7c2edc34a068d88974c6c1b0f529663f4bbce145b5a33f3b7e90671fd908fb4a544e033b98a6906d3244c64a18732104c5f1d323c0ccac8a5134e13f411"},
|
||||
{"name": "ipc-utils", "version": "1.1-1", "file": "x86_64/release/ipc-utils/ipc-utils-1.1-1.tar.xz", "bytes": 11120, "sha512": "374ef40c871d00eb3b4774c383bb85872443a2e8b9abf74b8b9b9b27984598abfb6284716c2d2cd264181e6d012cf7dc8cd04f6bab91f9b083f72e9b51e6226b"},
|
||||
{"name": "less", "version": "704-1", "file": "x86_64/release/less/less-704-1-x86_64.tar.xz", "bytes": 171024, "sha512": "2d1ecf29272e7c1781bb0df5b0f0531b009972edc8d246d63e17edf7d8314109f0a8f38668b371c6f5e1dc1f948d63384eecdca5409eacb927c4f267f89f4bfe"},
|
||||
{"name": "libargp", "version": "20250917-2", "file": "x86_64/release/libargp/libargp-20250917-2-x86_64.tar.xz", "bytes": 19508, "sha512": "a83ef7c1809cae1b10a50e228643a640ea14e1be324429b9f53be9a4c8cee03ddd0efb46b24e159493dfa36569e73b636bc897943d61cdb90511e5e4cbb54257"},
|
||||
{"name": "libattr1", "version": "2.5.2-2", "file": "x86_64/release/attr/libattr1/libattr1-2.5.2-2-x86_64.tar.xz", "bytes": 6160, "sha512": "345b8f84b9c4df2eeea5e211dbaff5e0382aaee788435e1f4cc69f546e1603bbb45e9baec02a37d935674fcd55fb782d924c3a1540d2f829bde4969c96945ce4"},
|
||||
{"name": "libblkid1", "version": "2.40.2-2", "file": "x86_64/release/util-linux/libblkid1/libblkid1-2.40.2-2.tar.xz", "bytes": 120936, "sha512": "d931c47cce5a7caf18799a16ed526e0f0d0f82c0f6d0af952420d50d88f1e0f0ea9d6c07be72f9d0baa06a3299b2db8c3bd3c43d13d94400edc816e7c00da148"},
|
||||
{"name": "libbz2_1", "version": "1.0.8-2", "file": "x86_64/release/bzip2/libbz2_1/libbz2_1-1.0.8-2-x86_64.tar.xz", "bytes": 26884, "sha512": "d15d88e8e0fae69f7c4c3025515e748c273d758a0f470312162cec46c4cf0d340d2ef036e3a4f4d03b5edf4508b4927834ffa0f9aa45585a5f3bc3b3163ff675"},
|
||||
{"name": "libcrypt2", "version": "4.5.2-1", "file": "x86_64/release/libxcrypt/libcrypt2/libcrypt2-4.5.2-1-x86_64.tar.xz", "bytes": 106104, "sha512": "7668d29aaebba8ca94e48e810d92108db72b067b2786cea8dcf4a049c29f20f0aeb8653a6e9524869c69e0b1df9d4d0ac499a052a86f0d44178e8a8167002c97"},
|
||||
{"name": "libdb18.1", "version": "18.1.40-1", "file": "x86_64/release/db/libdb18.1/libdb18.1-18.1.40-1.tar.xz", "bytes": 733872, "sha512": "51955ae95823c54051b5345a7dbe6927521411754dff416ad6af2061bd3c9b2230ca2ea88f9b921b4b09b7654c7dac924b0ae08af708a93604cc193d6a18f4ff"},
|
||||
{"name": "libfdisk1", "version": "2.40.2-2", "file": "x86_64/release/util-linux/libfdisk1/libfdisk1-2.40.2-2.tar.xz", "bytes": 160264, "sha512": "0c8e6854eb72bb8cc51fc33565ee0d36a747e520e98e074a1d2400672a45651807b53be0f5a1c97efa0ce34975063f86953c9465312dcfdaba8104edb1298d62"},
|
||||
{"name": "libffi8", "version": "3.8.0-1", "file": "x86_64/release/libffi/libffi8/libffi8-3.8.0-1-x86_64.tar.xz", "bytes": 196924, "sha512": "935a0567f740a314d70ecd4adc8c4cf5ad37c6fb43f2d26dee882d4fda71f08efb2646bee10cee6e2000f52e25cce87fa29ce07665ba6d22532e0daa76bc887c"},
|
||||
{"name": "libgc1", "version": "8.2.12-1", "file": "x86_64/release/libgc/libgc1/libgc1-8.2.12-1-x86_64.tar.xz", "bytes": 62392, "sha512": "faf226ea2b58949da714e2c50f1aa95738082c3499e2ae4828af5173bdd617248f000bf4868636b31a2b76b3a905057ab307c4f6a0d7112f23422531a97be92d"},
|
||||
{"name": "libgcc1", "version": "14.4.0-1", "file": "x86_64/release/gcc/libgcc1/libgcc1-14.4.0-1-x86_64.tar.zst", "bytes": 59166, "sha512": "5ac8a56e5eee285efcd6dbd05a473e795e181021d7194b8a98dfe2fa201a71f0abe2908e0b4c81490eb5ef472efaeac8e56a61a5f289eee4ad6e90e52a844ff8"},
|
||||
{"name": "libgdbm6", "version": "1.26-1", "file": "x86_64/release/gdbm/libgdbm6/libgdbm6-1.26-1-x86_64.tar.xz", "bytes": 25436, "sha512": "8ed666a5b978b40f8cfc69d270d47cd674a31eb41bac499f783137eedfde6aa02ba4346de3d5dc3184d9af10ec80f57730c7517a88732616f4c6e0ef637d4bce"},
|
||||
{"name": "libgdbm_compat4", "version": "1.26-1", "file": "x86_64/release/gdbm/libgdbm_compat4/libgdbm_compat4-1.26-1-x86_64.tar.xz", "bytes": 3892, "sha512": "fd026dd74c495c1ee67b790269e77e8525ad78d52d4895923443feab55f7bb32dc07b115d490143c7e0277167d9cdbef5dad4707ecc7ca6df13a9f1a5184f8ca"},
|
||||
{"name": "libgmp10", "version": "6.3.0-1", "file": "x86_64/release/gmp/libgmp10/libgmp10-6.3.0-1.tar.zst", "bytes": 254680, "sha512": "947cd56e1945ddf180622b453f17e6655b4ee3e79fcc91238370a8826b88cd07c31d939f1ed7b87d91344d46fee90af2560105267a9207dcca800cba72459191"},
|
||||
{"name": "libguile3.0_1", "version": "3.0.11-1", "file": "x86_64/release/guile3.0/libguile3.0_1/libguile3.0_1-3.0.11-1-x86_64.tar.xz", "bytes": 6969492, "sha512": "a559914ed5d62d0a701e4ce3810276436cf1ce54d579c72fc72c3b4688f2af71ef93f3cdae7089ad7f85107c7ca5c87f2e497cac6f2550b38df1bc6ba7f16230"},
|
||||
{"name": "libiconv2", "version": "1.19-2", "file": "x86_64/release/libiconv/libiconv2/libiconv2-1.19-2-x86_64.tar.xz", "bytes": 555664, "sha512": "a1b23e24e0a495e7163923bcf40a4b933403e0826cfc0d9bde785bc92c909b8c4fb94b1e6b2c0242f4328a723855e72ff3baab9f557ef855b7fe7a7d901b0943"},
|
||||
{"name": "libintl8", "version": "0.22.5-1", "file": "x86_64/release/gettext/libintl8/libintl8-0.22.5-1.tar.xz", "bytes": 43256, "sha512": "370a19af888bc7c9ed95cf8ade0d36d5e7cdb634abdebcba260cad61fa9a4cc05b5e748e315c9709f66861e8756b227d6757d529846591189e19ee2b2d00002d"},
|
||||
{"name": "liblastlog2", "version": "2.40.2-2", "file": "x86_64/release/util-linux/liblastlog2/liblastlog2-2.40.2-2.tar.xz", "bytes": 4908, "sha512": "89350921fe76c9065662dd9d72dd464d2f404f1690e806210cbb828ae8325ea5f3f9909d8eb04c8342b80417a4e1e22c3569241515762ad081ecd58d56927c02"},
|
||||
{"name": "liblz4_1", "version": "1.9.4-1", "file": "x86_64/release/lz4/liblz4_1/liblz4_1-1.9.4-1.tar.xz", "bytes": 53296, "sha512": "70e6b0f3af2c5e04089c955b46c13293ab935ee4683e4690da0cebfffba4ba91614004aede99dd804f54e4def93461159f55d151e7fbb647d1ca97ca29e619cc"},
|
||||
{"name": "liblzma5", "version": "5.8.3-1", "file": "x86_64/release/xz/liblzma5/liblzma5-5.8.3-1-x86_64.tar.zst", "bytes": 87321, "sha512": "7399c6d117f23788a7edb11cf7f5eec77724aad2bf7cf8a437001fc1515941f6ca415f42363981be35361290f43cd60cd04e15bb1b01cffc0fd275f3167037e0"},
|
||||
{"name": "libmpfr6", "version": "4.2.2-1", "file": "x86_64/release/mpfr/libmpfr6/libmpfr6-4.2.2-1.tar.zst", "bytes": 284416, "sha512": "8203dc61bf646041c71f7fece9fe59422ded96ac28dd24826ffb00a9607f274f3226673f9bee441f32b424a7e26c2f178281bd7836db26b0253d37da208d06a8"},
|
||||
{"name": "libncursesw10", "version": "6.5+20240427-1", "file": "x86_64/release/ncurses/libncursesw10/libncursesw10-6.5+20240427-1.tar.xz", "bytes": 393928, "sha512": "08102f7a7083cb5663fecc46d819f2ece4123444a8f94c42300f03f7eebd40395f556c44b22ab58bf57321b44d9b8fb8b19358e535c7500d36e52d48b05dcca8"},
|
||||
{"name": "libp11-kit0", "version": "0.26.5-1", "file": "x86_64/release/p11-kit/libp11-kit0/libp11-kit0-0.26.5-1-x86_64.tar.xz", "bytes": 212700, "sha512": "dd64f129fe71233e26e0845b6711db5cf2eb2e6d2d050f07b6aec0d9dd54d980e87390614744fbf022cf57aa2b3f7edbdc30c548c2f9d480188c22bcde0c2eba"},
|
||||
{"name": "libpcre1", "version": "8.45-1", "file": "x86_64/release/pcre/libpcre1/libpcre1-8.45-1.tar.zst", "bytes": 166711, "sha512": "85c793ed3622a00b811773b94c45376882513e267b9f1d2a3efa0bc42ff86a4e4bebd8362a193d302e66ae9e5c9b93befc1bb1096c0fd397e2cd0f5632c808dd"},
|
||||
{"name": "libpcre2_8_0", "version": "10.47-1", "file": "x86_64/release/pcre2/libpcre2_8_0/libpcre2_8_0-10.47-1-x86_64.tar.zst", "bytes": 237134, "sha512": "a98b38e1591c19404a5794cef488810747d86cc27ce5ee326e706cfa7069cf088d8a64571933f4c1f7a611fd8c232008837271bebe2e81c04a3f6ec571f0009e"},
|
||||
{"name": "libpipeline1", "version": "1.5.8-1", "file": "x86_64/release/libpipeline/libpipeline1/libpipeline1-1.5.8-1-x86_64.tar.xz", "bytes": 24880, "sha512": "1d062ac4909d37fbac3ce66b07ac691df0ae5acbd01f08c5019a5ed897cb2bbef95f9e347c5bc71185ae3317d89383306e46f2c59acae5d28a18fa65f66d4e80"},
|
||||
{"name": "libpopt-common", "version": "1.19-1", "file": "x86_64/release/popt/libpopt-common/libpopt-common-1.19-1.tar.xz", "bytes": 18536, "sha512": "4d69e6d7e196cdb4caad558c5d7543f706a4c6d7053476be861be07672506e378084126f22903deab8113557f757d2a07578f4a790ae316a2ea50ba612148a43"},
|
||||
{"name": "libpopt0", "version": "1.19-1", "file": "x86_64/release/popt/libpopt0/libpopt0-1.19-1.tar.xz", "bytes": 18748, "sha512": "e820a7bac13cdd3bff07673ac54dcb80f342c6a32917035f218ef255bdb707d654ee6a1684242d7ce8439eebf050ade6566f27f5118896fbf8e0171173b5bfee"},
|
||||
{"name": "libreadline7", "version": "8.2-2", "file": "x86_64/release/readline/libreadline7/libreadline7-8.2-2.tar.xz", "bytes": 113340, "sha512": "1d27576cf49b056f35f90ad933e39c5d946bc271ddcd109daa98f95b97123b428256827889ff45ca8a76409cdb1afd0146e99c9b70150b302538356512acfe38"},
|
||||
{"name": "libreadline8", "version": "8.3-1", "file": "x86_64/release/readline/libreadline8/libreadline8-8.3-1-x86_64.tar.xz", "bytes": 120084, "sha512": "64142c5f305b9836c5be9a4271e4163d8b3e739a0451c0d152373eeb3338342f7cf5691e4437b8e6d0a8404c30ea7a21832e342e7a1ca3b5f3e8e3403051b96e"},
|
||||
{"name": "libsmartcols1", "version": "2.40.2-2", "file": "x86_64/release/util-linux/libsmartcols1/libsmartcols1-2.40.2-2.tar.xz", "bytes": 96124, "sha512": "71ded6f02d264343d068b90450d96f4fdeb4087f278b990709aaa814c16123f4ae947714e5f10020260c30a6d78865c2d35d9ffe57a51b038815db52c3274317"},
|
||||
{"name": "libsqlite3_0", "version": "3.49.1-1", "file": "x86_64/release/sqlite3/libsqlite3_0/libsqlite3_0-3.49.1-1.tar.xz", "bytes": 686212, "sha512": "cd81686fe5778a94ab91e4aebdd2a229cb963318ce7b393e0a0299e29ed7648c24135733c1978cbebbb926813d7f994b9e38318ede12c72fe79ad404dbfdeaf2"},
|
||||
{"name": "libssl3", "version": "3.5.7-1", "file": "x86_64/release/openssl/libssl3/libssl3-3.5.7-1-x86_64.tar.zst", "bytes": 2081790, "sha512": "18161f1292404554742ced4beaa10548c7e1bbfb9398ec0b733e632401dfaa49c33336ad4b1e80e2b7bd77c20f00c10196c5804c327e37f641d49da2288837b8"},
|
||||
{"name": "libstdc++6", "version": "14.4.0-1", "file": "x86_64/release/gcc/libstdc++6/libstdc++6-14.4.0-1-x86_64.tar.zst", "bytes": 651767, "sha512": "3d86409193c952618eee7e2dea32bdeb97f22ee800e13cc46f98b5095d4d0b1b31ac4336dc5819abb2d553ad1c2151619e9f6f337dfe921ba80fda1323f6f4e3"},
|
||||
{"name": "libtasn1_6", "version": "4.21.0-1", "file": "x86_64/release/libtasn1/libtasn1_6/libtasn1_6-4.21.0-1-x86_64.tar.xz", "bytes": 32072, "sha512": "d28713b27d5d41408b29caed785e29380da4d8b4ccdc1c479ae13906e6765bedc6d6b9e6c1c22fd2111d678fcf1663187d3de27d7ad2e104cd48c38086189e36"},
|
||||
{"name": "libuchardet0", "version": "0.0.8-1", "file": "x86_64/release/uchardet/libuchardet0/libuchardet0-0.0.8-1.tar.zst", "bytes": 72637, "sha512": "1fad5711590a82a8386c2492286dd9c0ad7cbe086aab249d07ad27277757327a6a67264e9718aef7d30307515462fe67d64f23582f08f0ced85a19cc8e0afe23"},
|
||||
{"name": "libunistring-devel", "version": "1.4.1-1", "file": "x86_64/release/libunistring/libunistring-devel/libunistring-devel-1.4.1-1-x86_64.tar.xz", "bytes": 43332, "sha512": "14e067719e5c0a973950955a05685c18d6fa97df5defa8d0915125ea3af1d01ac921c2a84565a49cc7fb785b15a8be4640ee209f3f0d2e13cb542eb6c75b51f9"},
|
||||
{"name": "libunistring5", "version": "1.4.1-1", "file": "x86_64/release/libunistring/libunistring5/libunistring5-1.4.1-1-x86_64.tar.xz", "bytes": 498220, "sha512": "cbd454f5068bfb9291d440a3b03b0c58437aa0342a199007d5cce6fa006b6b5ea4d3ba10c136fb0257ffb0d0199db73484275c632506e4ec31c81e1746667b80"},
|
||||
{"name": "libuuid1", "version": "2.40.2-2", "file": "x86_64/release/util-linux/libuuid1/libuuid1-2.40.2-2.tar.xz", "bytes": 12532, "sha512": "3ba0c5d5a401c88796077e9f45164532408882f2f5d9f0ab99b2fdf6eb915917250124cde3653a7c53b648866e091aa3baf3304d0b243337f0d4e254a7631f55"},
|
||||
{"name": "libzstd1", "version": "1.5.7-1", "file": "x86_64/release/zstd/libzstd1/libzstd1-1.5.7-1.tar.zst", "bytes": 253786, "sha512": "f89cdaa004487ec8c4796b8f56887c81f6f497873c1495b9cb585ffe6c8d6e6b8ad4b52617d5238075f965f1fe001da287d9a00d121590274b2d87672b415a0f"},
|
||||
{"name": "login", "version": "1.13-1", "file": "x86_64/release/login/login-1.13-1.tar.xz", "bytes": 17264, "sha512": "66acc3255962a27af8d701a8c02846f3b9180b7b1d65d946f6fb27cd24aeedc8e6a9a2601b419e981c94b356ef376a5c565ea31a4a220e5add9d70ae501a11d1"},
|
||||
{"name": "m4", "version": "1.4.21-1", "file": "x86_64/release/m4/m4-1.4.21-1-x86_64.tar.xz", "bytes": 363204, "sha512": "0d86c88d4bbbfc59e136bba3101ca3714139fba2ab7fea2883bc773ca884c3876f8a8f3a2ea8b05c29fd5280c1fb2d686401346f2761160917edf0818a2b232b"},
|
||||
{"name": "make", "version": "4.4.1-2", "file": "x86_64/release/make/make-4.4.1-2.tar.xz", "bytes": 598004, "sha512": "9a89a0f4ceadf5c2d0390029d16274fbed0190d2410ad6beb76e39b7153f38d0d1169ad0abf57c96929e6ab0523a0a76c345868e9ae46f9cd3d708d23f6fa3e6"},
|
||||
{"name": "man-db", "version": "2.13.1-1", "file": "x86_64/release/man-db/man-db-2.13.1-1-x86_64.tar.zst", "bytes": 1301518, "sha512": "a1e8a0d6d5a75465e32be83c13e685a73f084fa41abc5500d9437837a2c9de2f897827d3516c1076fa6cdd07a3d1aaaa4751f3b393fcfe64c370ff8f6b8b7f84"},
|
||||
{"name": "mintty", "version": "3.8.3-1", "file": "x86_64/release/mintty/mintty-3.8.3-1-x86_64.tar.xz", "bytes": 1190356, "sha512": "79068708c81a7bf6abba3ad1cd0550a2c3eb6f6eea21adade8b0d2b77339cd2519716f528159da9f0972f93bb624867e394d782c3e3b0b7e841a8db985395b92"},
|
||||
{"name": "ncurses", "version": "6.5+20240427-1", "file": "x86_64/release/ncurses/ncurses-6.5+20240427-1.tar.xz", "bytes": 111396, "sha512": "e15664bdab3f4d82bac6481deaa66476adbe34404937079983b5165930fa18cec3aa0345b93fbb2c390f8304ef20f041cd47d268552b92d01a51adb6abde0fc5"},
|
||||
{"name": "openssl", "version": "3.5.7-1", "file": "x86_64/release/openssl/openssl-3.5.7-1-x86_64.tar.zst", "bytes": 1392875, "sha512": "c50821b61eec47d58d1624a4a3d5a4013c80a8b48cdc803d81a656e6859079d321b34fa0ff97db4c093735a76b71a68c8a7f12184b2c4f0677014e910d1ba9d3"},
|
||||
{"name": "p11-kit", "version": "0.26.5-1", "file": "x86_64/release/p11-kit/p11-kit-0.26.5-1-x86_64.tar.xz", "bytes": 332724, "sha512": "1f057de789a5553f04649c80e6f78385135b57de7ba078e9dd51f2db60afee37717bb6de9dcf0a330cf72fce1359e08c0186988632b5f858992ebf95739bb840"},
|
||||
{"name": "p11-kit-trust", "version": "0.26.5-1", "file": "x86_64/release/p11-kit/p11-kit-trust/p11-kit-trust-0.26.5-1-x86_64.tar.xz", "bytes": 110096, "sha512": "2f98ae11e42f69fa4626638f7cefe2ba2fed808ae618093c1e6c568f8a8be79e6690b40e39e20df02a8d363c371cca8b8320fea7b288e8561cd299f15cc5b796"},
|
||||
{"name": "perl", "version": "5.44.0-1", "file": "x86_64/release/perl/perl-5.44.0-1-x86_64.tar.zst", "bytes": 5129424, "sha512": "42f80064ff94ea778319a24e011d4a7236944c79d9db22e0ed64a7ca7d9b65bc2df5998130eb64c50aa95c173937776cc42665174c5717e84fe6dca523368f27"},
|
||||
{"name": "perl-Algorithm-Diff", "version": "1.2010-5", "file": "noarch/release/perl-Algorithm-Diff/perl-Algorithm-Diff-1.2010-5-noarch.tar.zst", "bytes": 31580, "sha512": "d840b605043448ceab8ded77313e12653c81fd7db08062a99010fb19b334429c15628b1a0a805f88110e7aae4dcd3f667b515c18870ba873169533663f4374de"},
|
||||
{"name": "perl-Archive-Zip", "version": "1.680.0-1", "file": "noarch/release/perl-Archive-Zip/perl-Archive-Zip-1.680.0-1-noarch.tar.zst", "bytes": 85917, "sha512": "de23da6dac8aa8c8218c141c845723d092f6eaf2f1e67ced96d7b0385206c2e335b150bb7066bd0c7d257125ad1b3fc7691686dc535c56429b4a0f4535b6c73a"},
|
||||
{"name": "perl-Class-Inspector", "version": "1.360.0-1", "file": "noarch/release/perl-Class-Inspector/perl-Class-Inspector-1.360.0-1-noarch.tar.zst", "bytes": 21261, "sha512": "299489c9d0bc86fe8ba625c0ec0530f0e6ecacab3f67b2826760413f6bc58252c6c11f45583063cfcf0944f9127ed2bece9168fd76220e735841f374a57943f5"},
|
||||
{"name": "perl-Devel-Cycle", "version": "1.120.0-1", "file": "noarch/release/perl-Devel-Cycle/perl-Devel-Cycle-1.120.0-1-noarch.tar.zst", "bytes": 8884, "sha512": "308211af5b57106629b168be340fd682e23670fd97cc7c7f80c3bac48223984c1a226148c99cf5d904b09e352f1008f13bd4645897223a162a22af819aa7af11"},
|
||||
{"name": "perl-File-ShareDir", "version": "1.118.0-1", "file": "noarch/release/perl-File-ShareDir/perl-File-ShareDir-1.118.0-1-noarch.tar.zst", "bytes": 19857, "sha512": "7cb0f5fe4c327e9f870fc9c303f5e7e1483d2d2d012dbb5487f4b08f350170b7eb0a345766bd0a809bb4b8fa138788112eed2528b92718e817a5f21a9b82774d"},
|
||||
{"name": "perl-Text-Diff", "version": "1.450.0-1", "file": "noarch/release/perl-Text-Diff/perl-Text-Diff-1.450.0-1-noarch.tar.zst", "bytes": 30982, "sha512": "c19c80564d50d1d8efd44b156013aa5620b79205fd291897b938735c49214c84867a1337dfe9e7857f97e6f924ec919f5a0197df2d3bfeae78e0ec9dc8b9a6ac"},
|
||||
{"name": "perl-Win32-API", "version": "0.840.0-1", "file": "x86_64/release/perl-Win32-API/perl-Win32-API-0.840.0-1-x86_64.tar.zst", "bytes": 84514, "sha512": "758b1881d55942e91365780bede1dca63838995ad6574f9a242c15f613e7e3211a029e9bd3a3bd24d834ca6838e7a85c2812411783423ba23ccf808d094b6890"},
|
||||
{"name": "perl_autorebase", "version": "5.44.0-1", "file": "x86_64/release/perl/perl_autorebase/perl_autorebase-5.44.0-1-x86_64.tar.zst", "bytes": 175, "sha512": "55cd94604cfa3e2491df45e5a3715f32b2dee8298a656ca2da8de2eba4096329c595228a8c950760e9641b2c6097309571350c0ffe1c8d13759eb76ec841a4f8"},
|
||||
{"name": "perl_base", "version": "5.44.0-1", "file": "x86_64/release/perl/perl_base/perl_base-5.44.0-1-x86_64.tar.zst", "bytes": 3772189, "sha512": "3039e7a60c950cd682d8372f948ec83f7ebea27e9b425ab7406ed2eff0bebb80f7622423cf82b9ab07e34deb183bdf1b56fe129c8306bd2cfb04e7cd96beb992"},
|
||||
{"name": "rebase", "version": "4.6.6-1", "file": "x86_64/release/rebase/rebase-4.6.6-1.tar.xz", "bytes": 248832, "sha512": "9f3751c4687b09f3c286cf5c4522a0d976fce2d79ab471ab37560b15f14af84f7d13162b6102c02d0d60784448ff0586e76e9291675af4fa0c9320a3713633da"},
|
||||
{"name": "run", "version": "1.3.4-2", "file": "x86_64/release/run/run-1.3.4-2.tar.xz", "bytes": 34492, "sha512": "7e3156bbddc5f934fde3530879aa5186c9fdccb757ba848fc958e79e96534b336975f2882e413d5c18174628033a422157d25c48f8b5e90f0f1555ff2fa6343f"},
|
||||
{"name": "sed", "version": "4.10-1", "file": "x86_64/release/sed/sed-4.10-1-x86_64.tar.xz", "bytes": 359252, "sha512": "da5475344a1693f90fb560773ccca48eaf13af0e6bbcada9dcea658862bf7f46043b2d7365de0e2e235fb9a874fe784ad83bc29eb2fdbf3207cd8ad5e127b8b9"},
|
||||
{"name": "tar", "version": "1.35-2", "file": "x86_64/release/tar/tar-1.35-2.tar.zst", "bytes": 997616, "sha512": "007c7df12bc27ca14862a925680e2b2ff616a5149262b153889e6f580f3db492f98da49b5f34a8c4234194ee25021b67e9a84c987c96c5d6baa7ee0b3ea02425"},
|
||||
{"name": "terminfo", "version": "6.5+20240427-1", "file": "x86_64/release/ncurses/terminfo/terminfo-6.5+20240427-1.tar.xz", "bytes": 94760, "sha512": "128fb04f188bbf2af3060416193c9879a9cbbf7e5486febf851f35c3d9d00b9d61a0e2bf4be575d2308fd665a224ce5674485dcfd071125c3a8d199a4b88a042"},
|
||||
{"name": "texinfo", "version": "7.3-1", "file": "x86_64/release/texinfo/texinfo-7.3-1-x86_64.tar.zst", "bytes": 1853455, "sha512": "a7a0da042d05bbf2978857fcad1887552db9d77bf745fb8a17e156a2616500cf711adce107610f008ddff5556d02823f148d2bf146bd7eaa8a9466f9300cf2e6"},
|
||||
{"name": "tzcode", "version": "2026c-1", "file": "x86_64/release/tzcode/tzcode-2026c-1-x86_64.tar.xz", "bytes": 185512, "sha512": "85ab0f5d8d7c02e38dbd945c99ee6841774d84c486f857cd8484605068441b2028eea1f42a7e36c8fd6801c454f8f786a16f9caeb422afb30e5fcf324434878b"},
|
||||
{"name": "tzdata", "version": "2026c-1", "file": "noarch/release/tzdata/tzdata-2026c-1-noarch.tar.xz", "bytes": 184092, "sha512": "567adb6da01050a84b3785a1cb518e62a9c838cfe55e8ab33610c6ee64355677486329de5781361d08f03cd355acd64f94c64ec2a2686d48538813cc405b638c"},
|
||||
{"name": "util-linux", "version": "2.40.2-2", "file": "x86_64/release/util-linux/util-linux-2.40.2-2.tar.xz", "bytes": 2053568, "sha512": "4f3473472e32bff586401ec31f1423237c9cb112ae1140cdd8b2797040c5c182632f49f5354eaaa409d2dacba7767d5baa8b8926d7638e2725ad80065b46c10b"},
|
||||
{"name": "vim-minimal", "version": "9.1.1825-1", "file": "x86_64/release/vim/vim-minimal/vim-minimal-9.1.1825-1-x86_64.tar.xz", "bytes": 794064, "sha512": "6a252210e2ef08a7038d6e5bc8e5312e0c25d8328ab0aefd7f292eb79b7a32dd699f15f3f293cfbb83687e87cb3f68a335e969b117f55e6ff99b34ebdfbc8119"},
|
||||
{"name": "which", "version": "2.23-1", "file": "x86_64/release/which/which-2.23-1-x86_64.tar.xz", "bytes": 31108, "sha512": "98dffe802e1137d7b54359314797fd10080e6c261f37668e32e46aa7b1587b4148a1647b4f4a00cd0d23a9e90f153d5c2081d0ffa4ccea657b73aaa31b538d6e"},
|
||||
{"name": "xz", "version": "5.8.3-1", "file": "x86_64/release/xz/xz-5.8.3-1-x86_64.tar.zst", "bytes": 767298, "sha512": "8918389508ade8237226170b6dd02104938ec53b2bb15b310f5005dd64f954dfd67a5391757ba8602afe2a423f901894204771d6ae335402095c074d098daa76"},
|
||||
{"name": "zlib0", "version": "1.3.2-1", "file": "x86_64/release/zlib/zlib0/zlib0-1.3.2-1-x86_64.tar.zst", "bytes": 46254, "sha512": "d79ba6098cadf6bf2f32f35d9cd54729293c64b3c9daabb9d080f52861a19db71544d5710fdbd61ff45e7c2ae4eecb3f2e3b8a1e3bc05695b8cfe01c7639c53a"},
|
||||
{"name": "zstd", "version": "1.5.7-1", "file": "x86_64/release/zstd/zstd-1.5.7-1.tar.zst", "bytes": 394600, "sha512": "5de9a2fdee75345a35592444d467a1b70504f09f3b2ee5aaf8af8a9d9fda1a4e77d37c5c4c4fee9b96995ef78f9708e6c02adea7a70d9f80f1238e507b2bc0fc"}
|
||||
]
|
||||
}
|
||||
83
.github/scripts/voice_windows_tools.py
vendored
Normal file
83
.github/scripts/voice_windows_tools.py
vendored
Normal file
@@ -0,0 +1,83 @@
|
||||
"""Expose verified Windows build-tool installations as local Bazel inputs.
|
||||
|
||||
This declares the installed support trees; the caller authenticates their
|
||||
inputs and verifies the installed package inventory first.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import itertools
|
||||
import json
|
||||
from pathlib import Path
|
||||
import stat
|
||||
|
||||
|
||||
def export_repository(root: Path, target: str, pkg_config: Path):
|
||||
if target not in ("x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc"):
|
||||
raise ValueError("unsupported Windows target")
|
||||
root = root.resolve(strict=True)
|
||||
pkg_config = pkg_config.resolve(strict=True)
|
||||
names = {
|
||||
"shell": "cygwin/bin/bash.exe",
|
||||
"make": "cygwin/bin/make.exe",
|
||||
"cygpath": "cygwin/bin/cygpath.exe",
|
||||
"automake": "cygwin/bin/automake-1.18",
|
||||
"pkg_config": pkg_config.relative_to(root).as_posix(),
|
||||
}
|
||||
if not names["pkg_config"].startswith("pkgconf-image/"):
|
||||
raise ValueError("pkg-config must belong to the extracted image")
|
||||
outputs = ("BUILD.bazel", "MODULE.bazel", "voice-tools.json")
|
||||
if any((root / name).exists() for name in outputs):
|
||||
raise ValueError("Bazel tool repository outputs must be fresh")
|
||||
# A nested package boundary would silently remove files from Bazel's glob.
|
||||
# Reparse points could escape the installation or hide support directories.
|
||||
for directory in ("cygwin", "pkgconf-image"):
|
||||
tree = root / directory
|
||||
if not tree.is_dir():
|
||||
raise ValueError(f"missing tool tree: {directory}")
|
||||
for path in itertools.chain((tree,), tree.rglob("*")):
|
||||
info = path.lstat()
|
||||
if (
|
||||
stat.S_ISLNK(info.st_mode)
|
||||
or getattr(info, "st_file_attributes", 0)
|
||||
& stat.FILE_ATTRIBUTE_REPARSE_POINT
|
||||
or not (stat.S_ISDIR(info.st_mode) or stat.S_ISREG(info.st_mode))
|
||||
or path.name.casefold() in ("build", "build.bazel")
|
||||
):
|
||||
raise ValueError(f"unsupported tool-tree entry: {path}")
|
||||
if any(not (root / name).is_file() for name in names.values()):
|
||||
raise ValueError("required Windows build tool missing")
|
||||
definitions = [
|
||||
'package(default_visibility = ["//visibility:public"])',
|
||||
# Cygwin records installation timestamps in this unused Java truststore.
|
||||
# Exclude it so reinstalling the same tools preserves action cache keys.
|
||||
'filegroup(name = "cygwin", srcs = glob(["cygwin/**"], '
|
||||
'exclude = ["cygwin/etc/pki/ca-trust/extracted/java/cacerts"], allow_empty = False))',
|
||||
'filegroup(name = "pkgconf", srcs = glob(["pkgconf-image/**"], allow_empty = False))',
|
||||
'filegroup(name = "tools", srcs = [":cygwin", ":pkgconf", "voice-tools.json"])',
|
||||
]
|
||||
definitions.extend(
|
||||
f"filegroup(name = {json.dumps(name)}, srcs = [{json.dumps(path)}])"
|
||||
for name, path in names.items()
|
||||
)
|
||||
metadata = {
|
||||
"schemaVersion": 1,
|
||||
"target": target,
|
||||
"cygwinArchitecture": "x86_64",
|
||||
"tools": names,
|
||||
}
|
||||
for name, contents in (
|
||||
("BUILD.bazel", "\n".join(definitions) + "\n"),
|
||||
("MODULE.bazel", 'module(name = "voice_windows_tools")\n'),
|
||||
("voice-tools.json", json.dumps(metadata, indent=2) + "\n"),
|
||||
):
|
||||
with (root / name).open("x", encoding="utf-8") as output:
|
||||
output.write(contents)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--root", type=Path, required=True)
|
||||
parser.add_argument("--target", required=True)
|
||||
parser.add_argument("--pkg-config", type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
export_repository(args.root, args.target, args.pkg_config)
|
||||
79
.github/scripts/watch_voice_bazel.py
vendored
Normal file
79
.github/scripts/watch_voice_bazel.py
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
"""Capture one bounded diagnostic when the ARM64 voice build goes silent."""
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import threading
|
||||
import time
|
||||
|
||||
|
||||
def diagnose():
|
||||
root = Path(os.environ.get("BAZEL_OUTPUT_BASE", ""))
|
||||
if not root.is_absolute():
|
||||
print("Bazel output base unavailable; skipping diagnostics", flush=True)
|
||||
return
|
||||
for relative in ("command.log", "server/jvm.out"):
|
||||
try:
|
||||
with (root / relative).open("rb") as source:
|
||||
source.seek(max(0, source.seek(0, 2) - 16384))
|
||||
print(
|
||||
f"Bazel {relative} tail:\n{source.read(16384).decode(errors='replace')}",
|
||||
flush=True,
|
||||
)
|
||||
except OSError as error:
|
||||
print(f"Cannot read {relative}: {error}", flush=True)
|
||||
try:
|
||||
pid = str(int((root / "server/server.pid.txt").read_text().strip()))
|
||||
jstack = shutil.which("jstack")
|
||||
if not jstack:
|
||||
print("jstack unavailable; log tails retained", flush=True)
|
||||
return
|
||||
result = subprocess.run([jstack, pid], capture_output=True, timeout=20)
|
||||
print(
|
||||
f"jstack exit {result.returncode}:\n{(result.stdout + result.stderr)[-65536:].decode(errors='replace')}",
|
||||
flush=True,
|
||||
)
|
||||
except (OSError, ValueError, subprocess.TimeoutExpired) as error:
|
||||
print(f"Cannot capture JVM stacks: {error}", flush=True)
|
||||
|
||||
|
||||
def main():
|
||||
with subprocess.Popen(
|
||||
sys.argv[1:], stdout=subprocess.PIPE, stderr=subprocess.STDOUT
|
||||
) as process:
|
||||
last_output = time.monotonic()
|
||||
|
||||
def forward():
|
||||
nonlocal last_output
|
||||
for line in process.stdout:
|
||||
last_output = time.monotonic()
|
||||
sys.stdout.buffer.write(line)
|
||||
sys.stdout.buffer.flush()
|
||||
|
||||
reader = threading.Thread(target=forward)
|
||||
reader.start()
|
||||
captured = False
|
||||
while process.poll() is None:
|
||||
if (
|
||||
not captured
|
||||
and os.environ.get("VOICE_ARCH") == "aarch64"
|
||||
and time.monotonic() - last_output >= 600
|
||||
):
|
||||
captured = True
|
||||
print(
|
||||
"ARM64 Bazel silent for ten minutes; capturing diagnostics",
|
||||
flush=True,
|
||||
)
|
||||
diagnose()
|
||||
time.sleep(1)
|
||||
reader.join()
|
||||
if process.returncode and not captured:
|
||||
print("Bazel command failed; capturing diagnostics", flush=True)
|
||||
diagnose()
|
||||
return process.returncode
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
251
.github/scripts/windows_bazel_test_durations.tsv
vendored
Normal file
251
.github/scripts/windows_bazel_test_durations.tsv
vendored
Normal file
@@ -0,0 +1,251 @@
|
||||
# Windows Bazel duration weights; columns: target<TAB>seconds.
|
||||
# Seeded from 24 successful public openai/codex Windows job logs across six main
|
||||
# runs, September 21-23, 2026. Public GitHub Actions run IDs:
|
||||
# 35638529858, 35665540272, 35694732932, 35912411800, 35919297566, 35924169500.
|
||||
# To refresh, take the median summed inner-run time (N * average) from clean,
|
||||
# uncached PASSED summaries, excluding partial cache hits and FLAKY results.
|
||||
# Round up to positive integer seconds. These weights exclude build/download time.
|
||||
# Every queried target is assigned; missing weights default to 1 and stale entries are ignored.
|
||||
//codex-rs/agent-graph-store:agent-graph-store-unit-tests 76
|
||||
//codex-rs/agent-identity:agent-identity-unit-tests 66
|
||||
//codex-rs/agent-roles:agent-roles-unit-tests 48
|
||||
//codex-rs/analytics:analytics-unit-tests 29
|
||||
//codex-rs/app-server-client:app-server-client-unit-tests 51
|
||||
//codex-rs/app-server-daemon:app-server-daemon-unit-tests 4
|
||||
//codex-rs/app-server-protocol:app-server-protocol-unit-tests 19
|
||||
//codex-rs/app-server-test-client:app-server-test-client-unit-tests 25
|
||||
//codex-rs/app-server-test-client:codex-app-server-test-client-bin-unit-tests 1
|
||||
//codex-rs/app-server-transport:app-server-transport-unit-tests 65
|
||||
//codex-rs/app-server/tests/common:common-unit-tests 26
|
||||
//codex-rs/app-server:app-server-all-test-windows-cross 2835
|
||||
//codex-rs/app-server:app-server-unit-tests 399
|
||||
//codex-rs/app-server:codex-app-server-bin-unit-tests 48
|
||||
//codex-rs/app-server:codex-app-server-test-notify-capture-bin-unit-tests 1
|
||||
//codex-rs/app-server:exec-server-bin-unit-tests 1
|
||||
//codex-rs/app-server:test_notify_capture-bin-unit-tests 1
|
||||
//codex-rs/apply-patch:apply-patch-all-test-windows-cross 50
|
||||
//codex-rs/apply-patch:apply-patch-unit-tests 48
|
||||
//codex-rs/apply-patch:apply_patch-bin-unit-tests 24
|
||||
//codex-rs/arg0:arg0-unit-tests 24
|
||||
//codex-rs/backend-client:backend-client-unit-tests 41
|
||||
//codex-rs/chatgpt:chatgpt-all-test-windows-cross 26
|
||||
//codex-rs/chatgpt:chatgpt-unit-tests 27
|
||||
//codex-rs/cli:cli-app_server-test-windows-cross 3
|
||||
//codex-rs/cli:cli-app_server_daemon-test-windows-cross 1
|
||||
//codex-rs/cli:cli-cloud_auth-test-windows-cross 47
|
||||
//codex-rs/cli:cli-cloud_config-test-windows-cross 3
|
||||
//codex-rs/cli:cli-daemon_startup-test-windows-cross 4
|
||||
//codex-rs/cli:cli-daemon_telemetry-test-windows-cross 1
|
||||
//codex-rs/cli:cli-debug_clear_memories-test-windows-cross 4
|
||||
//codex-rs/cli:cli-debug_models-test-windows-cross 2
|
||||
//codex-rs/cli:cli-delete-test-windows-cross 2
|
||||
//codex-rs/cli:cli-doctor_enterprise_network-test-windows-cross 3
|
||||
//codex-rs/cli:cli-doctor_path_safety-test-windows-cross 47
|
||||
//codex-rs/cli:cli-exec_server-test-windows-cross 39
|
||||
//codex-rs/cli:cli-exec_server_websocket_auth-test-windows-cross 4
|
||||
//codex-rs/cli:cli-execpolicy-test-windows-cross 2
|
||||
//codex-rs/cli:cli-features-test-windows-cross 3
|
||||
//codex-rs/cli:cli-login-test-windows-cross 4
|
||||
//codex-rs/cli:cli-marketplace_add-test-windows-cross 2
|
||||
//codex-rs/cli:cli-marketplace_remove-test-windows-cross 1
|
||||
//codex-rs/cli:cli-marketplace_upgrade-test-windows-cross 2
|
||||
//codex-rs/cli:cli-mcp_add_remove-test-windows-cross 3
|
||||
//codex-rs/cli:cli-mcp_list-test-windows-cross 2
|
||||
//codex-rs/cli:cli-mcp_login-test-windows-cross 2
|
||||
//codex-rs/cli:cli-plugin_cli-test-windows-cross 7
|
||||
//codex-rs/cli:cli-queue-test-windows-cross 1
|
||||
//codex-rs/cli:cli-sandbox_cloud_config-test-windows-cross 48
|
||||
//codex-rs/cli:cli-sandbox_network_proxy-test-windows-cross 1
|
||||
//codex-rs/cli:cli-sandbox_tty-test-windows-cross 1
|
||||
//codex-rs/cli:cli-unit-tests 2
|
||||
//codex-rs/cli:cli-update-test-windows-cross 47
|
||||
//codex-rs/cli:cli-worktree-test-windows-cross 12
|
||||
//codex-rs/cli:codex-bin-unit-tests 60
|
||||
//codex-rs/cli:logs_client-bin-unit-tests 1
|
||||
//codex-rs/cloud-config:cloud-config-unit-tests 47
|
||||
//codex-rs/cloud-tasks-client:cloud-tasks-client-unit-tests 35
|
||||
//codex-rs/cloud-tasks-mock-client:cloud-tasks-mock-client-unit-tests 59
|
||||
//codex-rs/cloud-tasks:cloud-tasks-env_filter-test-windows-cross 1
|
||||
//codex-rs/cloud-tasks:cloud-tasks-unit-tests 1
|
||||
//codex-rs/code-mode-host:code-mode-host-grpc-test-windows-cross 28
|
||||
//codex-rs/code-mode-host:code-mode-host-grpc_notifications-test-windows-cross 25
|
||||
//codex-rs/code-mode-host:code-mode-host-grpc_tcp-test-windows-cross 1
|
||||
//codex-rs/code-mode-host:code-mode-host-grpc_timing-test-windows-cross 7
|
||||
//codex-rs/code-mode-host:code-mode-host-stdio-test-windows-cross 11
|
||||
//codex-rs/code-mode-host:code-mode-host-unit-tests 2
|
||||
//codex-rs/code-mode-host:codex-code-mode-host-bin-unit-tests 1
|
||||
//codex-rs/code-mode-protocol:code-mode-protocol-unit-tests 62
|
||||
//codex-rs/code-mode-runtime:code-mode-runtime-array_sort-test-windows-cross 24
|
||||
//codex-rs/code-mode-runtime:code-mode-runtime-jit-test-windows-cross 1
|
||||
//codex-rs/code-mode-runtime:code-mode-runtime-unit-tests 7
|
||||
//codex-rs/code-mode:code-mode-unit-tests 49
|
||||
//codex-rs/codex-api:codex-api-clients-test-windows-cross 75
|
||||
//codex-rs/codex-api:codex-api-models_integration-test-windows-cross 66
|
||||
//codex-rs/codex-api:codex-api-realtime_websocket_e2e-test-windows-cross 63
|
||||
//codex-rs/codex-api:codex-api-realtime_websocket_tls-test-windows-cross 66
|
||||
//codex-rs/codex-api:codex-api-sse_end_to_end-test-windows-cross 48
|
||||
//codex-rs/codex-api:codex-api-unit-tests 60
|
||||
//codex-rs/codex-home:codex-home-unit-tests 13
|
||||
//codex-rs/codex-mcp:codex-mcp-unit-tests 61
|
||||
//codex-rs/config-schema:codex-write-config-schema-bin-unit-tests 48
|
||||
//codex-rs/config:config-unit-tests 75
|
||||
//codex-rs/connectors:connectors-unit-tests 39
|
||||
//codex-rs/context-fragments:context-fragments-unit-tests 59
|
||||
//codex-rs/core-api:core-api-unit-tests 1
|
||||
//codex-rs/core-plugins:core-plugins-unit-tests 20
|
||||
//codex-rs/core/tests/common:common-unit-tests 48
|
||||
//codex-rs/core:core-all-test-windows-cross 3162
|
||||
//codex-rs/core:core-mcp_trace_propagation-test-windows-cross 2
|
||||
//codex-rs/core:core-responses_headers-test-windows-cross 5
|
||||
//codex-rs/core:core-unit-tests 251
|
||||
//codex-rs/exec-server-protocol:exec-server-protocol-unit-tests 48
|
||||
//codex-rs/exec-server/tests/support:support-unit-tests 48
|
||||
//codex-rs/exec-server:exec-server-accepted_websocket-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-capability_discovery-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-chatgpt_cloudflare_affinity-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-deferred_environment-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-environment-test-windows-cross 10
|
||||
//codex-rs/exec-server:exec-server-environment_config-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-exec_process-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-file_stream-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-file_system_unix-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-file_system_windows-test-windows-cross 11
|
||||
//codex-rs/exec-server:exec-server-forward-test-windows-cross 10
|
||||
//codex-rs/exec-server:exec-server-health-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-http_client-test-windows-cross 2
|
||||
//codex-rs/exec-server:exec-server-http_request-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-http_request_logging-test-windows-cross 3
|
||||
//codex-rs/exec-server:exec-server-initialize-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-macos_fs_spawn-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-process-test-windows-cross 4
|
||||
//codex-rs/exec-server:exec-server-relay-test-windows-cross 8
|
||||
//codex-rs/exec-server:exec-server-selected_capability_roots-test-windows-cross 1
|
||||
//codex-rs/exec-server:exec-server-unit-tests 116
|
||||
//codex-rs/exec-server:exec-server-websocket-test-windows-cross 1
|
||||
//codex-rs/exec:codex-exec-bin-unit-tests 1
|
||||
//codex-rs/exec:exec-all-test-windows-cross 331
|
||||
//codex-rs/exec:exec-event_processor_with_json_output-test-windows-cross 1
|
||||
//codex-rs/exec:exec-unit-tests 47
|
||||
//codex-rs/message-board:message-board-local_board-test-windows-cross 46
|
||||
//codex-rs/ext/agent-message-board:agent-message-board-unit-tests 30
|
||||
//codex-rs/ext/agent:agent-agent_service-test-windows-cross 3
|
||||
//codex-rs/ext/agent:agent-unit-tests 1
|
||||
//codex-rs/ext/connectors:connectors-unit-tests 47
|
||||
//codex-rs/ext/extension-api:extension-api-capabilities-test-windows-cross 14
|
||||
//codex-rs/ext/extension-api:extension-api-registry-test-windows-cross 31
|
||||
//codex-rs/ext/extension-api:extension-api-state-test-windows-cross 57
|
||||
//codex-rs/ext/extension-api:extension-api-unit-tests 35
|
||||
//codex-rs/ext/git-attribution:git-attribution-unit-tests 30
|
||||
//codex-rs/ext/goal:goal-accounting-test-windows-cross 1
|
||||
//codex-rs/ext/goal:goal-goal_extension_backend-test-windows-cross 9
|
||||
//codex-rs/ext/goal:goal-steering-test-windows-cross 1
|
||||
//codex-rs/ext/goal:goal-unit-tests 47
|
||||
//codex-rs/ext/guardian-reviewer:guardian-reviewer-unit-tests 36
|
||||
//codex-rs/ext/guardian-v2:guardian-v2-unit-tests 50
|
||||
//codex-rs/ext/history-notes:history-notes-history_notes_extension-test-windows-cross 1
|
||||
//codex-rs/ext/history-notes:history-notes-image_model_input-test-windows-cross 2
|
||||
//codex-rs/ext/history-notes:history-notes-unit-tests 1
|
||||
//codex-rs/ext/image-generation:image-generation-unit-tests 47
|
||||
//codex-rs/ext/mcp:mcp-hosted_apps_mcp-test-windows-cross 26
|
||||
//codex-rs/ext/mcp:mcp-plugin_mcp-test-windows-cross 5
|
||||
//codex-rs/ext/mcp:mcp-unit-tests 48
|
||||
//codex-rs/ext/memories:memories-unit-tests 28
|
||||
//codex-rs/ext/queue:queue-queue_service-test-windows-cross 9
|
||||
//codex-rs/ext/queue:queue-unit-tests 25
|
||||
//codex-rs/ext/skills:skills-executor_file_system_authority-test-windows-cross 36
|
||||
//codex-rs/ext/skills:skills-skills_extension-test-windows-cross 7
|
||||
//codex-rs/ext/skills:skills-unit-tests 8
|
||||
//codex-rs/ext/web-search:web-search-unit-tests 1
|
||||
//codex-rs/external-agent-migration:external-agent-migration-unit-tests 4
|
||||
//codex-rs/features:features-unit-tests 47
|
||||
//codex-rs/feedback:feedback-unit-tests 77
|
||||
//codex-rs/file-system:file-system-unit-tests 48
|
||||
//codex-rs/git-utils:git-utils-unit-tests 83
|
||||
//codex-rs/guardian-context:guardian-context-cache_prefix-test-windows-cross 66
|
||||
//codex-rs/guardian-context:guardian-context-unit-tests 67
|
||||
//codex-rs/history:history-unit-tests 59
|
||||
//codex-rs/hooks:hooks-unit-tests 16
|
||||
//codex-rs/hooks:write_hooks_schema_fixtures-bin-unit-tests 48
|
||||
//codex-rs/lmstudio:lmstudio-unit-tests 1
|
||||
//codex-rs/login:login-all-test-windows-cross 5
|
||||
//codex-rs/login:login-unit-tests 320
|
||||
//codex-rs/memories/read:read-unit-tests 62
|
||||
//codex-rs/memories/write:write-unit-tests 20
|
||||
//codex-rs/message-history:message-history-unit-tests 74
|
||||
//codex-rs/model-provider-info:model-provider-info-unit-tests 63
|
||||
//codex-rs/model-provider:model-provider-unit-tests 64
|
||||
//codex-rs/models-manager:models-manager-unit-tests 35
|
||||
//codex-rs/mxc-sandbox:mxc-sandbox-unit-tests 36
|
||||
//codex-rs/network-proxy:codex-network-proxy-bin-unit-tests 48
|
||||
//codex-rs/network-proxy:network-proxy-unit-tests 85
|
||||
//codex-rs/network-proxy:network-proxy-windows_stable_ingress-test-windows-cross 37
|
||||
//codex-rs/ollama:ollama-unit-tests 1
|
||||
//codex-rs/otel:otel-tests-test-windows-cross 17
|
||||
//codex-rs/otel:otel-unit-tests 48
|
||||
//codex-rs/plugin:plugin-unit-tests 74
|
||||
//codex-rs/prompts:prompts-unit-tests 62
|
||||
//codex-rs/protocol:protocol-unit-tests 67
|
||||
//codex-rs/response-debug-context:response-debug-context-unit-tests 66
|
||||
//codex-rs/rmcp-client:rmcp-client-foreign_stdio_cwd-test-windows-cross 48
|
||||
//codex-rs/rmcp-client:rmcp-client-mcp_2026_discovery-test-windows-cross 4
|
||||
//codex-rs/rmcp-client:rmcp-client-mcp_2026_message_limits-test-windows-cross 4
|
||||
//codex-rs/rmcp-client:rmcp-client-mcp_2026_mrtr-test-windows-cross 2
|
||||
//codex-rs/rmcp-client:rmcp-client-mcp_2026_oauth_discovery-test-windows-cross 1
|
||||
//codex-rs/rmcp-client:rmcp-client-mcp_2026_sse_discovery-test-windows-cross 1
|
||||
//codex-rs/rmcp-client:rmcp-client-mcp_2026_stdio-test-windows-cross 39
|
||||
//codex-rs/rmcp-client:rmcp-client-mcp_2026_stdio_discovery-test-windows-cross 2
|
||||
//codex-rs/rmcp-client:rmcp-client-mcp_events-test-windows-cross 2
|
||||
//codex-rs/rmcp-client:rmcp-client-process_group_cleanup-test-windows-cross 1
|
||||
//codex-rs/rmcp-client:rmcp-client-resources-test-windows-cross 1
|
||||
//codex-rs/rmcp-client:rmcp-client-stdio_descriptor_boundary-test-windows-cross 1
|
||||
//codex-rs/rmcp-client:rmcp-client-stdio_message_limits-test-windows-cross 3
|
||||
//codex-rs/rmcp-client:rmcp-client-stdio_stderr_cleanup-test-windows-cross 1
|
||||
//codex-rs/rmcp-client:rmcp-client-streamable_http_oauth_startup-test-windows-cross 6
|
||||
//codex-rs/rmcp-client:rmcp-client-streamable_http_oauth_store_pinning-test-windows-cross 38
|
||||
//codex-rs/rmcp-client:rmcp-client-streamable_http_oauth_tool_call-test-windows-cross 2
|
||||
//codex-rs/rmcp-client:rmcp-client-streamable_http_recovery-test-windows-cross 51
|
||||
//codex-rs/rmcp-client:rmcp-client-streamable_http_remote-test-windows-cross 3
|
||||
//codex-rs/rmcp-client:rmcp-client-streamable_http_test_support-test-windows-cross 1
|
||||
//codex-rs/rmcp-client:rmcp-client-streamable_http_user_agent-test-windows-cross 1
|
||||
//codex-rs/rmcp-client:rmcp-client-unit-tests 50
|
||||
//codex-rs/rmcp-client:rmcp_test_server-bin-unit-tests 39
|
||||
//codex-rs/rmcp-client:test_mcp_2026_discovery_stdio_server-bin-unit-tests 43
|
||||
//codex-rs/rmcp-client:test_mcp_2026_stdio_server-bin-unit-tests 25
|
||||
//codex-rs/rmcp-client:test_stdio_server-bin-unit-tests 41
|
||||
//codex-rs/rmcp-client:test_streamable_http_server-bin-unit-tests 40
|
||||
//codex-rs/rollout-trace:rollout-trace-unit-tests 76
|
||||
//codex-rs/rollout:rollout-unit-tests 56
|
||||
//codex-rs/sandboxing:sandboxing-unit-tests 74
|
||||
//codex-rs/secrets:secrets-unit-tests 57
|
||||
//codex-rs/shell-command:shell-command-unit-tests 60
|
||||
//codex-rs/skills:skills-unit-tests 59
|
||||
//codex-rs/state:state-unit-tests 242
|
||||
//codex-rs/test-binary-support:test-binary-support-unit-tests 48
|
||||
//codex-rs/thread-manager-sample:codex-thread-manager-sample-bin-unit-tests 47
|
||||
//codex-rs/thread-store:thread-store-unit-tests 95
|
||||
//codex-rs/tools:tools-json_schema_policy_fixtures-test-windows-cross 34
|
||||
//codex-rs/tools:tools-unit-tests 37
|
||||
//codex-rs/tui:codex-tui-bin-unit-tests 2
|
||||
//codex-rs/tui:md-events-bin-unit-tests 1
|
||||
//codex-rs/tui:tui-all-test-windows-cross 36
|
||||
//codex-rs/tui:tui-manager_dependency_regression-test-windows-cross 2
|
||||
//codex-rs/tui:tui-test_backend-test-windows-cross 25
|
||||
//codex-rs/tui:tui-unit-tests 1003
|
||||
//codex-rs/utils/approval-presets:approval-presets-unit-tests 66
|
||||
//codex-rs/utils/audio:audio-unit-tests 76
|
||||
//codex-rs/utils/cli:cli-unit-tests 64
|
||||
//codex-rs/utils/git-discovery:git-discovery-unit-tests 59
|
||||
//codex-rs/utils/oss:oss-unit-tests 1
|
||||
//codex-rs/utils/output-truncation:output-truncation-unit-tests 60
|
||||
//codex-rs/utils/plugins:plugins-unit-tests 36
|
||||
//codex-rs/utils/sandbox-summary:sandbox-summary-unit-tests 66
|
||||
//codex-rs/windows-sandbox-rs:codex-command-runner-bin-unit-tests 1
|
||||
//codex-rs/windows-sandbox-rs:codex-windows-managed-deny-probe-bin-unit-tests 1
|
||||
//codex-rs/windows-sandbox-rs:codex-windows-sandbox-setup-bin-unit-tests 1
|
||||
//codex-rs/windows-sandbox-rs:windows-sandbox-rs-helper_manifest-test-windows-cross 1
|
||||
//codex-rs/windows-sandbox-rs:windows-sandbox-rs-unit-tests 23
|
||||
//codex-rs/windows-sandbox-service:codex-windows-sandbox-service-bin-unit-tests 46
|
||||
//codex-rs/windows-sandbox-service:windows-sandbox-service-unit-tests 12
|
||||
//codex-rs/worktree:worktree-settings-test-windows-cross 59
|
||||
//codex-rs/worktree:worktree-unit-tests 76
|
||||
//codex-rs/worktree:worktree-worktree-test-windows-cross 92
|
||||
|
Reference in New Issue
Block a user