Skip to content

[No QA] Upgrade @actions and @octokit dependencies to their ESM-only majors - #98701

Draft
roryabraham wants to merge 1 commit into
mainfrom
rory/gh-actions-esm-deps
Draft

[No QA] Upgrade @actions and @octokit dependencies to their ESM-only majors#98701
roryabraham wants to merge 1 commit into
mainfrom
rory/gh-actions-esm-deps

Conversation

@roryabraham

Copy link
Copy Markdown
Contributor

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 with ncc — 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 runtime require() of these packages anymore.

Dependency upgrades

Package Before After
@actions/core 1.10.0 3.0.1
@actions/github 5.1.1 9.1.1
@octokit/core 4.0.4 ^7.0.6
@octokit/plugin-paginate-rest 3.1.0 ^14.0.0
@octokit/plugin-rest-endpoint-methods (transitive) ^17.0.0
@octokit/plugin-throttling 4.1.0 ^11.0.0
@octokit/request-error 3.0.3 ^7.1.0
@octokit/webhooks-types ^7.5.1 ^7.6.1

The @octokit/* versions are the ones @actions/github v9 itself bundles, so there is a single copy of each in the tree. @octokit/plugin-rest-endpoint-methods becomes an explicit dev dependency because we import types from it directly.

A new ncc patch was needed

@actions/core v3 and @actions/github v9 are ESM-only: their exports maps publish an import condition and nothing else. ncc emits CommonJS, so webpack resolves dependencies with the require condition only, and every action failed to build with:

Module not found: Error: Package path . is not exported from package @actions/core

@vercel+ncc+0.38.1+003+esm-only-package-exports.patch appends import to webpack's CommonJS condition list. require stays first, so dual-published packages are unaffected — verified by checking that checkSVGCompression's bundle still resolves svgo to dist/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: onAbuseLimit was renamed onSecondaryRateLimit, and retryCount moved from options.request.retryCount to its own handler argument. Fixed in GithubUtils.ts and scripts/aggregateGitHubDataFromUpwork.ts.
  • @octokit/plugin-rest-endpoint-methods no longer exports RestEndpointMethods, nor any of its dist-types/* paths. It only exports Api, so RestEndpointMethods is now derived as Api['rest'].
  • @actions/github dropped ./lib/interfaces from its exports map, so WebhookPayload is derived from typeof github.context.payload.
  • @octokit/openapi-types version skew: @octokit/core depends on a newer copy than the plugins do, and the two disagree on some schema fields (e.g. issue.id is number | bigint in the newer one, because @octokit/request now decodes oversized integers as BigInt). GithubUtils no longer imports @octokit/openapi-types at all — OctokitIssueItem, OctokitCommit, OctokitArtifact, and OctokitPR are derived from the endpoint methods that return them, which pins them to the one copy the REST methods actually use. DeployChecklistUtils now imports OctokitIssueItem from GithubUtils instead of redeclaring it.

Two test-only breakages this surfaced

Both were silent failures worth calling out:

  1. jest.spyOn no longer intercepts octokit REST methods. @octokit/plugin-rest-endpoint-methods now builds every scope (octokit.rest.issues, octokit.rest.pulls, …) as a Proxy that materializes endpoint methods on first access, and jest.spyOn has no effect through a Proxy under bun: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. New tests/utils/materializeOctokitScopes.ts spreads each scope into an ordinary object first, after which jest.spyOn/jest.restoreAllMocks behave normally and no other test code had to change.
  2. @octokit/request reads JSON bodies with text() (then parses them itself, to support BigInt) rather than json(). postOrReplaceComment.test.ts stubs fetch, so its fake Response needed a text().

Rebuild

All 24 committed index.js action bundles were rebuilt with ncc.

Fixed Issues

$
PROPOSAL:

Tests

  1. Check out this branch and run npm install (Node 26.5.0, per .nvmrc).
  2. Run npm run gh-actions-build and confirm all 24 actions build without error.
  3. Run ./.github/scripts/verifyActions.sh and confirm it reports Github Actions are up to date!.
  4. Run npm run test:bun and confirm all tests pass.
  5. Run npm run typecheck and ./scripts/lint.sh .github/ tests/ scripts/ and confirm both are clean.
  6. Run npx knip and confirm no new unused/unlisted dependencies are reported versus main.
  7. Run node .github/actions/javascript/checkSVGCompression/index.js with no GITHUB_TOKEN set and confirm it fails with Error: Input required and not supplied: GITHUB_TOKEN rather than crashing — this proves the ESM-only @actions/core bundled correctly and that svgo/css-tree still resolve.
  8. Run node .github/actions/javascript/bumpVersion/index.js with no SEMVER_LEVEL set, confirm it fails with Error: Input required and not supplied: SEMVER_LEVEL, and confirm git status shows no version files were changed.
  9. Run GITHUB_TOKEN=<a real token> node .github/actions/javascript/isDeployChecklistLocked/index.js and confirm it prints the current StagingDeployCash issue and its labels — this exercises the upgraded Octokit chain against the real API end to end.
  10. Run rm -rf node_modules/@vercel/ncc && npm install --ignore-scripts && ./scripts/applyPatches.sh and confirm patch-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 isAuthorizedContributor and verifySignedCommits, and Validate GitHub Actions runs the build step in CI.

  • Verify that no errors appear in the JS console

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.

  • Verify that no errors appear in the JS console

PR Author Checklist

  • I linked the correct issue in the ### Fixed Issues section above
  • I wrote clear testing steps that cover the changes made in this PR
    • I added steps for local testing in the Tests section
    • I added steps for the expected offline behavior in the Offline steps section
    • I added steps for Staging and/or Production testing in the QA steps section
    • I added steps to cover failure scenarios (i.e. verify an input displays the correct error message if the entered data is not correct)
    • I turned off my network connection and tested it while offline to ensure it matches the expected behavior (i.e. verify the default avatar icon is displayed if app is offline)
    • I tested this PR with a High Traffic account against the staging or production API to ensure there are no regressions (e.g. long loading states that impact usability).
  • I included screenshots or videos for tests on all platforms
  • I ran the tests on all platforms & verified they passed on:
    • Android: Native
    • Android: mWeb Chrome
    • iOS: Native
    • iOS: mWeb Safari
    • MacOS: Chrome / Safari
  • I verified there are no console errors (if there's a console error not related to the PR, report it or open an issue for it to be fixed)
  • I followed proper code patterns (see Reviewing the code)
    • I verified that comments were added to code that is not self explanatory
    • I verified that any new or modified comments were clear, correct English, and explained "why" the code was doing something instead of only explaining "what" the code was doing.
    • I verified any copy / text that was added to the app is grammatically correct in English. It adheres to proper capitalization guidelines (note: only the first word of header/labels should be capitalized), and is either coming verbatim from figma or has been approved by marketing (in order to get marketing approval, ask the Bug Zero team member to add the Waiting for copy label to the issue)
  • If a new code pattern is added I verified it was agreed to be used by multiple Expensify engineers
  • I followed the guidelines as stated in the Review Guidelines
  • I tested other components that can be impacted by my changes (i.e. if the PR modifies a shared library or component like Avatar, I verified the components using Avatar are working as expected)
  • If a new CSS style is added I verified that:
    • A similar style doesn't already exist
    • The style can't be created with an existing StyleUtils function (i.e. StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))
  • If new assets were added or existing ones were modified, I verified that:
    • The assets are optimized and compressed (for SVG files, run npm run compress-svg)
    • The assets load correctly across all supported platforms.
  • If the PR modifies code that runs when editing or sending messages, I tested and verified there is no unexpected behavior for all supported markdown - URLs, single line code, code blocks, quotes, headings, bold, strikethrough, and italic.
  • If the PR modifies a generic component, I tested and verified that those changes do not break usages of that component in the rest of the App (i.e. if a shared library or component like Avatar is modified, I verified that Avatar is working as expected in all cases)
  • If the PR modifies a component related to any of the existing Storybook stories, I tested and verified all stories for that component are still working as expected.
  • If the PR modifies a component or page that can be accessed by a direct deeplink, I verified that the code functions as expected when the deeplink is used - from a logged in and logged out account.
  • If the PR modifies the UI (e.g. new buttons, new UI components, changing the padding/spacing/sizing, moving components, etc) or modifies the form input styles:
    • I verified that all the inputs inside a form are aligned with each other.
    • I added Design label and/or tagged @Expensify/design so the design team can review the changes.
  • I added unit tests for any new feature or bug fix in this PR to help automatically prevent regressions in this user flow.
  • If the main branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to the Test steps.

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.

…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.
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