Skip to content

Conversation

@Bo98
Copy link
Member

@Bo98 Bo98 commented Aug 11, 2025

GitHub Actions now supports Node 24. Node 24 supports natively running TypeScript without needing a compile stage (erasable syntax only) which means we can adopt it without needing to add any build stages.

This pull request experiments with adopting TypeScript (for one action in this initial draft).

Given the Actions runner with support for Node 24 is just 2 weeks old, perhaps we want to allow a little more time before doing this since we don't do tagged releases?

package.json Outdated
"devDependencies": {
"@tsconfig/node-ts": "^23.6.1",
"@tsconfig/node24": "^24.0.1",
"@types/node": "^24.2.1",
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't want Dependabot to bump the major version here so may need to figure out how best to do that.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Good idea! ✅ when 🟢

@github-actions
Copy link

github-actions bot commented Sep 3, 2025

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@Bo98
Copy link
Member Author

Bo98 commented Sep 11, 2025

Code wise this is ready but need to:

  • Update dependabot config as per above
  • Fix coverage regressions
  • Test setup-homebrew still works on Portable Ruby runners (as it's technically under Node 24 requirements)

This did catch one edge case bug in check-commit-format (we just probably never hit that edge case) so typing has at least proven some use.

@github-actions
Copy link

github-actions bot commented Oct 3, 2025

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the Stale label Oct 3, 2025
@Bo98 Bo98 removed the Stale label Oct 9, 2025
@github-actions
Copy link

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@github-actions github-actions bot added the Stale label Oct 31, 2025
@Bo98 Bo98 removed the Stale label Nov 6, 2025
@branchvincent
Copy link
Member

@Bo98 this looks awesome, do you need any help on the remaining items? If so, the first two make sense to me but I may need a pointer on how to do 3

Copilot AI review requested due to automatic review settings November 24, 2025 07:48
Copy link

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 migrates GitHub Actions from Node 20 to Node 24, leveraging Node 24's native TypeScript support to eliminate the need for a compilation step. The migration involves converting JavaScript files to TypeScript (.mts), adding type annotations, and updating action configurations.

Key changes:

  • Converted all action files from .mjs to .mts with TypeScript type annotations
  • Updated all action.yml files to use node24 runtime instead of node20
  • Added type safety improvements including explicit type annotations, non-null assertions, and error handling guards

Reviewed changes

Copilot reviewed 26 out of 518 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
limit-pull-requests/main.test.mts Added type annotation for directory variable
limit-pull-requests/main.mts Added type conversions for numeric inputs, non-null assertions for pull request data, and error type guard
limit-pull-requests/action.yml Updated runtime from node20 to node24, changed entry point to .mts
label-pull-requests/main.test.mts Added null check guard for GITHUB_EVENT_PATH before directory cleanup
label-pull-requests/main.mts Added comprehensive type definitions, assertions, and replaced string matching with RegExp
label-pull-requests/action.yml Updated runtime from node20 to node24, changed entry point to .mts
git-user-config/main.mts Converted from CommonJS to ES modules, added error type guard, changed to top-level await
git-user-config/action.yml Updated runtime from node20 to node24, changed entry point to .mts
git-try-push/main.mts Converted from CommonJS to ES modules, added type conversion for numeric input, added error type guard, changed to top-level await
git-try-push/action.yml Updated runtime from node20 to node24, changed entry point to .mts
find-related-workflow-run-id/main.mts Added GraphQL response typing and optional chaining for nested properties
find-related-workflow-run-id/action.yml Updated runtime from node20 to node24, changed entry point to .mts
dismiss-approvals/main.mts Added parseInt for PR number input and error type guard
dismiss-approvals/action.yml Updated runtime from node20 to node24, changed entry point to .mts
create-pull-request/main.mts Added explicit type annotation for PR request parameters and error type guard
create-pull-request/action.yml Updated runtime from node20 to node24, changed entry point to .mts
create-or-update-issue/main.mts Added type annotation for listForRepo parameters and error type guard
create-or-update-issue/action.yml Updated runtime from node20 to node24, changed entry point to .mts
check-commit-format/main.test.mts Added null check guard for GITHUB_EVENT_PATH and new test cases for merge/empty commits
check-commit-format/main.mts Added type annotations, empty commit detection, and improved array access
check-commit-format/action.yml Updated runtime from node20 to node24, changed entry point to .mts
api-commit-and-push/main.test.mts Added type annotations for test variables
api-commit-and-push/main.mts Added type annotations, improved error handling with type guard, removed redundant file read
api-commit-and-push/action.yml Updated runtime from node20 to node24, changed entry point to .mts
.github/workflows/vendor-node-modules.yml Changed npm install to npm ci --omit=dev for more reliable builds
.github/workflows/test.yml Updated Node version to 24 and added TypeScript type checking step

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


if (body) {
constraintApplies = body.match(constraint.pr_body_content)
constraintApplies = RegExp(constraint.pr_body_content).test(body)
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

Creating a new RegExp object on every iteration is inefficient. Consider compiling the regex once outside the loop or caching it, especially if this constraint is checked multiple times.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

constraint is the loop item so you can't just lift it out. And given it is only used once then caching doesn't make any sense.

if (error.code !== "ENOENT") throw error;

content = null;
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

The type guard for checking 'code' property is verbose. Consider using a type predicate function like 'isNodeError' or casting to 'NodeJS.ErrnoException' which has a typed 'code' property.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

@Bo98 Bo98 Nov 24, 2025

Choose a reason for hiding this comment

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

Type casting is a bit dubious as it might not actually be a ErrnoException whereas "code" in error actually checks it. It doesn't really matter though given JavaScript at runtime allows basically anything anyway so this is all an argument about which semantics one prefers.

@Bo98
Copy link
Member Author

Bo98 commented Nov 24, 2025

I may need a pointer on how to do 3

For point 3 what you'd do is open a test PR to homebrew-core that modifies Portable Ruby and also updates the test workflow to point to Homebrew/actions/setup-homebrew@ts-node24.

Because of the prebuild action stuff, you might need to open a test PR here first to repoint setup-homebrew and then repoint the prebuild action in homebrew-core test PR to the actions test PR.

It's a bit messy but probably worthwhile.

@Bo98
Copy link
Member Author

Bo98 commented Nov 24, 2025

test-bot failure seems new and may need fixing in Homebrew/brew

Copilot AI review requested due to automatic review settings November 24, 2025 08:54
Copy link

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

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


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

for (const file of files.data) {
for (const file of files) {
// File object could have this field set as 'null'
if (!file.sha) {
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

The comment states that the sha field could be null, but when null the file.content field is not set before continuing. This creates inconsistency with other code paths where file.content is always defined. Consider setting file.content to an empty string or undefined for consistency.

Suggested change
if (!file.sha) {
if (!file.sha) {
file.content = "";

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

content is marked as optional above

owner: owner,
repo: repo,
content: await fs.readFile(absoluteFile, {encoding: "base64"}),
content: content,
Copy link

Copilot AI Nov 24, 2025

Choose a reason for hiding this comment

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

The variable 'content' is used here but was already read earlier at line 33. This redundant read was removed, but the variable is still being passed. Consider clarifying whether this change was intentional or if there's a logic issue.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe I'm reading this wrong but this comment doesn't make any sense?

@MikeMcQuaid
Copy link
Member

MikeMcQuaid commented Nov 24, 2025

test-bot failure seems new and may need fixing in Homebrew/brew

@Bo98 correct and now fixed and 🟢 after rerun

@Bo98
Copy link
Member Author

Bo98 commented Dec 1, 2025

Looks like it needs macOS 12, which actually weirdly enough means the old 10.11-cross image would have worked.

Anyhow I'll get a 10.15-cross set up at the same time as the Xcode 26.2 updates (when that's available).

There's also no rush here. I could probably split out the setup-homebrew changes to a separate PR. GHES doesn't even support Node 24 yet - the whole process is a bit less rushed this time so Node 20 won't be deprecated for a while longer.

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.

4 participants