Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for nodejs22.x runtime to v13 #1838

Merged
merged 2 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/config/supportedRuntimes.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const supportedRuntimesArchitecture = {
"nodejs16.x": [ARM64, X86_64],
"nodejs18.x": [ARM64, X86_64],
"nodejs20.x": [ARM64, X86_64],
"nodejs22.x": [ARM64, X86_64],
"python3.7": [X86_64],
"python3.8": [ARM64, X86_64],
"python3.9": [ARM64, X86_64],
Expand Down Expand Up @@ -46,6 +47,7 @@ export const supportedNodejs = new Set([
"nodejs16.x",
"nodejs18.x",
"nodejs20.x",
"nodejs22.x",
])

// PROVIDED
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import assert from "node:assert"
import { env } from "node:process"
import { join } from "desm"
import { setup, teardown } from "../../../../_testHelpers/index.js"
import { BASE_URL } from "../../../../config.js"

describe("Node.js 22.x with Docker tests", function desc() {
beforeEach(() =>
setup({
servicePath: join(import.meta.url),
}),
)

afterEach(() => teardown())
;[
{
description: "should work with nodejs22.x in docker container",
expected: {
message: "Hello Node.js 22.x!",
},
path: "/dev/hello",
},
].forEach(({ description, expected, path }) => {
it(description, async function it() {
// "Could not find 'Docker', skipping tests."
if (!env.DOCKER_DETECTED) {
this.skip()
}

const url = new URL(path, BASE_URL)
const response = await fetch(url)
const json = await response.json()

assert.equal(json.message, expected.message)
})
})
})
16 changes: 16 additions & 0 deletions tests/integration/docker/nodejs/nodejs22.x/handler.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use strict"

// eslint-disable-next-line unicorn/prefer-node-protocol
const { versions } = require("process")

const { stringify } = JSON

module.exports.hello = async () => {
return {
body: stringify({
message: "Hello Node.js 22.x!",
version: versions.node,
}),
statusCode: 200,
}
}
30 changes: 30 additions & 0 deletions tests/integration/docker/nodejs/nodejs22.x/serverless.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
service: docker-nodejs22-x-test

configValidationMode: warn
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DorianMazur I've had to set this to warn instead of error for the test to pass as serverless v3 does not have nodejs22.x as a supported runtime, hope this is fine.

deprecationNotificationMode: error

plugins:
- ../../../../../src/index.js

provider:
architecture: x86_64
deploymentMethod: direct
memorySize: 1024
name: aws
region: us-east-1
runtime: nodejs22.x
stage: dev
versionFunctions: false

custom:
serverless-offline:
noTimeout: true
useDocker: true

functions:
hello:
events:
- http:
method: get
path: hello
handler: handler.hello
Loading