fix(hwlab): avoid prepare-source yaml runtime dependency (#809)

Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
Lyon
2026-06-24 10:45:06 +08:00
committed by GitHub
parent cac291d7af
commit 467abd16d4
2 changed files with 5 additions and 15 deletions
-2
View File
@@ -152,8 +152,6 @@ targets:
- COPY --from=python-runtime /usr/local /usr/local
- COPY --from=docker-cli-runtime /usr/local/bin/docker /usr/local/bin/docker
- RUN ln -sf /usr/local/bin/bun /usr/local/bin/bunx
- ENV NODE_PATH=/usr/local/lib/node_modules
- RUN npm install -g --omit=dev --ignore-scripts --no-audit --no-fund yaml@2.8.3 && NODE_PATH=/usr/local/lib/node_modules node -e "require.resolve('yaml')"
- RUN node --version && npm --version && bun --version && git --version && python3 --version && docker --version && ssh -V
buildArgs:
NODE_IMAGE: docker.io/library/node:22-bookworm-slim
+5 -13
View File
@@ -4949,18 +4949,7 @@ function nodeRuntimePipelinePostprocessScript(): string[] {
"const stepEnv = { ...proxyEnv, ...dockerProxyEnv, ...(overlay.stepEnv || {}) };",
"function prepareSourceDependencyScript() {",
" return `prepare_source_dependencies_started_ms=\"$(ci_now_ms)\"",
"node <<'NODE_UNIDESK_YAML_DEPENDENCY'",
"const dependency = 'yaml';",
"function emit(status, extra = {}) { console.error(JSON.stringify({ event: 'prepare-source-dependencies', status, dependency, ...extra })); }",
"try {",
" const resolved = require.resolve('yaml');",
" emit('cached', { manager: 'tools-image', resolved });",
" process.exit(0);",
"} catch (error) {",
" emit('failed', { reason: 'tools-image-missing-yaml', message: error && error.message ? error.message : String(error) });",
" process.exit(34);",
"}",
"NODE_UNIDESK_YAML_DEPENDENCY",
"echo '{\"event\":\"prepare-source-dependencies\",\"status\":\"not-required\",\"dependency\":\"yaml\",\"manager\":\"inline-service-id-parser\"}' >&2",
"ci_timing_emit prepare-source-dependencies succeeded \"$prepare_source_dependencies_started_ms\"`;",
"}",
"function validatePrepareSourceDependencyScript(script) {",
@@ -5620,6 +5609,9 @@ function nodeRuntimePipelinePostprocessScript(): string[] {
"}",
"function patchScript(script) {",
" let result = String(script || '');",
" const inlineDeployServiceIdParser = `const deployText = fs.readFileSync(deployPath, 'utf8');\\nconst deploy = { services: [...deployText.matchAll(/(?:^|\\\\n)\\\\s*serviceId:\\\\s*[\\\"']?([^\\\"'\\\\n#]+)[\\\"']?/g)].map((match) => ({ serviceId: match[1].trim() })) };`;",
" result = result.split('import { readStructuredFile } from \"./scripts/src/structured-config.mjs\";\\n').join('');",
" result = result.split('const deploy = await readStructuredFile(process.cwd(), deployPath);').join(inlineDeployServiceIdParser);",
" if (result.includes('npm run gitops:ts:check')) {",
" result = result.replace(/\\n[ \\t]*npm run gitops:ts:check\\n/g, '\\n echo \\'{\"event\":\"unidesk-node-contract-check\",\"status\":\"skipped\",\"reason\":\"d601-yaml-render-check-replaces-tsc-gate\"}\\' >&2\\n');",
" }",
@@ -5859,7 +5851,7 @@ function nodeRuntimePipelinePostprocessScript(): string[] {
"}",
"if (!structured && !changed && !text.includes(`--gitops-root ${quotedRoot}`) && !text.includes(`--gitops-root ${escapedQuotedRoot}`)) { throw new Error(`generated pipeline missing expected gitops-render invocation in ${pipelinePath}`); }",
"if (text.includes('prepare_source_dependencies_started_ms=\"$(ci_now_ms)\"') && text.includes('npm ci --ignore-scripts --no-audit --prefer-offline')) { throw new Error(`generated pipeline still uses full npm ci prepare-source dependency install in ${pipelinePath}`); }",
"if (text.includes('prepare_source_dependencies_started_ms=\"$(ci_now_ms)\"') && !text.includes('NODE_UNIDESK_YAML_DEPENDENCY')) { throw new Error(`generated pipeline missing UniDesk yaml dependency install in ${pipelinePath}`); }",
"if (text.includes('readStructuredFile(process.cwd(), deployPath)')) { throw new Error(`generated pipeline still imports YAML parser for prepare-source catalog check in ${pipelinePath}`); }",
"if (text.includes('/yaml/-/yaml-') || text.includes('bun add --no-save --ignore-scripts') || text.includes('npm install --package-lock=false --no-save')) { throw new Error(`generated pipeline still downloads yaml during prepare-source in ${pipelinePath}`); }",
"if (text.includes('npm run gitops:ts:check')) { throw new Error(`generated pipeline still uses npm gitops:ts:check gate in ${pipelinePath}`); }",
"fs.writeFileSync(pipelinePath, text);",