fix: keep dev e2e repo fetch on host
This commit is contained in:
+55
-1
@@ -9,11 +9,12 @@ environment="dev"
|
||||
result_dir=""
|
||||
timeout_ms="1800000"
|
||||
keep_namespace="false"
|
||||
manifest_file=""
|
||||
|
||||
usage() {
|
||||
cat <<'EOF'
|
||||
Usage:
|
||||
dev-e2e.sh --run-id ID --manifest-commit COMMIT --result-dir DIR [--repo-url URL] [--desired-ref master] [--environment dev] [--timeout-ms MS] [--keep-namespace]
|
||||
dev-e2e.sh --run-id ID --manifest-commit COMMIT --manifest-file FILE --result-dir DIR [--repo-url URL] [--desired-ref master] [--environment dev] [--timeout-ms MS] [--keep-namespace]
|
||||
|
||||
This script runs the D601 dev namespace e2e harness from a Git-controlled blob.
|
||||
It must be launched by the CLI with a short command; do not paste this script
|
||||
@@ -47,6 +48,10 @@ while [ "$#" -gt 0 ]; do
|
||||
result_dir="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--manifest-file)
|
||||
manifest_file="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--timeout-ms)
|
||||
timeout_ms="${2:-}"
|
||||
shift 2
|
||||
@@ -86,6 +91,10 @@ fi
|
||||
if [ -z "$result_dir" ]; then
|
||||
result_dir="/home/ubuntu/.unidesk/runs/$run_id"
|
||||
fi
|
||||
if [ -z "$manifest_file" ] || [ ! -f "$manifest_file" ]; then
|
||||
echo "--manifest-file must point to the commit-pinned deploy.json fetched by the launcher" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
mkdir -p "$result_dir"
|
||||
runner_log="$result_dir/runner.log"
|
||||
@@ -144,6 +153,43 @@ log_json runner_started run_id "$run_id" manifest_commit "$manifest_commit"
|
||||
kubectl get pipeline/unidesk-dev-namespace-e2e -n unidesk-ci >/dev/null
|
||||
kubectl get pvc/unidesk-ci-cache -n unidesk-ci >/dev/null
|
||||
|
||||
service_env="$result_dir/dev-e2e-service-commits.env"
|
||||
python3 - "$manifest_file" "$service_env" "$environment" <<'PY'
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
|
||||
manifest_path, out_path, environment = sys.argv[1:]
|
||||
with open(manifest_path, "r", encoding="utf-8") as handle:
|
||||
manifest = json.load(handle)
|
||||
if manifest.get("schemaVersion") != 2:
|
||||
raise SystemExit("deploy.json must use schemaVersion=2")
|
||||
env = manifest.get("environments", {}).get(environment)
|
||||
if not isinstance(env, dict):
|
||||
raise SystemExit(f"deploy.json must contain environments.{environment}")
|
||||
services = env.get("services")
|
||||
if not isinstance(services, list) or not services:
|
||||
raise SystemExit(f"deploy.json environments.{environment}.services must contain services")
|
||||
lines = []
|
||||
summary = []
|
||||
for service in services:
|
||||
if not isinstance(service, dict) or not service.get("id") or not service.get("repo") or not service.get("commitId"):
|
||||
raise SystemExit(f"each deploy.json environments.{environment} service must contain id, repo and commitId")
|
||||
key = re.sub(r"[^A-Z0-9]", "_", str(service["id"]).upper())
|
||||
commit = str(service["commitId"])
|
||||
lines.append(f"{key}_COMMIT={commit}")
|
||||
summary.append({"id": service["id"], "commitId": commit})
|
||||
with open(out_path, "w", encoding="utf-8") as handle:
|
||||
handle.write("\n".join(lines) + "\n")
|
||||
print(json.dumps({"ok": True, "environment": environment, "services": summary}, ensure_ascii=False))
|
||||
PY
|
||||
# shellcheck disable=SC1090
|
||||
source "$service_env"
|
||||
backend_commit="${BACKEND_CORE_COMMIT:-unknown}"
|
||||
frontend_commit="${FRONTEND_COMMIT:-unknown}"
|
||||
code_queue_commit="${CODE_QUEUE_COMMIT:-unknown}"
|
||||
deploy_json_b64="$(base64 -w0 "$manifest_file")"
|
||||
|
||||
pipeline_manifest="$result_dir/pipelinerun.yaml"
|
||||
cat >"$pipeline_manifest" <<YAML
|
||||
apiVersion: tekton.dev/v1
|
||||
@@ -175,6 +221,14 @@ spec:
|
||||
value: "$run_id"
|
||||
- name: keep-namespace
|
||||
value: "$keep_namespace"
|
||||
- name: backend-core-commit
|
||||
value: "$backend_commit"
|
||||
- name: frontend-commit
|
||||
value: "$frontend_commit"
|
||||
- name: code-queue-commit
|
||||
value: "$code_queue_commit"
|
||||
- name: deploy-json-b64
|
||||
value: "$deploy_json_b64"
|
||||
workspaces:
|
||||
- name: shared-workspace
|
||||
persistentVolumeClaim:
|
||||
|
||||
@@ -81,6 +81,32 @@ function help(): unknown {
|
||||
};
|
||||
}
|
||||
|
||||
function isHelpToken(value: string | undefined): boolean {
|
||||
return value === "help" || value === "--help" || value === "-h";
|
||||
}
|
||||
|
||||
function sshHelp(): unknown {
|
||||
return {
|
||||
command: "ssh",
|
||||
output: "json",
|
||||
description: "Open a Host SSH / WSL SSH maintenance session through the provider-gateway bridge.",
|
||||
usage: [
|
||||
"bun scripts/cli.ts ssh <providerId>",
|
||||
"bun scripts/cli.ts ssh <providerId> argv <command> [args...]",
|
||||
"bun scripts/cli.ts ssh <providerId> apply-patch < patch.diff",
|
||||
"bun scripts/cli.ts ssh <providerId> py [script-args...] < script.py",
|
||||
"bun scripts/cli.ts ssh <providerId> skills [--scope all|wsl|windows] [--limit N]",
|
||||
"bun scripts/cli.ts ssh <providerId> find <path...> [--contains TEXT] [--limit N]",
|
||||
"bun scripts/cli.ts ssh <providerId> glob [--root DIR] [--pattern PATTERN]",
|
||||
],
|
||||
notes: [
|
||||
"ssh --help and ssh <providerId> --help print this JSON help and never open an interactive session.",
|
||||
"Use argv when nested shell quoting would be fragile.",
|
||||
"Use -- before a remote command that intentionally starts with a dash.",
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
function numberOption(name: string, defaultValue: number): number {
|
||||
const index = args.indexOf(name);
|
||||
if (index === -1) return defaultValue;
|
||||
@@ -147,6 +173,11 @@ async function main(): Promise<void> {
|
||||
return;
|
||||
}
|
||||
|
||||
if (top === "ssh" && (sub === undefined || isHelpToken(sub) || (isHelpToken(third) && args.length === 3))) {
|
||||
emitJson(commandName, sshHelp());
|
||||
return;
|
||||
}
|
||||
|
||||
if (top === "internal" && sub === "run-job") {
|
||||
if (!third) throw new Error("internal run-job requires job id");
|
||||
emitJson(commandName, await runJob(third));
|
||||
|
||||
+5
-2
@@ -593,6 +593,7 @@ async function runRemoteDevE2ELauncher(options: CiDevE2EOptions): Promise<Dispat
|
||||
"test \"$resolved\" = \"$commit\" || { echo \"resolved_commit_mismatch=$resolved expected=$commit\" >&2; exit 1; }",
|
||||
"git -C \"$repo_dir\" cat-file -e \"$resolved:$script_path\"",
|
||||
"git -C \"$repo_dir\" show \"$resolved:$script_path\" > \"$work_dir/runner.sh\"",
|
||||
"git -C \"$repo_dir\" show \"$resolved:deploy.json\" > \"$work_dir/deploy.json\"",
|
||||
"chmod 700 \"$work_dir/runner.sh\"",
|
||||
"echo \"runner_script_ready=$work_dir/runner.sh\"",
|
||||
"runner_args=(",
|
||||
@@ -600,6 +601,7 @@ async function runRemoteDevE2ELauncher(options: CiDevE2EOptions): Promise<Dispat
|
||||
" --repo-url \"$repo_url\"",
|
||||
" --desired-ref \"$desired_ref\"",
|
||||
" --manifest-commit \"$commit\"",
|
||||
" --manifest-file \"$work_dir/deploy.json\"",
|
||||
" --environment \"$environment\"",
|
||||
" --result-dir \"$result_dir\"",
|
||||
" --timeout-ms \"$timeout_ms\"",
|
||||
@@ -629,8 +631,9 @@ async function waitForDevE2EResult(runId: string, waitMs: number): Promise<Dispa
|
||||
"tail -n 80 \"$result_dir/runner.log\" 2>/dev/null || true",
|
||||
].join("\n"), 30_000, 20_000);
|
||||
latest = result;
|
||||
if (result.ok && result.stdout.trimStart().startsWith("{")) {
|
||||
const parsed = JSON.parse(result.stdout) as { ok?: boolean; status?: string };
|
||||
const stdout = result.stdout.trimStart();
|
||||
if (stdout.startsWith("{")) {
|
||||
const parsed = JSON.parse(stdout) as { ok?: boolean; status?: string };
|
||||
return {
|
||||
...result,
|
||||
ok: parsed.ok === true,
|
||||
|
||||
Reference in New Issue
Block a user