Repository navigation
ci: Type-check SDK breaking changes without secrets - #24216
Conversation
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.
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR splits |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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.ymldownloads thesdk-internalpackage from an sdk-internal run and runsnpm link ./sdk-internal.npm link <folder>runs the package'spreinstall,install,postinstallandpreparescripts. I confirmed this locally with npm 11.12.1.Whoever builds the package controls its
package.json. On sdk-internalmain, 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 forkpull_requestrun, 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:
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 readgh-org-bitwardenBW-GHAPP-KEYinto runner memoryThe fix
The workflow now has two jobs:
download-sdktype-checkcontents: readonlynpm link --ignore-scripts --no-bin-links,tscThe workflow-level permissions are
{}, so each job only gets what it lists.Both flags are needed.
--ignore-scriptsstops the lifecycle scripts. It still links the package'sbinentries, though, and setup-node puts that directory first onPATH. A package with adateortimeoutentry would then run in place of the commands the next step calls.--no-bin-linksstops that. I verified both behaviors locally. Thesdk-internalpackage has no scripts and nobinentries, 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 ciandtscare 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_dispatchruns 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
--ignore-scriptsalone still linksbinentries that can shadow commands onPATH. 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.