fix(hwlab): avoid prepare-source yaml runtime dependency (#809)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -152,8 +152,6 @@ targets:
|
|||||||
- COPY --from=python-runtime /usr/local /usr/local
|
- COPY --from=python-runtime /usr/local /usr/local
|
||||||
- COPY --from=docker-cli-runtime /usr/local/bin/docker /usr/local/bin/docker
|
- COPY --from=docker-cli-runtime /usr/local/bin/docker /usr/local/bin/docker
|
||||||
- RUN ln -sf /usr/local/bin/bun /usr/local/bin/bunx
|
- 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
|
- RUN node --version && npm --version && bun --version && git --version && python3 --version && docker --version && ssh -V
|
||||||
buildArgs:
|
buildArgs:
|
||||||
NODE_IMAGE: docker.io/library/node:22-bookworm-slim
|
NODE_IMAGE: docker.io/library/node:22-bookworm-slim
|
||||||
|
|||||||
@@ -4949,18 +4949,7 @@ function nodeRuntimePipelinePostprocessScript(): string[] {
|
|||||||
"const stepEnv = { ...proxyEnv, ...dockerProxyEnv, ...(overlay.stepEnv || {}) };",
|
"const stepEnv = { ...proxyEnv, ...dockerProxyEnv, ...(overlay.stepEnv || {}) };",
|
||||||
"function prepareSourceDependencyScript() {",
|
"function prepareSourceDependencyScript() {",
|
||||||
" return `prepare_source_dependencies_started_ms=\"$(ci_now_ms)\"",
|
" return `prepare_source_dependencies_started_ms=\"$(ci_now_ms)\"",
|
||||||
"node <<'NODE_UNIDESK_YAML_DEPENDENCY'",
|
"echo '{\"event\":\"prepare-source-dependencies\",\"status\":\"not-required\",\"dependency\":\"yaml\",\"manager\":\"inline-service-id-parser\"}' >&2",
|
||||||
"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",
|
|
||||||
"ci_timing_emit prepare-source-dependencies succeeded \"$prepare_source_dependencies_started_ms\"`;",
|
"ci_timing_emit prepare-source-dependencies succeeded \"$prepare_source_dependencies_started_ms\"`;",
|
||||||
"}",
|
"}",
|
||||||
"function validatePrepareSourceDependencyScript(script) {",
|
"function validatePrepareSourceDependencyScript(script) {",
|
||||||
@@ -5620,6 +5609,9 @@ function nodeRuntimePipelinePostprocessScript(): string[] {
|
|||||||
"}",
|
"}",
|
||||||
"function patchScript(script) {",
|
"function patchScript(script) {",
|
||||||
" let result = String(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')) {",
|
" 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');",
|
" 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 (!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('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('/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}`); }",
|
"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);",
|
"fs.writeFileSync(pipelinePath, text);",
|
||||||
|
|||||||
Reference in New Issue
Block a user