ReviewOS

also looking at this

pantry-pm/pantry

fix(installer): resolve versions against live sources when one is unreachable

#255
Merged glennmichael123 wants to merge fix/242-version-source-fallback into main
6 files +400 -44
packages/action/src/index.tsmodified+16-0
Changes to packages/action/src/index.ts
@@ -332,6 +332,10 @@ async function installSystemPackages(
332332 const installed = await installResolvedSystemPackages(requests, {
333333 installDir: pantryDir,
334334 onRetry: message => core.warning(message),
335 // `quiet` silences progress, not this: a pin that resolved off a stale
336 // bundled catalog because a version source was unreachable installs an
337 // older version than upstream has, and CI is where that happens.
338 onWarn: message => core.warning(message),
335339 nativeInstall: packageSpecs => exec.exec(pantryExecutable, ['install', ...packageSpecs, '--no-save'], {
336340 cwd: path.dirname(pantryDir),
337341 env: { ...process.env, CI: 'true', NO_COLOR: '1' } as { [key: string]: string },
@@ -662,6 +666,18 @@ export async function run(): Promise<void> {
662666 }
663667 else core.warning('GitHub build dependency archive cache unavailable; local caching remains enabled')
664668 }
669
670 // Authenticate the SDK's upstream version lookups before anything resolves
671 // a version. Unauthenticated api.github.com is 60 req/hr per IP and runner
672 // pools share egress addresses, so a 403 here is routine — and a failed
673 // lookup is what made a published `bun.sh: ^1.4.1` report as having no
674 // satisfying version. `github.token` is the input's default, so this is on
675 // by default; passing `github-token: ''` opts out. Kept in-process rather
676 // than exported, so it reaches the lookups without widening the job env.
677 const githubToken = core.getInput('github-token')
678 if (githubToken && !process.env.PANTRY_GITHUB_TOKEN)
679 process.env.PANTRY_GITHUB_TOKEN = githubToken
680
665681 const inputs: ActionInputs = {
666682 nativeApp: (core.getInput('native-app') || undefined) as ActionInputs['nativeApp'],
667683 version: core.getInput('version') || 'latest',