Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors
TypeScript a2aai-agentsai-gatewayanthropicclaudeclaude-codeclinecodexcopilotcursordeepseekfree-aigeminikimillm-gatewaymcpopenaiopenai-proxyqwentoken-saver
fix(ci): deliver ONNX install skip through explicit env (#16782)
Diego Rodrigues de Sa e Souza5e3ee0d2abaa
diff --git a/.github/actions/npm-ci-retry/README.md b/.github/actions/npm-ci-retry/README.mdnew file mode 100644index 0000000000..17aa8c899a--- /dev/null+++ b/.github/actions/npm-ci-retry/README.md@@ -0,0 +1,32 @@+# npm ci with retry++This action installs the checkout dependencies with up to three attempts and restores a node_modules tree only when its complete cache key matches. Node, the lockfile, project npm configuration, postinstall helpers and the action itself participate in the key.++The installation step sets `ONNXRUNTIME_NODE_INSTALL=skip` before invoking npm. ONNX Runtime reads this environment variable directly, so skipping its additional CUDA installation does not depend on npm forwarding the custom `.npmrc` key. The repository retains that key temporarily; its npm warning can therefore remain.++## Installing this checkout locally++For a POSIX shell, set the variable on the install command:++```sh+ONNXRUNTIME_NODE_INSTALL=skip npm ci+```++Use `npm install` in place of `npm ci` when deliberately updating the lockfile.++In PowerShell, set it in the current shell before starting npm:++```powershell+$env:ONNXRUNTIME_NODE_INSTALL = "skip"+npm ci+```++The PowerShell assignment remains in that process environment and is inherited by its children. npm does not load the application's `.env` file for this purpose. A package preinstall script cannot set the environment of its parent npm process.++## Scope++The environment is scoped to this action's install step. Direct checkout-install steps in the enumerated workflows set the same variable themselves. It is not exported to unrelated workflow steps or changed for tarball smoke tests.++The Dockerfile checkout install already uses `--ignore-scripts`, then builds only the SQLite native dependency; that path does not execute the ONNX install script.++This policy does not force an environment variable on people installing the published package, on remote deployment commands, or inside a separate container. The checkout `.npmrc` is also not a configuration mechanism for those consumers. Those installation paths have their own contracts. The regression tests exercise the ONNX flag parser and a local npm lifecycle without downloading CUDA, installing the application or claiming to reproduce a startup crash.diff --git a/.github/actions/npm-ci-retry/action.yml b/.github/actions/npm-ci-retry/action.ymlindex b83a76bcfd..268612a669 100644--- a/.github/actions/npm-ci-retry/action.yml+++ b/.github/actions/npm-ci-retry/action.yml@@ -35,11 +35,13 @@ runs:uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0with:path: node_modules- key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ steps.node.outputs.version }}-${{ hashFiles('package-lock.json', '.npmrc', 'scripts/build/postinstall.mjs', 'scripts/build/postinstallSupport.mjs', 'scripts/build/colocateOptionals.mjs', 'scripts/build/wreqJsNative.mjs', 'scripts/build/fixPlaywrightAndroid.mjs', 'scripts/build/native-binary-compat.mjs', 'scripts/build/betterSqlitePrebuildTarget.mjs') }}+ key: node-modules-${{ runner.os }}-${{ runner.arch }}-${{ steps.node.outputs.version }}-${{ hashFiles('package-lock.json', '.npmrc', 'scripts/build/postinstall.mjs', 'scripts/build/postinstallSupport.mjs', 'scripts/build/colocateOptionals.mjs', 'scripts/build/wreqJsNative.mjs', 'scripts/build/fixPlaywrightAndroid.mjs', 'scripts/build/native-binary-compat.mjs', 'scripts/build/betterSqlitePrebuildTarget.mjs', '.github/actions/npm-ci-retry/action.yml') }}- name: npm ci (with retry)if: steps.node-modules.outputs.cache-hit != 'true'shell: bash+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"run: |set -euo pipefaildiff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 47fd7b807d..3b0a95b7fb 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -43,6 +43,8 @@ jobs:- name: Install dependenciesrun: npm ci+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"- name: Build Next.js app & CLI bundlerun: |diff --git a/.github/workflows/electron-release.yml b/.github/workflows/electron-release.ymlindex 2a1a2734f7..79b04610ed 100644--- a/.github/workflows/electron-release.yml+++ b/.github/workflows/electron-release.yml@@ -93,6 +93,7 @@ jobs:- name: Install dependenciesrun: npm cienv:+ ONNXRUNTIME_NODE_INSTALL: "skip"NPM_CONFIG_LEGACY_PEER_DEPS: true- name: Build Next.js standalone@@ -179,6 +180,7 @@ jobs:- name: Install dependenciesrun: npm cienv:+ ONNXRUNTIME_NODE_INSTALL: "skip"NPM_CONFIG_LEGACY_PEER_DEPS: true# The Linux leg produces x64 + arm64 installers from one x64 runner. npmdiff --git a/.github/workflows/mutation-redundancy.yml b/.github/workflows/mutation-redundancy.ymlindex 0960846c5f..a0ec381007 100644--- a/.github/workflows/mutation-redundancy.yml+++ b/.github/workflows/mutation-redundancy.yml@@ -49,6 +49,8 @@ jobs:node-version: "24"cache: npm- run: npm ci+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"- name: Run Stryker (disableBail)env:BATCH_MUTATE: ${{ matrix.batch.mutate }}diff --git a/.github/workflows/nightly-llm-security.yml b/.github/workflows/nightly-llm-security.ymlindex e0631f4f04..047a4443fd 100644--- a/.github/workflows/nightly-llm-security.yml+++ b/.github/workflows/nightly-llm-security.yml@@ -21,6 +21,8 @@ jobs:- uses: actions/setup-node@v7with: { node-version: "24", cache: npm }- run: npm ci+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"- name: Build CLI bundleenv:JWT_SECRET: ci-build-secret-with-sufficient-length-for-validation@@ -85,6 +87,8 @@ jobs:if: steps.gate.outputs.run == 'true'with: { node-version: "24", cache: npm }- run: npm ci+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"if: steps.gate.outputs.run == 'true'- name: Build CLI bundleif: steps.gate.outputs.run == 'true'diff --git a/.github/workflows/nightly-mutation.yml b/.github/workflows/nightly-mutation.ymlindex 9ffb5c22b5..d53bab6a37 100644--- a/.github/workflows/nightly-mutation.yml+++ b/.github/workflows/nightly-mutation.yml@@ -112,6 +112,8 @@ jobs:node-version: "24"cache: npm- run: npm ci+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"- name: Restore Stryker incremental cacheuses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0with:diff --git a/.github/workflows/nightly-property.yml b/.github/workflows/nightly-property.ymlindex 2ef7a543af..3a686ea4e6 100644--- a/.github/workflows/nightly-property.yml+++ b/.github/workflows/nightly-property.yml@@ -18,6 +18,8 @@ jobs:node-version: "24"cache: npm- run: npm ci+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"- name: fast-check random seed (high runs)id: proprun: FC_SEED=random FC_NUM_RUNS=2000 npm run test:propertydiff --git a/.github/workflows/nightly-resilience.yml b/.github/workflows/nightly-resilience.ymlindex 0961791828..519a297337 100644--- a/.github/workflows/nightly-resilience.yml+++ b/.github/workflows/nightly-resilience.yml@@ -20,6 +20,8 @@ jobs:node-version: "24"cache: npm- run: npm ci+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"- run: npm run test:heapchaos:@@ -34,6 +36,8 @@ jobs:node-version: "24"cache: npm- run: npm ci+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"- run: npm run test:chaosk6-soak:@@ -48,6 +52,8 @@ jobs:node-version: "24"cache: npm- run: npm ci+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"- name: Build CLI bundleenv:JWT_SECRET: ci-build-secret-with-sufficient-length-for-validation@@ -117,6 +123,8 @@ jobs:node-version: "24"cache: npm- run: npm ci+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"- name: Cache Playwright browsersuses: actions/[email protected]with:diff --git a/.github/workflows/nightly-schemathesis.yml b/.github/workflows/nightly-schemathesis.ymlindex 33ec974698..01ccaa900e 100644--- a/.github/workflows/nightly-schemathesis.yml+++ b/.github/workflows/nightly-schemathesis.yml@@ -22,6 +22,8 @@ jobs:- uses: actions/setup-node@v7with: { node-version: "24", cache: npm }- run: npm ci+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"- name: Build CLI bundleenv:JWT_SECRET: ci-build-secret-with-sufficient-length-for-validationdiff --git a/.github/workflows/radar-export.yml b/.github/workflows/radar-export.ymlindex 18f29e4d60..7051866a15 100644--- a/.github/workflows/radar-export.yml+++ b/.github/workflows/radar-export.yml@@ -51,6 +51,8 @@ jobs:node-version: ${{ env.CI_NODE_VERSION }}cache: npm- run: npm ci+ env:+ ONNXRUNTIME_NODE_INSTALL: "skip"- name: Generate catalog export with provenancerun: node --import tsx/esm scripts/release/radar-export.mjs "$RUNNER_TEMP/export-omniroute.json"- name: Publish to the stable release assetdiff --git a/changelog.d/features/16225-onnx-install-env.md b/changelog.d/features/16225-onnx-install-env.mdnew file mode 100644index 0000000000..893c4c4c49--- /dev/null+++ b/changelog.d/features/16225-onnx-install-env.md@@ -0,0 +1 @@+- Set `ONNXRUNTIME_NODE_INSTALL=skip` explicitly for the shared dependency-install action and direct checkout install steps, include the action policy in the dependency cache identity, and document local shell usage. The legacy `.npmrc` key remains for compatibility; published-package consumer installs are outside this checkout policy.diff --git a/tests/unit/onnx-install-env-16225.test.ts b/tests/unit/onnx-install-env-16225.test.tsnew file mode 100644index 0000000000..71a00c75ce--- /dev/null+++ b/tests/unit/onnx-install-env-16225.test.ts@@ -0,0 +1,332 @@+import assert from "node:assert/strict";+import { spawnSync } from "node:child_process";+import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { delimiter, dirname, join } from "node:path";+import test from "node:test";+import { fileURLToPath } from "node:url";+import { parse } from "yaml";++const root = fileURLToPath(new URL("../../", import.meta.url));+const parserPath = join(root, "node_modules/onnxruntime-node/script/install-utils.js");+const action = parse(+ readFileSync(join(root, ".github/actions/npm-ci-retry/action.yml"), "utf8")+) as { runs: { steps: Array<{ name?: string; env?: Record<string, string>; run?: string }> } };++type Observation = { value: boolean | null; isUndefined: boolean };++const checkedNpm = new Set<string>();++function npmCommand(env: NodeJS.ProcessEnv) {+ const cli = env.npm_execpath;+ if (cli) assert.ok(existsSync(cli), "npm_execpath must point to an existing npm CLI");+ const command = cli ? process.execPath : process.platform === "win32" ? "cmd.exe" : "npm";+ const prefix = cli ? [cli] : process.platform === "win32" ? ["/d", "/s", "/c", "npm"] : [];+ const identity = JSON.stringify([command, prefix]);+ if (!checkedNpm.has(identity)) {+ const version = spawnSync(command, [...prefix, "--version"], {+ env,+ encoding: "utf8",+ timeout: 15_000,+ });+ assert.equal(version.error, undefined, "npm must be available through npm_execpath or PATH");+ assert.equal(version.status, 0, version.stderr);+ // config/ci/toolchain.json exists on the release branch and not on main.+ // When it is present, the probe must use that pin. main still runs the parser.+ const toolchainFile = join(root, "config/ci/toolchain.json");+ if (existsSync(toolchainFile)) {+ const expected = JSON.parse(readFileSync(toolchainFile, "utf8")).npm;+ assert.equal(version.stdout.trim(), expected, `use the repository's pinned npm ${expected}`);+ }+ checkedNpm.add(identity);+ }+ return { command, prefix };+}++function writeActionBoundary(dir: string, shell: string) {+ writeFileSync(+ join(dir, "action.sh"),+ `+npm() {+ test "$1" = "ci" || return 97+ if [ -n "$ONNX_FIXTURE_NPM" ]; then+ "$ONNX_FIXTURE_NODE" "$ONNX_FIXTURE_NPM" run postinstall --offline --ignore-scripts=false --no-audit --no-fund+ else+ command npm run postinstall --offline --ignore-scripts=false --no-audit --no-fund+ fi+}+sleep() { return 98; }+` + shell+ );+}++function parserProbe(+ extraEnv: Record<string, string>,+ lifecycle: boolean | string = false+): Observation {+ const dir = mkdtempSync(join(tmpdir(), "onnx-env-16225-"));+ try {+ const output = join(dir, "observation.json");+ writeFileSync(+ join(dir, "parser-probe.cjs"),+ `const { parseInstallFlag } = require(process.env.ONNX_FIXTURE_PARSER);+require("node:assert/strict").equal(process.execPath, process.env.ONNX_FIXTURE_NODE);+const value = parseInstallFlag();+require("node:fs").writeFileSync(process.env.ONNX_FIXTURE_OUTPUT,+ JSON.stringify({ value: value ?? null, isUndefined: value === undefined }));+`+ );+ writeFileSync(+ join(dir, "package.json"),+ JSON.stringify({+ name: "onnx-env-local-fixture",+ private: true,+ scripts: { postinstall: "node parser-probe.cjs" },+ })+ );+ const env = { ...process.env };+ for (const key of Object.keys(env)) {+ if (key.toLowerCase().includes("onnxruntime")) delete env[key];+ }+ Object.assign(env, extraEnv, {+ ONNX_FIXTURE_PARSER: parserPath,+ ONNX_FIXTURE_OUTPUT: output,+ ONNX_FIXTURE_NODE: process.execPath,+ PATH: dirname(process.execPath) + delimiter + (env.PATH ?? ""),+ });+ const npm = lifecycle ? npmCommand(env) : undefined;+ const args = npm+ ? [+ ...npm.prefix,+ "run",+ "postinstall",+ "--offline",+ "--ignore-scripts=false",+ "--no-audit",+ "--no-fund",+ ]+ : [join(dir, "parser-probe.cjs")];+ if (typeof lifecycle === "string") {+ writeActionBoundary(dir, lifecycle);+ env.ONNX_FIXTURE_NPM = env.npm_execpath ?? "";+ }+ const result = spawnSync(+ typeof lifecycle === "string" ? "bash" : (npm?.command ?? process.execPath),+ typeof lifecycle === "string" ? ["--noprofile", "--norc", join(dir, "action.sh")] : args,+ {+ cwd: dir,+ env,+ encoding: "utf8",+ timeout: 15_000,+ }+ );+ assert.equal(result.error, undefined);+ assert.equal(result.status, 0, result.stderr);+ return JSON.parse(readFileSync(output, "utf8")) as Observation;+ } finally {+ rmSync(dir, { recursive: true, force: true });+ }+}++for (const fixture of [+ {+ name: "explicit skip without npm custom config",+ env: { ONNXRUNTIME_NODE_INSTALL: "skip" },+ value: false,+ },+ { name: "unset flags retain the upstream default", env: {}, value: undefined },+ {+ name: "legacy custom config still skips",+ env: { npm_config_onnxruntime_node_install: "skip" },+ value: false,+ },+ {+ name: "explicit skip precedes custom true",+ env: { ONNXRUNTIME_NODE_INSTALL: "skip", npm_config_onnxruntime_node_install: "true" },+ value: false,+ },+ {+ name: "explicit true precedes custom skip",+ env: { ONNXRUNTIME_NODE_INSTALL: "true", npm_config_onnxruntime_node_install: "skip" },+ value: true,+ },+]) {+ test(`ONNX parser: ${fixture.name}`, () => {+ assert.deepEqual(parserProbe(fixture.env), {+ value: fixture.value ?? null,+ isUndefined: fixture.value === undefined,+ });+ });+}++test("npm lifecycle receives an explicit caller flag without a project npmrc", () => {+ assert.deepEqual(parserProbe({ ONNXRUNTIME_NODE_INSTALL: "skip" }, true), {+ value: false,+ isUndefined: false,+ });+});++test("the composite npm ci environment skips ONNX without npm custom config delivery", () => {+ const install = action.runs.steps.find((step) => step.name === "npm ci (with retry)");+ assert.ok(install, "the actual installation step must exist");+ assert.deepEqual(parserProbe(install.env ?? {}, true), {+ value: false,+ isUndefined: false,+ });+});++type InstallStep = {+ run?: string;+ env?: Record<string, string>;+ "working-directory"?: string;+};+type Workflow = {+ env?: Record<string, string>;+ defaults?: { run?: { "working-directory"?: string } };+ jobs: Record<+ string,+ {+ env?: Record<string, string>;+ defaults?: { run?: { "working-directory"?: string } };+ steps: InstallStep[];+ }+ >;+};++const directRootInstalls = [+ ["build", "build"],+ ["electron-release", "web-build"],+ ["electron-release", "build"],+ ["mutation-redundancy", "stryker-nobail"],+ ["nightly-llm-security", "promptfoo-guard"],+ ["nightly-llm-security", "garak"],+ ["nightly-mutation", "stryker"],+ ["nightly-property", "property-random-seed"],+ ["nightly-resilience", "heap"],+ ["nightly-resilience", "chaos"],+ ["nightly-resilience", "k6-soak"],+ ["nightly-resilience", "a11y"],+ ["nightly-schemathesis", "schemathesis"],+ ["radar-export", "publish-export"],+] as const;++function installEnvironment(workflow: Workflow, jobName: string, step: InstallStep) {+ const job = workflow.jobs[jobName];+ const cwd =+ step["working-directory"] ??+ job.defaults?.run?.["working-directory"] ??+ workflow.defaults?.run?.["working-directory"] ??+ ".";+ assert.equal(cwd, ".", "the recorded entrypoint must install the checkout root");+ return { ...workflow.env, ...job.env, ...step.env };+}++for (const [workflowName, jobName] of directRootInstalls) {+ test(`root install ${workflowName}/${jobName} delivers skip to npm lifecycle`, () => {+ const workflow = parse(+ readFileSync(join(root, ".github/workflows", `${workflowName}.yml`), "utf8")+ ) as Workflow;+ const step = workflow.jobs[jobName].steps.find((entry) => entry.run?.trim() === "npm ci");+ assert.ok(step, "the audited npm ci root entrypoint must exist");+ const effective = installEnvironment(workflow, jobName, step);+ // Only the installation flag crosses this boundary: GitHub expressions and+ // secrets from unrelated job environment are not needed by this local probe.+ const flag = effective.ONNXRUNTIME_NODE_INSTALL;+ assert.deepEqual(+ parserProbe(flag === undefined ? {} : { ONNXRUNTIME_NODE_INSTALL: flag }, true),+ {+ value: false,+ isUndefined: false,+ }+ );+ });+}++test("the action source participates in the exact dependency cache identity", () => {+ const parsed = parse(+ readFileSync(join(root, ".github/actions/npm-ci-retry/action.yml"), "utf8")+ ) as {+ runs: { steps: Array<{ id?: string; with?: Record<string, string> }> };+ };+ const cache = parsed.runs.steps.find((step) => step.id === "node-modules");+ assert.ok(cache?.with);+ assert.ok(cache.with.key.includes("'.github/actions/npm-ci-retry/action.yml'"));+ assert.equal(cache.with["restore-keys"], undefined);+});++test("legacy npmrc compatibility remains while explicit caller delivery is added", () => {+ const lines = readFileSync(join(root, ".npmrc"), "utf8").split("\n");+ assert.ok(lines.includes("onnxruntime-node-install=skip"));+});++test("comments and environment on another step cannot supply the install flag", () => {+ const workflow = parse(`+# ONNXRUNTIME_NODE_INSTALL: skip+jobs:+ build:+ steps:+ - run: npm ci+ - run: echo finished+ env:+ ONNXRUNTIME_NODE_INSTALL: skip+`) as Workflow;+ assert.equal(+ installEnvironment(workflow, "build", workflow.jobs.build.steps[0]).ONNXRUNTIME_NODE_INSTALL,+ undefined+ );+});++test("step environment overrides job and workflow installation defaults", () => {+ const workflow: Workflow = {+ env: { ONNXRUNTIME_NODE_INSTALL: "skip" },+ jobs: { build: { env: { ONNXRUNTIME_NODE_INSTALL: "skip" }, steps: [] } },+ };+ const effective = installEnvironment(workflow, "build", {+ run: "npm ci",+ env: { ONNXRUNTIME_NODE_INSTALL: "true" },+ });+ assert.equal(parserProbe(effective).value, true);+});++test(+ "the actual composite shell carries its step environment into npm lifecycle",+ { skip: process.platform === "win32" && "composite Bash contract runs on the Linux runner" },+ () => {+ const install = action.runs.steps.find((step) => step.name === "npm ci (with retry)");+ assert.ok(install?.run);+ assert.deepEqual(parserProbe(install.env ?? {}, install.run), {+ value: false,+ isUndefined: false,+ });+ }+);++test("direct install flags do not become workflow or job defaults for downstream consumers", () => {+ for (const [workflowName, jobName] of directRootInstalls) {+ const workflow = parse(+ readFileSync(join(root, ".github/workflows", `${workflowName}.yml`), "utf8")+ ) as Workflow;+ assert.equal(workflow.env?.ONNXRUNTIME_NODE_INSTALL, undefined);+ assert.equal(workflow.jobs[jobName].env?.ONNXRUNTIME_NODE_INSTALL, undefined);+ for (const step of workflow.jobs[jobName].steps) {+ if (step.run?.trim() !== "npm ci")+ assert.equal(step.env?.ONNXRUNTIME_NODE_INSTALL, undefined);+ }+ }+});++test("only the composite installation step receives the explicit flag", () => {+ for (const step of action.runs.steps) {+ if (step.name !== "npm ci (with retry)")+ assert.equal(step.env?.ONNXRUNTIME_NODE_INSTALL, undefined);+ }+});++test("the excluded Docker checkout install explicitly disables lifecycle scripts", () => {+ const dockerfile = readFileSync(join(root, "Dockerfile"), "utf8");+ const command = dockerfile+ .split("\n")+ .find((line) => line.trim().startsWith("npm ci --include=optional"));+ assert.ok(command, "the audited checkout installation must remain identifiable");+ assert.ok(command.split(/\s+/).includes("--ignore-scripts"));+});