🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(codex): bootstrap env files for new git worktrees (#12717)
Max Deichmann4b4a0a445152
diff --git a/scripts/codex/setup.sh b/scripts/codex/setup.shindex 4eeae9d8ef..21fcac5a9e 100755--- a/scripts/codex/setup.sh+++ b/scripts/codex/setup.sh@@ -2,6 +2,17 @@set -euo pipefail+ensure_env_file() {+ local target_path="$1"+ local fallback_path="$2"++ if [ -f "$target_path" ]; then+ return 0+ fi++ cp "$fallback_path" "$target_path"+}+if ! command -v corepack >/dev/null 2>&1; thenecho "corepack is required. Use a Codex base environment with Node.js 24 support."exit 1@@ -10,13 +21,8 @@ ficorepack enablecorepack prepare [email protected] --activate-if [ ! -f .env ]; then- cp .env.dev.example .env-fi--if [ ! -f .env.test ]; then- cp .env.test.example .env.test-fi+ensure_env_file .env .env.dev.example+ensure_env_file .env.test .env.test.examplepnpm install --frozen-lockfilediff --git a/scripts/codex/setup.test.sh b/scripts/codex/setup.test.shnew file mode 100755index 0000000000..a02280fb22--- /dev/null+++ b/scripts/codex/setup.test.sh@@ -0,0 +1,83 @@+#!/usr/bin/env bash++set -euo pipefail++repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"+tmpdir="$(mktemp -d)"++cleanup() {+ rm -rf "$tmpdir"+}++trap cleanup EXIT++repo_copy="$tmpdir/repo"++mkdir -p "$tmpdir/bin" "$repo_copy/scripts/codex"++cp "$repo_root/scripts/codex/setup.sh" "$repo_copy/scripts/codex/setup.sh"+cp "$repo_root/.env.dev.example" "$repo_copy/.env.dev.example"+cp "$repo_root/.env.test.example" "$repo_copy/.env.test.example"++chmod +x "$repo_copy/scripts/codex/setup.sh"++cat <<'EOF' > "$tmpdir/bin/corepack"+#!/usr/bin/env bash+exit 0+EOF++cat <<'EOF' > "$tmpdir/bin/pnpm"+#!/usr/bin/env bash+exit 0+EOF++chmod +x "$tmpdir/bin/corepack" "$tmpdir/bin/pnpm"++assert_file_contains() {+ local file_path="$1"+ local expected="$2"+ local message="$3"++ if ! grep -Fqx "$expected" "$file_path"; then+ echo "$message"+ echo "missing line: $expected"+ exit 1+ fi+}++run_setup() {+ (+ cd "$repo_copy"+ PATH="$tmpdir/bin:$PATH" bash scripts/codex/setup.sh+ )+}++run_setup++if ! cmp -s "$repo_copy/.env.dev.example" "$repo_copy/.env"; then+ echo ".env should be created from .env.dev.example when missing"+ exit 1+fi++if ! cmp -s "$repo_copy/.env.test.example" "$repo_copy/.env.test"; then+ echo ".env.test should be created from .env.test.example when missing"+ exit 1+fi++cat <<'EOF' > "$repo_copy/.env"+WORKTREE_ONLY=keep-me+EOF++run_setup++assert_file_contains \+ "$repo_copy/.env" \+ "WORKTREE_ONLY=keep-me" \+ "setup.sh should not overwrite an existing .env"++assert_file_contains \+ "$repo_copy/.env.test" \+ 'DATABASE_URL="postgresql://postgres:postgres@localhost:5432/langfuse_test"' \+ "setup.sh should preserve the existing .env.test on rerun"++echo "setup.sh example bootstrap regression test passed"