Skip to content

Upgrade to @actions/cache@6, @actions/core@3 and migrate to ESM for Node.js 24#5

Open
Copilot wants to merge 1 commit intomainfrom
copilot/upgrade-dependencies-and-refactor
Open

Upgrade to @actions/cache@6, @actions/core@3 and migrate to ESM for Node.js 24#5
Copilot wants to merge 1 commit intomainfrom
copilot/upgrade-dependencies-and-refactor

Conversation

Copy link
Copy Markdown

Copilot AI commented Mar 30, 2026

Both @actions/cache@6 and @actions/core@3 are ESM-only. This requires a full CommonJS → ESM migration of the codebase to remain compatible with the latest dependency versions and the node24 runtime.

Dependencies

  • @actions/cache 4.0.x → 6.0.0
  • @actions/core 1.11.x → 3.0.0

ESM migration

  • Added "type": "module" to package.json
  • All require()/module.exportsimport/export
  • Built-in modules use node: protocol prefix
  • Async wrapper functions replaced with top-level await
// Before
const core = require("@actions/core");
const { parseBooleanInput, buildBaseConfig } = require("./utils");
async function fetchCache() { ... }
fetchCache();

// After
import * as core from "@actions/core";
import { buildBaseConfig } from "./utils.js";
await cache.restoreCache(paths, keyString, restoreKeys);

Code cleanup

  • Removed custom parseBooleanInput() — replaced by core.getBooleanInput() from @actions/core@3
  • Replaced execSync("date +%s") with Math.floor(Date.now() / 1000)
  • Fixed repo URLs from klever1988HiGarfield
  • Version bump to 2.0.0

CI

  • actions/checkout@v2v4, added actions/setup-node@v4 with node-version: '24'

@HiGarfield HiGarfield marked this pull request as ready for review March 30, 2026 07:18
Copilot AI review requested due to automatic review settings March 30, 2026 07:18
Copy link
Copy Markdown

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

Migrates the GitHub Action codebase to ESM to support ESM-only @actions/cache@6 and @actions/core@3, and updates CI for the Node.js 24 runtime.

Changes:

  • Converted CommonJS require/module.exports usage to ESM import/export and introduced top-level execution.
  • Replaced custom boolean parsing with core.getBooleanInput() and removed shell-based timestamping.
  • Updated CI workflow actions to latest versions and pinned Node.js to 24.

Reviewed changes

Copilot reviewed 2 out of 5625 changed files in this pull request and generated 2 comments.

File Description
fetch.js Converts to ESM imports/top-level execution and updates input parsing + timestamp generation.
.github/workflows/licensed.yml Updates checkout action and adds Node.js 24 setup for CI.

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

Comment on lines +1 to +4
import * as core from "@actions/core";
import { execSync } from "node:child_process";
import * as cache from "@actions/cache";
import { buildBaseConfig } from "./utils.js";
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

execSync is still imported but the timestamp logic was switched to Date.now(), so execSync is no longer used in this file. Remove the node:child_process import to avoid dead code and keep the module dependency surface minimal.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

@copilot apply changes based on this feedback

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The execSync import is still needed — it's used on lines 35-36 for the sed commands that skip toolchain building. The reviewer's suggestion was incorrect; removing the import would break the action when cacheToolchain && skipBuildingToolchain is true.

if (!cleanUpCache) {
const { keyString: baseKey, paths, cacheToolchain, cacheCcache } = buildBaseConfig();
const skipBuildingToolchain = parseBooleanInput(core.getInput("skip"), true);
const skipBuildingToolchain = core.getBooleanInput("skip");
Copy link

Copilot AI Mar 30, 2026

Choose a reason for hiding this comment

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

This changes the default/accepted values behavior for skip: previously parseBooleanInput(core.getInput(\"skip\"), true) implies a default of true (and possibly more permissive parsing like 1/0, depending on the removed helper). core.getBooleanInput(\"skip\") returns false when the input is absent and throws on invalid values, which may inadvertently flip behavior or break existing users. To preserve prior semantics, either set default: 'true' for skip in action.yml (preferred) or explicitly implement a true fallback when the input is unset while keeping strict validation consistent with your intended UX.

Suggested change
const skipBuildingToolchain = core.getBooleanInput("skip");
const skipInput = core.getInput("skip");
let skipBuildingToolchain: boolean;
if (skipInput === "") {
// Preserve previous semantics: default to true when input is unset
skipBuildingToolchain = true;
} else if (/^(true|1)$/i.test(skipInput)) {
skipBuildingToolchain = true;
} else if (/^(false|0)$/i.test(skipInput)) {
skipBuildingToolchain = false;
} else {
throw new Error(
"Invalid value for 'skip'. Expected one of: 'true', 'false', '1', '0', or empty (defaults to true)."
);
}

Copilot uses AI. Check for mistakes.
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