Skip to content

ci: Type-check SDK breaking changes without secrets - #24216

Merged
coroiu merged 1 commit into
mainfrom
ci/sdk-breaking-change-check-isolate
Oct 28, 2026
Merged

coroiu merged 1 commit into
mainfrom
ci/sdk-breaking-change-check-isolate

Conversation

@coroiu

@coroiu coroiu commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR: The SDK breaking-change check runs code from the SDK package it checks, in a job that can log in to Azure. This PR moves the type check to a job without secrets or an OIDC token, and links the package without running anything from it.

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-46497

Follow-up to bitwarden/sdk-internal#1685, which lets fork PRs in sdk-internal run this check again after a maintainer approves the commit and adds a label. Related: BRE-2229 (cleaning up workflows that handle fork code).

📔 Objective

The problem

sdk-breaking-change-check.yml downloads the sdk-internal package from an sdk-internal run and runs npm link ./sdk-internal. npm link <folder> runs the package's preinstall, install, postinstall and prepare scripts. I confirmed this locally with npm 11.12.1.

Whoever builds the package controls its package.json. On sdk-internal main, only PRs from branches in the repo trigger this check, so only people with write access. With bitwarden/sdk-internal#1685, an approved fork PR can trigger it too. In a fork pull_request run, GitHub uses the fork's copy of the build workflow, so the fork decides what goes into the artifact.

The script would run in the same job that:

  • has id-token: write, so it can request an OIDC token and log in to Azure as this workflow's identity, the same login the job uses to read gh-org-bitwarden
  • has already fetched BW-GHAPP-KEY into runner memory

The fix

The workflow now has two jobs:

Job Has Handles the package by
download-sdk OIDC, the App token Downloading it from sdk-internal and uploading it again as an artifact of this run
type-check contents: read only Downloading it from this run, npm link --ignore-scripts --no-bin-links, tsc

The workflow-level permissions are {}, so each job only gets what it lists.

Both flags are needed. --ignore-scripts stops the lifecycle scripts. It still links the package's bin entries, though, and setup-node puts that directory first on PATH. A package with a date or timeout entry would then run in place of the commands the next step calls. --no-bin-links stops that. I verified both behaviors locally. The sdk-internal package has no scripts and no bin entries, so neither flag changes anything for real packages.

The split keeps secrets and the OIDC token out of the job that handles the package. If there is a path I missed, it has nothing to reach.

The sdk-internal side watches the whole run (gh run watch --exit-status), not a job name, so the split doesn't affect how the result is reported back.

Cost

About half a minute to a minute per check, from the extra job and the second runner. In the last 5 runs the check took about 4 minutes. npm ci and tsc are most of it, and the artifact download took 2 to 3 seconds. This is an estimate, not measured.

Testing

Not run in CI yet, since workflow_dispatch runs the workflow from the branch it's dispatched on. It can be tested by dispatching it on this branch with the inputs from a recent run.

🤖 AI-assisted review

  • Multi-agent review (architecture, code quality, bug analysis, security). The security agent found that --ignore-scripts alone still links bin entries that can shadow commands on PATH. The severity audit dismissed it, since the old setup was worse. It is fixed anyway with --no-bin-links, because the point of this change is that nothing from the package runs in the type-check job.

The SDK package can be built from a fork pull request. npm link runs the
package's lifecycle scripts and links its bin entries, and the job also had
an OIDC token and the GitHub App key. Download the package in a separate
job, type-check it in a job without secrets or id-token, and link it with
--ignore-scripts --no-bin-links.
@coroiu coroiu added the ai-review Request a Claude code review label Oct 28, 2026
@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🤖 Bitwarden Claude Code Review

Overall Assessment: APPROVE

This PR splits .github/workflows/sdk-breaking-change-check.yml into two jobs. download-sdk holds the OIDC token and the GitHub App token, and re-uploads the SDK as an artifact of this run. type-check runs with contents: read only and links the package with npm link --ignore-scripts --no-bin-links. Workflow-level permissions are now {}. Artifact upload and download within the same run use the runner's runtime token, so dropping actions: read is safe. npm run test:types (scripts/test-types.js) only runs tsc and typescript-strict-plugin from the repo's own node_modules, so nothing from the linked package runs.

@codecov

codecov Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.28%. Comparing base (2ff1c29) to head (d23a86f).
⚠️ Report is 6 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24216      +/-   ##
==========================================
- Coverage   60.29%   60.28%   -0.01%     
==========================================
  Files        4796     4796              
  Lines      152614   152620       +6     
  Branches    24360    24360              
==========================================
- Hits        92015    92014       -1     
- Misses      54272    54278       +6     
- Partials     6327     6328       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@coroiu
coroiu marked this pull request as ready for review October 28, 2026 15:03
@coroiu coroiu added the t:ci Change Type - Updates to automated workflows label Oct 28, 2026
@coroiu
coroiu merged commit 0e55460 into main Oct 28, 2026
58 of 63 checks passed
@coroiu
coroiu deleted the ci/sdk-breaking-change-check-isolate branch October 28, 2026 15:46
@djsmith85 djsmith85 added browser Browser Extension desktop Desktop Application cli CLI Application web labels Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-review Request a Claude code review browser Browser Extension cli CLI Application desktop Desktop Application t:ci Change Type - Updates to automated workflows web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants