Skip to content

Update dependencies and use Node 20 - #425

Merged
joshmgross merged 12 commits into
mainfrom
joshmgross/node-20
Nov 13, 2023
Merged

joshmgross merged 12 commits into
mainfrom
joshmgross/node-20

Conversation

@joshmgross

@joshmgross joshmgross commented Oct 11, 2023

Copy link
Copy Markdown
Contributor

Supports #421

With https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/, we can use Node 20 now.

This updates the action to that runtime and updates every dependency to the latest version. This also allows us to use the latest Octokit, which had dropped support for Node 16 (see actions/toolkit#1542).

As part of these changes, I've removed node-fetch as fetch is was added by default in Node 18.

With the latest Octokit, API previews are now only used for GraphQL APIs. I've updated the previews input to reflect that change.

@joshmgross
joshmgross requested a review from a team as a code owner October 11, 2023 20:16
@joshmgross
joshmgross had a problem deploying to debug-integration-test October 11, 2023 20:16 — with GitHub Actions Error
@github-actions

github-actions Bot commented Oct 11, 2023

Copy link
Copy Markdown

Hello from actions/github-script! (ba396f6)

@joshmgross
joshmgross had a problem deploying to debug-integration-test October 11, 2023 20:18 — with GitHub Actions Failure
@joshmgross
joshmgross had a problem deploying to debug-integration-test October 11, 2023 20:21 — with GitHub Actions Failure
Comment thread README.md Outdated
Co-authored-by: Martin Costello <martin@martincostello.com>
@joshmgross
joshmgross had a problem deploying to debug-integration-test October 12, 2023 17:06 — with GitHub Actions Failure
@joshmgross
joshmgross had a problem deploying to debug-integration-test October 12, 2023 17:13 — with GitHub Actions Failure
@joshmgross
joshmgross temporarily deployed to debug-integration-test October 12, 2023 17:15 — with GitHub Actions Inactive
@joshmgross

Copy link
Copy Markdown
Contributor Author

Looks like there's a legitimate failure with the preview integration test:

- Validating previews set to a single value
Error: ❌ Expected 'application/vnd.github.foo-preview+json', got application/vnd.github.v3+json
Error: Process completed with exit code 1.

@joshmgross
joshmgross marked this pull request as draft October 13, 2023 18:18
@joshmgross joshmgross mentioned this pull request Oct 30, 2023
3 tasks
@MikeMcC399

Copy link
Copy Markdown

You could probably also update to the node20 versions of related actions:

@Bo98

Bo98 commented Oct 31, 2023

Copy link
Copy Markdown

Looks like there's a legitimate failure with the preview integration test:

Previews are no longer supported in Octokit unless you are sending a request to /graphql: octokit/endpoint.js@376276d. This aligns with how previews have been phased out from the GitHub REST API (https://github.blog/changelog/2021-10-14-rest-api-preview-promotions) and the documentation was removed a couple years ago.

So probably worth adjusting the test to be a GraphQL one and adjusting any needed documentation accordingly.

@erikburt

erikburt commented Oct 31, 2023

Copy link
Copy Markdown

Took a look at the failing test and I think I figured it out. Seems like the problem lies with the updated @actions/Github and octokit dependencies.

Looking at this code segment that deals with the previews - which has been pulled in with the dependency updates. It only applies previews if the route is /graphql.

Some local testing:

INPUT_SCRIPT="return github.request.endpoint({url: \"/graphql\"}).headers.accept" INPUT_GITHUB_TOKEN=<redacted> INPUT_RESULT_ENCODING=string INPUT_PREVIEWS=foo INPUT_DEBUG=true INPUT_RETRIES=0 node ./dist/index.js

::set-output name=result::application/vnd.github.foo-preview+json

And without {url: \"/graphql\"} (as in the workflow file):

INPUT_SCRIPT="return github.request.endpoint({}).headers.accept" INPUT_GITHUB_TOKEN=<redacted> INPUT_RESULT_ENCODING=string INPUT_PREVIEWS=foo INPUT_DEBUG=true INPUT_RETRIES=0 node ./dist/index.js

::set-output name=result::application/vnd.github.v3+json

I'm able to run that ^ because I've made changes to main.ts which switches necessary input names from kebab-case to snake_case because my shell (and most shells) don't support - in environment variable names.

Diff
diff --git a/src/main.ts b/src/main.ts
index 44b1270..6e82709 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -23,7 +23,7 @@ type Options = {
 }
 
 async function main(): Promise<void> {
-  const token = core.getInput('github-token', {required: true})
+  const token = core.getInput('github_token', {required: true})
   const debug = core.getBooleanInput('debug')
   const userAgent = core.getInput('user-agent')
   const previews = core.getInput('previews')
@@ -63,7 +63,7 @@ async function main(): Promise<void> {
     script
   )
 
-  let encoding = core.getInput('result-encoding')
+  let encoding = core.getInput('result_encoding')
   encoding = encoding ? encoding : 'json'
 
   let output

@joshmgross
joshmgross temporarily deployed to debug-integration-test November 8, 2023 14:54 — with GitHub Actions Inactive
@joshmgross
joshmgross temporarily deployed to debug-integration-test November 8, 2023 15:04 — with GitHub Actions Inactive
@joshmgross
joshmgross temporarily deployed to debug-integration-test November 8, 2023 15:07 — with GitHub Actions Inactive
@joshmgross
joshmgross temporarily deployed to debug-integration-test November 8, 2023 16:17 — with GitHub Actions Inactive
@joshmgross
joshmgross temporarily deployed to debug-integration-test November 9, 2023 15:06 — with GitHub Actions Inactive
@joshmgross
joshmgross marked this pull request as ready for review November 9, 2023 15:32

@dscho dscho left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I love it, thanks @joshmgross!