Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update packages, migrate to ESM#1760

Open
Samirat wants to merge 3 commits into
mainfrom
samirat/esm_migration_and_package_update
Open

Update packages, migrate to ESM#1760
Samirat wants to merge 3 commits into
mainfrom
samirat/esm_migration_and_package_update

Conversation

@Samirat
Copy link
Copy Markdown

@Samirat Samirat commented May 20, 2026

Description

  • Update cache to the most recent version published from toolkit (v6)
  • Migrate to ESM (required in order to consume new packages)

Motivation and Context

Related to https://github.com/github/c2c-actions-support/issues/6176 and in general this package needed more work to keep it from falling farther out of date.
The ESM migration is necessary in order to consume any new versions of the cache package

How Has This Been Tested?

  • Local Tests

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (add or update README or docs)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@Samirat Samirat requested a review from a team as a code owner May 20, 2026 19:51
Copilot AI review requested due to automatic review settings May 20, 2026 19:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the action to the latest @actions/* toolkit majors (cache v6) and attempts to migrate the repository/tooling to ESM, including updating documentation references and adjusting the Jest test setup for ESM.

Changes:

  • Bump action/toolkit dependencies to @actions/cache@^6.0.1 and related @actions/* majors; update release notes and docs to reference actions/cache@v6.
  • Switch the package to ESM ("type": "module") and update TS compiler settings for newer Node/ES targets.
  • Migrate Jest configuration/tests to an ESM-compatible setup (jest.config.ts, unstable_mockModule, ESM transforms).
Show a summary per file
File Description
tsconfig.json Updates TS target/module settings for ESM + modern Node, adjusts excludes.
tips-and-workarounds.md Updates usage examples to actions/cache@v6.
RELEASES.md Adds v6.0.0 changelog entry.
README.md Updates docs to reference actions/cache@v6 and notes v6 changes.
package.json Bumps version/deps, sets ESM package type, updates Jest invocation.
jest.config.ts Adds new TS-based Jest config for ESM + ts-jest.
jest.config.js Removes previous CJS Jest config.
examples.md Updates usage examples to actions/cache@v6.
caching-strategies.md Updates usage examples to actions/cache@v6 / restore/save @v6.
tests/stateProvider.test.ts Migrates tests to ESM-style mocking/imports.
tests/saveOnly.test.ts Migrates tests to ESM-style mocking/imports.
tests/saveImpl.test.ts Migrates tests to ESM-style mocking/imports; adjusts warning expectations.
tests/save.test.ts Migrates tests to ESM-style mocking/imports.
tests/restoreOnly.test.ts Migrates tests to ESM-style mocking/imports.
tests/restoreImpl.test.ts Migrates tests to ESM-style mocking/imports; adjusts error simulation.
tests/restore.test.ts Migrates tests to ESM-style mocking/imports.
tests/actionUtils.test.ts Migrates tests to ESM-style mocking/imports; simplifies assertions.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 15/18 changed files
  • Comments generated: 6

Comment thread package.json
"type": "module",
"main": "dist/restore/index.js",
"scripts": {
"build": "tsc && ncc build -o dist/restore src/restore.ts && ncc build -o dist/save src/save.ts && ncc build -o dist/restore-only src/restoreOnly.ts && ncc build -o dist/save-only src/saveOnly.ts",
Comment thread package.json
"scripts": {
"build": "tsc && ncc build -o dist/restore src/restore.ts && ncc build -o dist/save src/save.ts && ncc build -o dist/restore-only src/restoreOnly.ts && ncc build -o dist/save-only src/saveOnly.ts",
"test": "tsc --noEmit && jest --coverage",
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
Comment on lines +164 to +166
(core.getState as jest.Mock)
.mockReturnValueOnce(savedCacheKey)
.mockReturnValueOnce(primaryKey);
Comment on lines +181 to +183
(core.getState as jest.Mock)
.mockReturnValueOnce(savedCacheKey)
.mockReturnValueOnce(primaryKey);
Comment on lines +207 to +209
(core.getState as jest.Mock)
.mockReturnValueOnce(savedCacheKey)
.mockReturnValueOnce(primaryKey);
Comment on lines +233 to +235
(core.getState as jest.Mock)
.mockReturnValueOnce(savedCacheKey)
.mockReturnValueOnce(primaryKey);
Comment on lines +103 to +105
expect(actionUtils.isExactKeyMatch("linux-áccent", "linux-accent")).toBe(
false
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
expect(actionUtils.isExactKeyMatch("linux-áccent", "linux-accent")).toBe(
false
);
expect(actionUtils.isExactKeyMatch("linux-áccent", "linux-accent")).toBe(false);

});

test("restore on GHES with AC available ", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me how this test can do it's validation with out mocking isGhes

Comment thread README.md

> [!IMPORTANT]
> `actions/cache@v5` runs on the Node.js 24 runtime and requires a minimum Actions Runner version of `2.327.1`.
> `actions/cache@v6` runs on the Node.js 24 runtime and requires a minimum Actions Runner version of `2.327.1`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should likely stay pointing at v5 (yes it applies to v6 too and any version that follows)

Suggested change
> `actions/cache@v6` runs on the Node.js 24 runtime and requires a minimum Actions Runner version of `2.327.1`.
> `actions/cache@v5` (and newer) runs on the Node.js 24 runtime and requires a minimum Actions Runner version of `2.327.1`.

Comment thread README.md
If you are using this inside a container, a POSIX-compliant `tar` needs to be included and accessible from the execution path.

Note: `actions/cache@v5` runs on Node.js 24 and requires a minimum Actions Runner version of `2.327.1`.
Note: `actions/cache@v6` runs on Node.js 24 and requires a minimum Actions Runner version of `2.327.1`.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Note: `actions/cache@v6` runs on Node.js 24 and requires a minimum Actions Runner version of `2.327.1`.
Note: `actions/cache@v5` (and newer) runs on Node.js 24 and requires a minimum Actions Runner version of `2.327.1`.

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.

3 participants