Skip to content

Commit

Permalink
Add node22 support and testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sparticuz committed Nov 25, 2024
1 parent ee54b00 commit 160ad97
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
- 16
- 18
- 20
- 22
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
node-version: 22.x
registry-url: https://registry.npmjs.org/

- run: npm ci
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ pretest:
npm install --prefix _/amazon/handlers puppeteer-core@latest --bin-links=false --fund=false --omit=optional --omit=dev --package-lock=false --save=false

test:
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node20
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node22

test16:
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node16

test18:
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node18

test20:
sam local invoke --template _/amazon/template.yml --event _/amazon/events/example.com.json node20

%.zip:
npm install --fund=false --package-lock=false
npm run build
Expand Down
12 changes: 12 additions & 0 deletions _/amazon/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Resources:
- nodejs16.x
- nodejs18.x
- nodejs20.x
- nodejs22.x

node16:
Type: AWS::Serverless::Function
Expand Down Expand Up @@ -49,3 +50,14 @@ Resources:
- AWSLambdaBasicExecutionRole
- AWSXRayDaemonWriteAccess
Tracing: Active
node22:
Type: AWS::Serverless::Function
Properties:
Layers:
- !Ref layer
Handler: handlers/index.handler
Runtime: nodejs22.x
Policies:
- AWSLambdaBasicExecutionRole
- AWSXRayDaemonWriteAccess
Tracing: Active
14 changes: 11 additions & 3 deletions source/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ export const isRunningInAwsLambda = () => {
if (
process.env["AWS_EXECUTION_ENV"] &&
process.env["AWS_EXECUTION_ENV"].includes("AWS_Lambda_nodejs") &&
!process.env["AWS_EXECUTION_ENV"].includes("20.x")
!process.env["AWS_EXECUTION_ENV"].includes("20.x") &&
!process.env["AWS_EXECUTION_ENV"].includes("22.x")
) {
return true;
} else if (
process.env["AWS_LAMBDA_JS_RUNTIME"] &&
process.env["AWS_LAMBDA_JS_RUNTIME"].includes("nodejs") &&
!process.env["AWS_LAMBDA_JS_RUNTIME"].includes("20.x")
!process.env["AWS_LAMBDA_JS_RUNTIME"].includes("20.x") &&
!process.env["AWS_LAMBDA_JS_RUNTIME"].includes("22.x")
) {
return true;
}
Expand All @@ -75,10 +77,16 @@ export const isRunningInAwsLambdaNode20 = () => {
if (
(process.env["AWS_EXECUTION_ENV"] &&
process.env["AWS_EXECUTION_ENV"].includes("20.x")) ||
(process.env["AWS_EXECUTION_ENV"] &&
process.env["AWS_EXECUTION_ENV"].includes("22.x")) ||
(process.env["AWS_LAMBDA_JS_RUNTIME"] &&
process.env["AWS_LAMBDA_JS_RUNTIME"].includes("20.x")) ||
(process.env["AWS_LAMBDA_JS_RUNTIME"] &&
process.env["AWS_LAMBDA_JS_RUNTIME"].includes("22.x")) ||
(process.env["CODEBUILD_BUILD_IMAGE"] &&
process.env["CODEBUILD_BUILD_IMAGE"].includes("nodejs20")) ||
(process.env["CODEBUILD_BUILD_IMAGE"] &&
process.env["CODEBUILD_BUILD_IMAGE"].includes("nodejs20"))
process.env["CODEBUILD_BUILD_IMAGE"].includes("nodejs22"))
) {
return true;
}
Expand Down

0 comments on commit 160ad97

Please sign in to comment.