[No QA] Upgrade @actions and @octokit dependencies to their ESM-only majors - #98701
Draft
roryabraham wants to merge 1 commit into
Draft
[No QA] Upgrade @actions and @octokit dependencies to their ESM-only majors#98701roryabraham wants to merge 1 commit into
roryabraham wants to merge 1 commit into
Conversation
…majors @actions/core v3 and @actions/github v9 publish only an `import` condition in their exports map. ncc emits CommonJS, so webpack resolved them with `require` only and every action failed to build with "Package path . is not exported". Patch ncc to also accept `import` for CommonJS dependencies, keeping `require` first so dual-published packages (e.g. svgo) still resolve to their CJS entry. Upgrade the @octokit/* plugin chain to the versions @actions/github v9 bundles and fix the breaking changes that surfaced: - @octokit/plugin-throttling renamed `onAbuseLimit` to `onSecondaryRateLimit` and moved `retryCount` to its own handler argument. - @octokit/plugin-rest-endpoint-methods no longer exports `RestEndpointMethods` or its `dist-types/*` paths, and @actions/github dropped `./lib/interfaces`. - @octokit/core and the plugins resolve to different @octokit/openapi-types versions that disagree on some schema fields, so GithubUtils now derives its payload types from the endpoint methods that return them rather than from @octokit/openapi-types directly. - @octokit/plugin-rest-endpoint-methods now builds each REST scope as a Proxy, which jest.spyOn cannot intercept under bun:test, so tests silently called the real GitHub API. Materialize the scopes into plain objects first. - @octokit/request now reads a JSON body with `text()` instead of `json()`. Rebuild all 24 action bundles with ncc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Explanation of Change
This is PR 3 of the bottom-up ncc → esbuild migration plan. It upgrades
@actions/core,@actions/github, and the@octokit/*plugin chain to their current majors. The action bundles are still built withncc— swapping in esbuild and emitting ESM is PR 4.PRs 1 and 2 (moving scripts to Bun and tests to
bun:test) are already merged, so nothing does a runtimerequire()of these packages anymore.Dependency upgrades
@actions/core@actions/github@octokit/core@octokit/plugin-paginate-rest@octokit/plugin-rest-endpoint-methods@octokit/plugin-throttling@octokit/request-error@octokit/webhooks-typesThe
@octokit/*versions are the ones@actions/githubv9 itself bundles, so there is a single copy of each in the tree.@octokit/plugin-rest-endpoint-methodsbecomes an explicit dev dependency because we import types from it directly.A new ncc patch was needed
@actions/corev3 and@actions/githubv9 are ESM-only: theirexportsmaps publish animportcondition and nothing else. ncc emits CommonJS, so webpack resolves dependencies with therequirecondition only, and every action failed to build with:@vercel+ncc+0.38.1+003+esm-only-package-exports.patchappendsimportto webpack's CommonJS condition list.requirestays first, so dual-published packages are unaffected — verified by checking thatcheckSVGCompression's bundle still resolvessvgotodist/svgo-node.cjs(rather than its pure-ESM entry, which is what crashed under esbuild's CJS output and motivated PR 4's ESM switch).This patch is deleted again in PR 4, when ncc itself goes away.
Breaking changes fixed
@octokit/plugin-throttling:onAbuseLimitwas renamedonSecondaryRateLimit, andretryCountmoved fromoptions.request.retryCountto its own handler argument. Fixed inGithubUtils.tsandscripts/aggregateGitHubDataFromUpwork.ts.@octokit/plugin-rest-endpoint-methodsno longer exportsRestEndpointMethods, nor any of itsdist-types/*paths. It only exportsApi, soRestEndpointMethodsis now derived asApi['rest'].@actions/githubdropped./lib/interfacesfrom its exports map, soWebhookPayloadis derived fromtypeof github.context.payload.@octokit/openapi-typesversion skew:@octokit/coredepends on a newer copy than the plugins do, and the two disagree on some schema fields (e.g.issue.idisnumber | bigintin the newer one, because@octokit/requestnow decodes oversized integers asBigInt).GithubUtilsno longer imports@octokit/openapi-typesat all —OctokitIssueItem,OctokitCommit,OctokitArtifact, andOctokitPRare derived from the endpoint methods that return them, which pins them to the one copy the REST methods actually use.DeployChecklistUtilsnow importsOctokitIssueItemfromGithubUtilsinstead of redeclaring it.Two test-only breakages this surfaced
Both were silent failures worth calling out:
jest.spyOnno longer intercepts octokit REST methods.@octokit/plugin-rest-endpoint-methodsnow builds every scope (octokit.rest.issues,octokit.rest.pulls, …) as aProxythat materializes endpoint methods on first access, andjest.spyOnhas no effect through aProxyunderbun:test— the spy is installed, but reads still return the real method. The affected tests were quietly calling the real GitHub API (Bad credentials) instead of their mocks. Newtests/utils/materializeOctokitScopes.tsspreads each scope into an ordinary object first, after whichjest.spyOn/jest.restoreAllMocksbehave normally and no other test code had to change.@octokit/requestreads JSON bodies withtext()(then parses them itself, to supportBigInt) rather thanjson().postOrReplaceComment.test.tsstubsfetch, so its fakeResponseneeded atext().Rebuild
All 24 committed
index.jsaction bundles were rebuilt with ncc.Fixed Issues
$
PROPOSAL:
Tests
npm install(Node 26.5.0, per.nvmrc).npm run gh-actions-buildand confirm all 24 actions build without error../.github/scripts/verifyActions.shand confirm it reportsGithub Actions are up to date!.npm run test:bunand confirm all tests pass.npm run typecheckand./scripts/lint.sh .github/ tests/ scripts/and confirm both are clean.npx knipand confirm no new unused/unlisted dependencies are reported versusmain.node .github/actions/javascript/checkSVGCompression/index.jswith noGITHUB_TOKENset and confirm it fails withError: Input required and not supplied: GITHUB_TOKENrather than crashing — this proves the ESM-only@actions/corebundled correctly and thatsvgo/css-treestill resolve.node .github/actions/javascript/bumpVersion/index.jswith noSEMVER_LEVELset, confirm it fails withError: Input required and not supplied: SEMVER_LEVEL, and confirmgit statusshows no version files were changed.GITHUB_TOKEN=<a real token> node .github/actions/javascript/isDeployChecklistLocked/index.jsand confirm it prints the current StagingDeployCash issue and its labels — this exercises the upgraded Octokit chain against the real API end to end.rm -rf node_modules/@vercel/ncc && npm install --ignore-scripts && ./scripts/applyPatches.shand confirmpatch-package succeeded without errors or warnings, i.e. the new ncc patch applies to a pristine install.Note that several of these bundled actions run on this PR before merge, at least
isAuthorizedContributorandverifySignedCommits, andValidate GitHub Actionsruns the build step in CI.Offline tests
N/A - this PR only changes CI/build tooling and its dependencies, not app code.
QA Steps
N/A - this PR only changes internal CI/build tooling; there is no end-user-facing or staging/production behavior to QA.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
N/A - build tooling change only, no app UI affected.
Android: mWeb Chrome
N/A - build tooling change only, no app UI affected.
iOS: Native
N/A - build tooling change only, no app UI affected.
iOS: mWeb Safari
N/A - build tooling change only, no app UI affected.
MacOS: Chrome / Safari
N/A - build tooling change only, no app UI affected.