Skip to content

ci: enforce npm ci on Studio install paths (follow-up to #5604) - #5616

Merged
danielhanchen merged 8 commits into
mainfrom
ci/npm-ci-followup-5604
Sep 29, 2026
Merged

danielhanchen merged 8 commits into
mainfrom
ci/npm-ci-followup-5604

Conversation

@danielhanchen

@danielhanchen danielhanchen commented May 19, 2026 •

Copy link
Copy Markdown
Member

Summary

Follow-up to #5604. The three Studio lockfiles (studio/frontend, studio/backend/core/data_recipe/oxc-validator, studio) are committed and audited, but the installers and two desktop workflows still ran npm install, which rewrites the lockfile when package.json drifts and installs whatever the drift asks for. This switches those paths to npm ci, which installs exactly the audited lockfile or fails.

Rebased onto current main by merge (main had rewritten every touched file since May); #5695 already moved the lockfile audit ahead of the installs, so that part is dropped here.

Changes

  • studio/setup.sh, studio/setup.ps1, build.sh: frontend and OXC validator installs use npm ci when package-lock.json is present, npm install only when it is absent (same rule as docker/unsloth_studio_update.sh). The npmmirror fallback retry uses the same verb.
  • A package-lock.json always decides the install. bun runs only when there is none and a bun.lock exists (--frozen-lockfile): bun.lock is gitignored and earlier bun installs left one behind, so it must not outrank the audited npm lockfile. On a drifted package.json, bun install (1.4.2 tested) installs the extra dependency and writes a new bun.lock, like npm install.
  • release-desktop.yml, studio-tauri-smoke.yml, desktop-app-clean-machine-ci.yml: Tauri CLI via npm ci --prefix studio (the studio/package.json lockfile holder exists for exactly this) instead of npm install --save-dev [email protected]; release frontend via npm ci.
  • security-audit.yml: npm audit, OSV scanner, npm audit signatures and the new-install-script diff now also cover the oxc-validator and Tauri CLI lockfiles.
  • wheel-smoke.yml: asserts the oxc-validator package-lock.json ships in the wheel (the installers run npm ci against it in site-packages).
  • Tests: tests/studio/test_installers_npm_ci.py (3 of 4 fail on main), plus a mirror-retry case in tests/sh/test_mirror_fallback.sh.

Verification

  • npm ci on all three lockfiles at this head: succeeds, lockfiles byte-identical afterwards, tauri-cli 2.10.1, oxc native bindings present.
  • Drifted package.json (extra dependency): npm install exits 0, rewrites the lockfile and installs the extra package; npm ci exits 1 with EUSAGE and installs nothing.
  • tests/security, tests/studio, tests/python, tests/test_*.py on main vs this head: no head-only failures (the 18 failures on both sides are environment-related).
  • tests/sh/test_mirror_fallback.sh 253/253, tests/sh/test_system_node_readonly.sh pass.

Behaviour note: npm ci removes an existing node_modules before installing, so re-running setup reinstalls the frontend and validator dependencies from scratch instead of reusing them.

PR #5604 committed three npm lockfiles (studio/, studio/frontend/,
studio/backend/core/data_recipe/oxc-validator/) but the install
paths still ran `npm install` -- mutates the lockfile, ignores
integrity hashes. Flip them to `npm ci`, which is non-mutating
and refuses to run unless the committed package-lock.json matches
the dependency tree byte-for-byte. This closes the gap between
"the lockfile passes the audit" and "the install respected that
lockfile".

For bun: gate every `bun install` on `[ -f bun.lock ]` (Test-Path
on Windows) plus `command -v bun` (Get-Command), and add
`--frozen-lockfile --no-progress` to the bun invocation. No
bun.lock is committed in this PR, so the gate fails closed today
and execution falls through to `npm ci`. When the eventual
bun.lock PR lands, the gate auto-activates with no further
script edits.

Existing bun infrastructure (cache-corruption retry +
critical-binary verification + npm fallback) is kept intact so
the auto-upgrade is clean. Deliberately NOT introducing
_BUN_PIN_VERSION or the 3-attempt cache-corruption recovery
ladder; both require committed bun.lock to be useful.

