Update packages, migrate to ESM#1760
Conversation
There was a problem hiding this comment.
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.1and related@actions/*majors; update release notes and docs to referenceactions/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
| "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", |
| "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", |
| (core.getState as jest.Mock) | ||
| .mockReturnValueOnce(savedCacheKey) | ||
| .mockReturnValueOnce(primaryKey); |
| (core.getState as jest.Mock) | ||
| .mockReturnValueOnce(savedCacheKey) | ||
| .mockReturnValueOnce(primaryKey); |
| (core.getState as jest.Mock) | ||
| .mockReturnValueOnce(savedCacheKey) | ||
| .mockReturnValueOnce(primaryKey); |
| (core.getState as jest.Mock) | ||
| .mockReturnValueOnce(savedCacheKey) | ||
| .mockReturnValueOnce(primaryKey); |
| expect(actionUtils.isExactKeyMatch("linux-áccent", "linux-accent")).toBe( | ||
| false | ||
| ); |
There was a problem hiding this comment.
| 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); |
There was a problem hiding this comment.
It's not clear to me how this test can do it's validation with out mocking isGhes
|
|
||
| > [!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`. |
There was a problem hiding this comment.
This should likely stay pointing at v5 (yes it applies to v6 too and any version that follows)
| > `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`. |
| 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`. |
There was a problem hiding this comment.
| 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`. |
Description
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?
Screenshots (if appropriate):
Types of changes
Checklist: