fix: configure JD01 workspace git proxy
This commit is contained in:
@@ -455,11 +455,16 @@ function sourceWorkspaceHostBootstrapSubmitScript(spec: HwlabRuntimeLaneSpec, so
|
||||
return [
|
||||
"set +e",
|
||||
`workspace=${shellQuote(spec.workspace)}`,
|
||||
`expected_branch=${shellQuote(spec.sourceBranch)}`,
|
||||
`state_dir=${shellQuote(stateDir)}`,
|
||||
`dependency_command_b64=${shellQuote(Buffer.from(sourceWorkspace.install.dependencyCommand, "utf8").toString("base64"))}`,
|
||||
`browser_command_b64=${shellQuote(Buffer.from(sourceWorkspace.install.browserCommand, "utf8").toString("base64"))}`,
|
||||
`required_files_b64=${shellQuote(Buffer.from(requiredFiles, "utf8").toString("base64"))}`,
|
||||
`timeout_seconds=${String(sourceWorkspace.install.timeoutSeconds)}`,
|
||||
`remote_name=${shellQuote(sourceWorkspace.git?.remoteName ?? "origin")}`,
|
||||
`remote_url=${shellQuote(sourceWorkspace.git?.remoteUrl ?? "")}`,
|
||||
`proxy_env_path=${shellQuote(sourceWorkspace.git?.proxyEnvPath ?? "")}`,
|
||||
`git_timeout=${String(spec.downloadProfile.git.timeoutSeconds)}`,
|
||||
`http_proxy_value=${shellQuote(spec.networkProfile.proxy.http)}`,
|
||||
`https_proxy_value=${shellQuote(spec.networkProfile.proxy.https)}`,
|
||||
`all_proxy_value=${shellQuote(spec.networkProfile.proxy.all)}`,
|
||||
@@ -489,11 +494,15 @@ function sourceWorkspaceHostBootstrapSubmitScript(spec: HwlabRuntimeLaneSpec, so
|
||||
"NODE",
|
||||
"(",
|
||||
" set +e",
|
||||
" export HTTP_PROXY=\"$http_proxy_value\" HTTPS_PROXY=\"$https_proxy_value\" ALL_PROXY=\"$all_proxy_value\" NO_PROXY=\"$no_proxy_value\"",
|
||||
" export http_proxy=\"$http_proxy_value\" https_proxy=\"$https_proxy_value\" all_proxy=\"$all_proxy_value\" no_proxy=\"$no_proxy_value\"",
|
||||
" if [ -n \"$proxy_env_path\" ] && [ -f \"$proxy_env_path\" ]; then . \"$proxy_env_path\" 2>/dev/null || true; fi",
|
||||
" export HTTP_PROXY=\"${HTTP_PROXY:-$http_proxy_value}\" HTTPS_PROXY=\"${HTTPS_PROXY:-$https_proxy_value}\" ALL_PROXY=\"${ALL_PROXY:-$all_proxy_value}\" NO_PROXY=\"${NO_PROXY:-$no_proxy_value}\"",
|
||||
" export http_proxy=\"${http_proxy:-$HTTP_PROXY}\" https_proxy=\"${https_proxy:-$HTTPS_PROXY}\" all_proxy=\"${all_proxy:-$ALL_PROXY}\" no_proxy=\"${no_proxy:-$NO_PROXY}\"",
|
||||
" failure_kind=",
|
||||
" dependency_exit=1",
|
||||
" browser_exit=1",
|
||||
" git_fetch_exit=0",
|
||||
" git_update_exit=0",
|
||||
" remote_url_after=",
|
||||
" missing_files=",
|
||||
" source_commit=",
|
||||
" status_short=",
|
||||
@@ -511,15 +520,36 @@ function sourceWorkspaceHostBootstrapSubmitScript(spec: HwlabRuntimeLaneSpec, so
|
||||
" failure_kind=workspace-dirty",
|
||||
" printf '%s\\n' \"source workspace is dirty; refusing to install dependencies\" >>\"$stderr_file\"",
|
||||
" else",
|
||||
" timeout \"$timeout_seconds\" /bin/bash \"$dependency_file\" >>\"$stdout_file\" 2>>\"$stderr_file\"",
|
||||
" dependency_exit=$?",
|
||||
" if [ \"$dependency_exit\" -eq 0 ]; then",
|
||||
" timeout \"$timeout_seconds\" /bin/bash \"$browser_file\" >>\"$stdout_file\" 2>>\"$stderr_file\"",
|
||||
" browser_exit=$?",
|
||||
" else",
|
||||
" failure_kind=dependency-command-failed",
|
||||
" if [ -n \"$remote_url\" ]; then",
|
||||
" git remote set-url \"$remote_name\" \"$remote_url\" >>\"$stdout_file\" 2>>\"$stderr_file\" || git remote add \"$remote_name\" \"$remote_url\" >>\"$stdout_file\" 2>>\"$stderr_file\"",
|
||||
" remote_url_after=$(git remote get-url \"$remote_name\" 2>/dev/null || true)",
|
||||
" timeout \"$git_timeout\" git fetch \"$remote_name\" \"$expected_branch:refs/remotes/$remote_name/$expected_branch\" >>\"$stdout_file\" 2>>\"$stderr_file\"",
|
||||
" git_fetch_exit=$?",
|
||||
" if [ \"$git_fetch_exit\" -ne 0 ]; then",
|
||||
" failure_kind=git-fetch-failed",
|
||||
" else",
|
||||
" current_branch=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true)",
|
||||
" if [ \"$current_branch\" = \"$expected_branch\" ]; then",
|
||||
" git merge --ff-only \"refs/remotes/$remote_name/$expected_branch\" >>\"$stdout_file\" 2>>\"$stderr_file\"",
|
||||
" git_update_exit=$?",
|
||||
" else",
|
||||
" git checkout -B \"$expected_branch\" \"refs/remotes/$remote_name/$expected_branch\" >>\"$stdout_file\" 2>>\"$stderr_file\"",
|
||||
" git_update_exit=$?",
|
||||
" fi",
|
||||
" if [ \"$git_update_exit\" -ne 0 ]; then failure_kind=git-update-failed; fi",
|
||||
" fi",
|
||||
" fi",
|
||||
" if [ -z \"$failure_kind\" ]; then",
|
||||
" timeout \"$timeout_seconds\" /bin/bash \"$dependency_file\" >>\"$stdout_file\" 2>>\"$stderr_file\"",
|
||||
" dependency_exit=$?",
|
||||
" if [ \"$dependency_exit\" -eq 0 ]; then",
|
||||
" timeout \"$timeout_seconds\" /bin/bash \"$browser_file\" >>\"$stdout_file\" 2>>\"$stderr_file\"",
|
||||
" browser_exit=$?",
|
||||
" else",
|
||||
" failure_kind=dependency-command-failed",
|
||||
" fi",
|
||||
" if [ \"$dependency_exit\" -eq 0 ] && [ \"$browser_exit\" -ne 0 ]; then failure_kind=browser-command-failed; fi",
|
||||
" fi",
|
||||
" if [ \"$dependency_exit\" -eq 0 ] && [ \"$browser_exit\" -ne 0 ]; then failure_kind=browser-command-failed; fi",
|
||||
" while IFS= read -r file_path; do",
|
||||
" [ -z \"$file_path\" ] && continue",
|
||||
" if [ ! -e \"$workspace/$file_path\" ]; then missing_files=\"$missing_files${missing_files:+,}$file_path\"; fi",
|
||||
@@ -532,15 +562,17 @@ function sourceWorkspaceHostBootstrapSubmitScript(spec: HwlabRuntimeLaneSpec, so
|
||||
" npx_version=$(npx --version 2>/dev/null || true)",
|
||||
" fi",
|
||||
" fi",
|
||||
" JOB_ID=\"$job_id\" WORKSPACE=\"$workspace\" STATE_DIR=\"$state_dir\" STATUS_FILE=\"$status_file\" STDOUT_FILE=\"$stdout_file\" STDERR_FILE=\"$stderr_file\" COMMAND_SHA=\"$command_sha\" FAILURE_KIND=\"$failure_kind\" DEPENDENCY_EXIT=\"$dependency_exit\" BROWSER_EXIT=\"$browser_exit\" MISSING_FILES=\"$missing_files\" SOURCE_COMMIT=\"$source_commit\" STATUS_SHORT=\"$status_short\" NODE_VERSION=\"$node_version\" NPM_VERSION=\"$npm_version\" NPX_VERSION=\"$npx_version\" node <<'NODE' >\"$status_file\"",
|
||||
" JOB_ID=\"$job_id\" WORKSPACE=\"$workspace\" STATE_DIR=\"$state_dir\" STATUS_FILE=\"$status_file\" STDOUT_FILE=\"$stdout_file\" STDERR_FILE=\"$stderr_file\" COMMAND_SHA=\"$command_sha\" FAILURE_KIND=\"$failure_kind\" DEPENDENCY_EXIT=\"$dependency_exit\" BROWSER_EXIT=\"$browser_exit\" GIT_FETCH_EXIT=\"$git_fetch_exit\" GIT_UPDATE_EXIT=\"$git_update_exit\" REMOTE_URL_AFTER=\"$remote_url_after\" MISSING_FILES=\"$missing_files\" SOURCE_COMMIT=\"$source_commit\" STATUS_SHORT=\"$status_short\" NODE_VERSION=\"$node_version\" NPM_VERSION=\"$npm_version\" NPX_VERSION=\"$npx_version\" node <<'NODE' >\"$status_file\"",
|
||||
"const fs = require('fs');",
|
||||
"const tail = (file) => { try { return fs.readFileSync(file, 'utf8').slice(-4000); } catch { return ''; } };",
|
||||
"const missingFiles = (process.env.MISSING_FILES || '').split(',').filter(Boolean);",
|
||||
"const dependencyExit = Number(process.env.DEPENDENCY_EXIT || '1');",
|
||||
"const browserExit = Number(process.env.BROWSER_EXIT || '1');",
|
||||
"const gitFetchExit = Number(process.env.GIT_FETCH_EXIT || '0');",
|
||||
"const gitUpdateExit = Number(process.env.GIT_UPDATE_EXIT || '0');",
|
||||
"const statusShort = process.env.STATUS_SHORT || '';",
|
||||
"const ok = dependencyExit === 0 && browserExit === 0 && missingFiles.length === 0 && !statusShort && !process.env.FAILURE_KIND;",
|
||||
"console.log(JSON.stringify({ ok, status: ok ? 'succeeded' : 'failed', jobId: process.env.JOB_ID, workspace: process.env.WORKSPACE, stateDir: process.env.STATE_DIR, statusFile: process.env.STATUS_FILE, stdoutFile: process.env.STDOUT_FILE, stderrFile: process.env.STDERR_FILE, installCommandSha256: process.env.COMMAND_SHA, failureKind: process.env.FAILURE_KIND || null, dependencyExitCode: dependencyExit, browserExitCode: browserExit, missingFiles, sourceCommit: process.env.SOURCE_COMMIT || null, workspaceClean: !statusShort, statusShort: statusShort || null, nodeVersion: process.env.NODE_VERSION || null, npmVersion: process.env.NPM_VERSION || null, npxVersion: process.env.NPX_VERSION || null, stdoutTail: tail(process.env.STDOUT_FILE), stderrTail: tail(process.env.STDERR_FILE), finishedAt: new Date().toISOString(), valuesPrinted: false }));",
|
||||
"console.log(JSON.stringify({ ok, status: ok ? 'succeeded' : 'failed', jobId: process.env.JOB_ID, workspace: process.env.WORKSPACE, stateDir: process.env.STATE_DIR, statusFile: process.env.STATUS_FILE, stdoutFile: process.env.STDOUT_FILE, stderrFile: process.env.STDERR_FILE, installCommandSha256: process.env.COMMAND_SHA, failureKind: process.env.FAILURE_KIND || null, dependencyExitCode: dependencyExit, browserExitCode: browserExit, gitFetchExitCode: gitFetchExit, gitUpdateExitCode: gitUpdateExit, remoteUrlAfter: process.env.REMOTE_URL_AFTER || null, missingFiles, sourceCommit: process.env.SOURCE_COMMIT || null, workspaceClean: !statusShort, statusShort: statusShort || null, nodeVersion: process.env.NODE_VERSION || null, npmVersion: process.env.NPM_VERSION || null, npxVersion: process.env.NPX_VERSION || null, stdoutTail: tail(process.env.STDOUT_FILE), stderrTail: tail(process.env.STDERR_FILE), finishedAt: new Date().toISOString(), valuesPrinted: false }));",
|
||||
"NODE",
|
||||
") >/dev/null 2>&1 &",
|
||||
"pid=$!",
|
||||
@@ -599,6 +631,15 @@ function sourceWorkspaceExpected(spec: HwlabRuntimeLaneSpec, sourceWorkspace: Hw
|
||||
return {
|
||||
workspace: spec.workspace,
|
||||
sourceBranch: spec.sourceBranch,
|
||||
sourceWorkspaceGit: sourceWorkspace.git === undefined ? null : {
|
||||
remoteName: sourceWorkspace.git.remoteName,
|
||||
remoteUrl: sourceWorkspace.git.remoteUrl,
|
||||
identityTarget: sourceWorkspace.git.identityTarget ?? null,
|
||||
identityId: sourceWorkspace.git.identityId ?? null,
|
||||
proxyEnvPath: sourceWorkspace.git.proxyEnvPath ?? null,
|
||||
verifyRemote: sourceWorkspace.git.verifyRemote,
|
||||
requireUpToDate: sourceWorkspace.git.requireUpToDate,
|
||||
},
|
||||
git: {
|
||||
url: spec.gitUrl,
|
||||
readUrl: spec.gitReadUrl,
|
||||
@@ -634,12 +675,18 @@ function sourceWorkspaceHostDependenciesExpected(hostDependencies: HwlabRuntimeS
|
||||
function sourceWorkspaceStatusFromFields(fields: Record<string, string>, exitCode: number | null): Record<string, unknown> {
|
||||
const missingCommands = commaListField(fields.missingCommands);
|
||||
const missingFiles = commaListField(fields.missingFiles);
|
||||
const remoteReachabilityRequired = fields.remoteReachabilityRequired === "yes";
|
||||
const remoteUpToDateRequired = fields.remoteUpToDateRequired === "yes";
|
||||
const remoteReachable = fields.remoteReachable === "yes";
|
||||
const remoteHead = fields.remoteHead || "";
|
||||
const ok = exitCode === 0
|
||||
&& fields.workspaceExists === "yes"
|
||||
&& fields.gitDirExists === "yes"
|
||||
&& fields.workspaceClean === "yes"
|
||||
&& fields.branch === fields.expectedBranch
|
||||
&& fields.remoteMatchesYaml === "yes"
|
||||
&& (!remoteReachabilityRequired || remoteReachable)
|
||||
&& (!remoteUpToDateRequired || remoteHead.length === 0 || fields.localHead === remoteHead)
|
||||
&& missingCommands.length === 0
|
||||
&& missingFiles.length === 0
|
||||
&& fields.playwrightPackagePresent === "yes"
|
||||
@@ -656,8 +703,16 @@ function sourceWorkspaceStatusFromFields(fields: Record<string, string>, exitCod
|
||||
branch: fields.branch || null,
|
||||
detached: fields.detached === "yes",
|
||||
localHead: fields.localHead || null,
|
||||
expectedRemoteUrl: fields.expectedRemoteUrl || null,
|
||||
remoteUrl: fields.remoteUrl || null,
|
||||
remoteMatchesYaml: fields.remoteMatchesYaml === "yes",
|
||||
remoteReachabilityRequired,
|
||||
remoteUpToDateRequired,
|
||||
remoteReachable,
|
||||
remoteHead: remoteHead || null,
|
||||
remoteProbeExitCode: numericField(fields.remoteProbeExitCode),
|
||||
remoteProbeErrorTail: fields.remoteProbeErrorTail || null,
|
||||
remoteUpToDate: remoteHead.length === 0 ? null : fields.localHead === remoteHead,
|
||||
requiredCommands: commaListField(fields.requiredCommands),
|
||||
missingCommands,
|
||||
requiredFiles: commaListField(fields.requiredFiles),
|
||||
@@ -795,11 +850,20 @@ function sourceWorkspaceHostDependenciesSubmitScript(
|
||||
function sourceWorkspaceStatusScript(spec: HwlabRuntimeLaneSpec, sourceWorkspace: HwlabRuntimeSourceWorkspaceSpec): string {
|
||||
const requiredCommands = shellLinesText(sourceWorkspace.requiredCommands);
|
||||
const requiredFiles = shellLinesText(sourceWorkspace.requiredFiles);
|
||||
const remoteUrls = shellLinesText([spec.gitUrl, spec.gitReadUrl, spec.gitWriteUrl]);
|
||||
const remoteUrls = shellLinesText(sourceWorkspace.git === undefined ? [spec.gitUrl, spec.gitReadUrl, spec.gitWriteUrl] : [sourceWorkspace.git.remoteUrl]);
|
||||
return [
|
||||
"set +e",
|
||||
`workspace=${shellQuote(spec.workspace)}`,
|
||||
`expected_branch=${shellQuote(spec.sourceBranch)}`,
|
||||
`remote_name=${shellQuote(sourceWorkspace.git?.remoteName ?? "origin")}`,
|
||||
`verify_remote=${shellQuote(sourceWorkspace.git?.verifyRemote === true ? "yes" : "no")}`,
|
||||
`require_up_to_date=${shellQuote(sourceWorkspace.git?.requireUpToDate === true ? "yes" : "no")}`,
|
||||
`proxy_env_path=${shellQuote(sourceWorkspace.git?.proxyEnvPath ?? "")}`,
|
||||
`git_timeout=${String(spec.downloadProfile.git.timeoutSeconds)}`,
|
||||
`http_proxy_value=${shellQuote(spec.networkProfile.proxy.http)}`,
|
||||
`https_proxy_value=${shellQuote(spec.networkProfile.proxy.https)}`,
|
||||
`all_proxy_value=${shellQuote(spec.networkProfile.proxy.all)}`,
|
||||
`no_proxy_value=${shellQuote(spec.networkProfile.proxy.noProxy.join(","))}`,
|
||||
`required_commands_b64=${shellQuote(Buffer.from(requiredCommands, "utf8").toString("base64"))}`,
|
||||
`required_files_b64=${shellQuote(Buffer.from(requiredFiles, "utf8").toString("base64"))}`,
|
||||
`remote_urls_b64=${shellQuote(Buffer.from(remoteUrls, "utf8").toString("base64"))}`,
|
||||
@@ -808,6 +872,7 @@ function sourceWorkspaceStatusScript(spec: HwlabRuntimeLaneSpec, sourceWorkspace
|
||||
"printf '%s' \"$required_commands_b64\" | base64 -d >\"$tmp_dir/commands.txt\"",
|
||||
"printf '%s' \"$required_files_b64\" | base64 -d >\"$tmp_dir/files.txt\"",
|
||||
"printf '%s' \"$remote_urls_b64\" | base64 -d >\"$tmp_dir/remotes.txt\"",
|
||||
"expected_remote_url=$(head -n 1 \"$tmp_dir/remotes.txt\" 2>/dev/null || true)",
|
||||
"workspace_exists=no",
|
||||
"git_dir_exists=no",
|
||||
"workspace_clean=no",
|
||||
@@ -816,6 +881,10 @@ function sourceWorkspaceStatusScript(spec: HwlabRuntimeLaneSpec, sourceWorkspace
|
||||
"local_head=",
|
||||
"remote_url=",
|
||||
"remote_matches_yaml=no",
|
||||
"remote_reachable=skipped",
|
||||
"remote_head=",
|
||||
"remote_probe_exit=",
|
||||
"remote_probe_error_tail=",
|
||||
"status_short=",
|
||||
"if [ -d \"$workspace\" ]; then",
|
||||
" workspace_exists=yes",
|
||||
@@ -824,10 +893,20 @@ function sourceWorkspaceStatusScript(spec: HwlabRuntimeLaneSpec, sourceWorkspace
|
||||
" branch=$(git -C \"$workspace\" rev-parse --abbrev-ref HEAD 2>/dev/null || true)",
|
||||
" [ \"$branch\" = HEAD ] && detached=yes",
|
||||
" local_head=$(git -C \"$workspace\" rev-parse HEAD 2>/dev/null || true)",
|
||||
" remote_url=$(git -C \"$workspace\" remote get-url origin 2>/dev/null || true)",
|
||||
" remote_url=$(git -C \"$workspace\" remote get-url \"$remote_name\" 2>/dev/null || true)",
|
||||
" status_short=$(git -C \"$workspace\" status --short 2>/dev/null || true)",
|
||||
" [ -z \"$status_short\" ] && workspace_clean=yes",
|
||||
" while IFS= read -r expected_remote; do [ \"$remote_url\" = \"$expected_remote\" ] && remote_matches_yaml=yes; done <\"$tmp_dir/remotes.txt\"",
|
||||
" if [ \"$verify_remote\" = yes ] && [ -n \"$expected_remote_url\" ]; then",
|
||||
" if [ -n \"$proxy_env_path\" ] && [ -f \"$proxy_env_path\" ]; then . \"$proxy_env_path\" 2>/dev/null || true; fi",
|
||||
" export HTTP_PROXY=\"${HTTP_PROXY:-$http_proxy_value}\" HTTPS_PROXY=\"${HTTPS_PROXY:-$https_proxy_value}\" ALL_PROXY=\"${ALL_PROXY:-$all_proxy_value}\" NO_PROXY=\"${NO_PROXY:-$no_proxy_value}\"",
|
||||
" export http_proxy=\"${http_proxy:-$HTTP_PROXY}\" https_proxy=\"${https_proxy:-$HTTPS_PROXY}\" all_proxy=\"${all_proxy:-$ALL_PROXY}\" no_proxy=\"${no_proxy:-$NO_PROXY}\"",
|
||||
" timeout \"$git_timeout\" git -C \"$workspace\" ls-remote \"$expected_remote_url\" \"refs/heads/$expected_branch\" >\"$tmp_dir/remote.out\" 2>\"$tmp_dir/remote.err\"",
|
||||
" remote_probe_exit=$?",
|
||||
" remote_head=$(awk '{print $1}' \"$tmp_dir/remote.out\" | head -n 1)",
|
||||
" remote_probe_error_tail=$(tail -c 1000 \"$tmp_dir/remote.err\" 2>/dev/null | tr '\\n\\t' ' ' | cut -c1-1000)",
|
||||
" if [ \"$remote_probe_exit\" = 0 ] && [ -n \"$remote_head\" ]; then remote_reachable=yes; else remote_reachable=no; fi",
|
||||
" fi",
|
||||
" fi",
|
||||
"fi",
|
||||
"missing_commands=",
|
||||
@@ -907,8 +986,15 @@ function sourceWorkspaceStatusScript(spec: HwlabRuntimeLaneSpec, sourceWorkspace
|
||||
"printf 'branch\\t%s\\n' \"$branch\"",
|
||||
"printf 'detached\\t%s\\n' \"$detached\"",
|
||||
"printf 'localHead\\t%s\\n' \"$local_head\"",
|
||||
"printf 'expectedRemoteUrl\\t%s\\n' \"$expected_remote_url\"",
|
||||
"printf 'remoteUrl\\t%s\\n' \"$remote_url\"",
|
||||
"printf 'remoteMatchesYaml\\t%s\\n' \"$remote_matches_yaml\"",
|
||||
"printf 'remoteReachabilityRequired\\t%s\\n' \"$verify_remote\"",
|
||||
"printf 'remoteUpToDateRequired\\t%s\\n' \"$require_up_to_date\"",
|
||||
"printf 'remoteReachable\\t%s\\n' \"$remote_reachable\"",
|
||||
"printf 'remoteHead\\t%s\\n' \"$remote_head\"",
|
||||
"printf 'remoteProbeExitCode\\t%s\\n' \"$remote_probe_exit\"",
|
||||
"printf 'remoteProbeErrorTail\\t%s\\n' \"$remote_probe_error_tail\"",
|
||||
"printf 'requiredCommands\\t%s\\n' \"$(tr '\\n' ',' <\"$tmp_dir/commands.txt\" | sed 's/,$//')\"",
|
||||
"printf 'missingCommands\\t%s\\n' \"$missing_commands\"",
|
||||
"printf 'requiredFiles\\t%s\\n' \"$(tr '\\n' ',' <\"$tmp_dir/files.txt\" | sed 's/,$//')\"",
|
||||
|
||||
Reference in New Issue
Block a user