Touches three files only:
- build.sh
- studio/setup.sh
- studio/setup.ps1
Point the existing audit + install + content-sanity workflows at
the two lockfiles PR #5604 introduced (studio/package-lock.json
and studio/backend/core/data_recipe/oxc-validator/package-lock.json)
so the Studio Tauri CLI holder and the oxc-validator runtime
benefit from the same per-PR coverage the frontend already has.

release-desktop.yml:
  - Tauri CLI install: `npm install --save-dev --prefix studio` ->
    `npm ci --prefix studio --no-fund --no-audit`.
  - Frontend install: `npm install --no-fund --no-audit` ->
    `npm ci --no-fund --no-audit`.
  - New "Lockfile supply-chain audit" step inserted BEFORE the
    Tauri CLI install so the structural audit fires before any
    tarball-side lifecycle script.

studio-tauri-smoke.yml:
  - Tauri CLI install: `npm install --save-dev --prefix studio` ->
    `npm ci --prefix studio --no-fund --no-audit`.
  - Existing audit step relocated to run BEFORE the Tauri CLI
    install (same ordering rationale).

wheel-smoke.yml:
  - One-line content-sanity assertion ensuring the oxc-validator
    package-lock.json is shipped in the wheel.

security-audit.yml:
  - `paths` trigger gains the 4 new entries (oxc + Tauri CLI
    holder package.json + package-lock.json).
  - `Scanned:` summary string updated to list the two new
    lockfiles.
  - OSV-scanner picks up `--lockfile=` for both.
  - Two new `npm audit` steps: oxc-validator runtime + Studio
    Tauri CLI holder.
  - `npm audit signatures` block split into three (frontend / oxc
    / Tauri CLI), each preceded by `npm ci --ignore-scripts` in
    its own directory.
  - `check_new_install_scripts.py` invocation extended to diff
    both new lockfiles base->head, with `git show ... 2>/dev/null
    || echo '{}'` fallback for PRs whose base predates #5604.
  - `upload-artifact` paths extended for the new log files.

Deliberately NOT included: removing `continue-on-error` from the
existing `scan_npm_packages` job. That is a policy flip from
advisory to blocking and is orthogonal to install-path hardening.
gemini-code-assist[bot]

This comment was marked as outdated.

…t install paths

main rewrote every file this PR touched. Kept main's side and re-derived the change:
- setup.sh, setup.ps1, build.sh: npm ci when package-lock.json exists (npm install
  only as the no-lockfile fallback, as docker/unsloth_studio_update.sh does), including
  the npmmirror retry; bun only with a committed bun.lock, --frozen-lockfile.
- release-desktop, studio-tauri-smoke, desktop-app-clean-machine-ci: Tauri CLI via
  npm ci --prefix studio instead of npm install --save-dev; release frontend via npm ci.
- security-audit: npm audit, OSV, audit signatures and install-script diff cover the
  oxc-validator and Tauri CLI lockfiles.
- wheel-smoke asserts the oxc-validator lockfile ships.
- tests/studio/test_installers_npm_ci.py, mirror retry case for npm ci.
bun.lock is gitignored and earlier bun installs wrote one, so gating bun on its
existence picked bun --frozen-lockfile over an old graph instead of npm ci.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex security review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-09-29T14:01:42.670535Z ee306ba Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a006dff3f9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/setup.sh
if command -v bun &>/dev/null; then
_NPM_INSTALL=install
[ -f package-lock.json ] && _NPM_INSTALL=ci
if [ ! -f package-lock.json ] && [ -f bun.lock ] && command -v bun &>/dev/null; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Gate Bun provisioning before forcing npm ci

When a local/source install needs a frontend rebuild and selects bundled Node, the earlier block still runs npm install -g bun --allow-scripts=bun; with the committed package-lock.json, this new condition is always false, so setup immediately uses npm ci instead. This makes every first such setup download and execute Bun's postinstall without ever using Bun, adding avoidable latency and network-failure exposure. Apply the same lockfile/Bun-lock condition to Bun provisioning, including the analogous block in setup.ps1.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 238efa3: setup.sh and setup.ps1 skip the global bun install when frontend/package-lock.json exists, since the frontend then installs with npm ci.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Sep 29, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 238efa3786

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen marked this pull request as ready for review September 29, 2026 14:01
@danielhanchen
danielhanchen merged commit fbccb93 into main Sep 29, 2026
99 of 101 checks passed
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for security reviews. Please try again later.

@danielhanchen
danielhanchen deleted the ci/npm-ci-followup-5604 branch September 29, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant