fix: skip prepare-source dependency install

This commit is contained in:
UniDesk Codex
2026-07-04 15:46:49 +08:00
parent 37fdcd2e6f
commit 952af96020
+28 -20
View File
@@ -1930,20 +1930,7 @@ function prepareSourceScript() {
"git merge-base --is-ancestor \"$(params.revision)\" \"origin/$(params.source-branch)\" || { echo '{\"event\":\"source-ancestry\",\"status\":\"failed\",\"revision\":\"'\"$(params.revision)\"'\",\"sourceBranch\":\"'\"$(params.source-branch)\"'\"}'; exit 32; }",
"ci_timing_emit source-clone succeeded \"$source_clone_started_ms\"",
"prepare_source_dependencies_started_ms=\"$(ci_now_ms)\"",
"if node -e 'require.resolve(\"yaml\")' >/dev/null 2>&1; then",
" echo '{\"event\":\"prepare-source-dependencies\",\"status\":\"cached\",\"dependency\":\"yaml\"}'",
"elif [ -f package-lock.json ]; then",
" command -v npm >/dev/null 2>&1 || { echo '{\"event\":\"prepare-source-dependencies\",\"status\":\"failed\",\"reason\":\"missing-tool\",\"tool\":\"npm\"}'; exit 31; }",
" npm ci --ignore-scripts --no-audit --prefer-offline",
" echo '{\"event\":\"prepare-source-dependencies\",\"status\":\"installed\",\"manager\":\"npm\",\"dependency\":\"yaml\"}'",
"elif [ -f bun.lock ] || [ -f bun.lockb ]; then",
" command -v bun >/dev/null 2>&1 || { echo '{\"event\":\"prepare-source-dependencies\",\"status\":\"failed\",\"reason\":\"missing-tool\",\"tool\":\"bun\"}'; exit 31; }",
" bun install --frozen-lockfile --ignore-scripts",
" echo '{\"event\":\"prepare-source-dependencies\",\"status\":\"installed\",\"manager\":\"bun\",\"dependency\":\"yaml\"}'",
"else",
" echo '{\"event\":\"prepare-source-dependencies\",\"status\":\"failed\",\"reason\":\"lockfile-missing\",\"dependency\":\"yaml\"}'",
" exit 33",
"fi",
"echo '{\"event\":\"prepare-source-dependencies\",\"status\":\"skipped\",\"reason\":\"renderer-dependency-install-disabled\",\"dependency\":\"yaml\"}'",
"ci_timing_emit prepare-source-dependencies succeeded \"$prepare_source_dependencies_started_ms\"",
"catalog_path=\"$(params.catalog-path)\"",
"mkdir -p \"$(dirname \"$catalog_path\")\"",
@@ -1955,14 +1942,24 @@ function prepareSourceScript() {
" git show FETCH_HEAD:\"$catalog_path\" > /tmp/hwlab-gitops-artifact-catalog.json",
" if node --input-type=module - /tmp/hwlab-gitops-artifact-catalog.json deploy/deploy.yaml \"$(params.services)\" <<'NODE'",
"import fs from \"node:fs\";",
"import { readStructuredFile } from \"./scripts/src/structured-config.mjs\";",
"const [catalogPath, deployPath, selectedServices] = process.argv.slice(2);",
"const ids = (doc) => (doc.services || []).map((service) => service.serviceId).filter(Boolean);",
"const topLevelServiceIds = (text) => {",
" const values = [];",
" let inServices = false;",
" for (const line of text.split(/\\r?\\n/u)) {",
" if (/^services:\\s*$/u.test(line)) { inServices = true; continue; }",
" if (!inServices) continue;",
" if (/^\\S/u.test(line)) break;",
" const match = line.match(/^\\s*-\\s+serviceId:\\s*['\"]?([^'\"#\\s]+)['\"]?/u);",
" if (match) values.push(match[1]);",
" }",
" return values;",
"};",
"const selected = (selectedServices || \"\").split(\",\").map((item) => item.trim()).filter(Boolean);",
"const uniqueSorted = (items) => [...new Set(items)].sort();",
"const gitops = JSON.parse(fs.readFileSync(catalogPath, \"utf8\"));",
"const deploy = await readStructuredFile(process.cwd(), deployPath);",
"const expected = selected.length ? selected : ids(deploy);",
"const expected = selected.length ? selected : topLevelServiceIds(fs.readFileSync(deployPath, \"utf8\"));",
"const actual = ids(gitops);",
"const expectedSet = uniqueSorted(expected);",
"const actualSet = uniqueSorted(actual);",
@@ -1989,13 +1986,24 @@ function prepareSourceScript() {
"if [ ! -s \"$catalog_path\" ] && [ \"$(params.lane)\" = \"v02\" ]; then",
" node --input-type=module - \"$catalog_path\" \"$(params.revision)\" \"$(params.registry-prefix)\" \"$(params.image-tag-mode)\" \"$(params.services)\" <<'NODE'",
"import fs from 'node:fs';",
"import { readStructuredFile } from './scripts/src/structured-config.mjs';",
"import path from 'node:path';",
"const [catalogPath, revision, registryPrefix, imageTagMode, selectedServices] = process.argv.slice(2);",
"const deploy = await readStructuredFile(process.cwd(), 'deploy/deploy.yaml');",
"const topLevelServiceIds = (text) => {",
" const values = [];",
" let inServices = false;",
" for (const line of text.split(/\\r?\\n/u)) {",
" if (/^services:\\s*$/u.test(line)) { inServices = true; continue; }",
" if (!inServices) continue;",
" if (/^\\S/u.test(line)) break;",
" const match = line.match(/^\\s*-\\s+serviceId:\\s*['\"]?([^'\"#\\s]+)['\"]?/u);",
" if (match) values.push(match[1]);",
" }",
" return values;",
"};",
"const tag = imageTagMode === 'full' ? revision : revision.slice(0, 7);",
"const namespace = 'hwlab-v02';",
"const selected = (selectedServices || '').split(',').filter(Boolean);",
"const serviceIds = selected.length ? selected : (deploy.services || []).map((service) => service.serviceId);",
"const serviceIds = selected.length ? selected : topLevelServiceIds(fs.readFileSync('deploy/deploy.yaml', 'utf8'));",
"const services = serviceIds.map((serviceId) => {",
" const service = { serviceId, profile: 'v02', namespace, commitId: tag, sourceCommitId: revision, image: `${registryPrefix}/${serviceId}:${tag}`, imageTag: tag, digest: null, buildBackend: 'contract-skeleton' };",
" return service;",