From 160ad97634b70a87c5cda576f18e555159a6414f Mon Sep 17 00:00:00 2001 From: Kyle McNally Date: Mon, 25 Nov 2024 13:35:05 -0500 Subject: [PATCH] Add node22 support and testing --- .github/workflows/aws.yml | 1 + .github/workflows/release.yml | 2 +- Makefile | 5 ++++- _/amazon/template.yml | 12 ++++++++++++ source/helper.ts | 14 +++++++++++--- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/aws.yml b/.github/workflows/aws.yml index 296cdbc..fc1064b 100644 --- a/.github/workflows/aws.yml +++ b/.github/workflows/aws.yml @@ -46,6 +46,7 @@ jobs: - 16 - 18 - 20 + - 22 steps: - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 91e8a27..8c250e8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 diff --git a/Makefile b/Makefile index ce75982..f434a0d 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ 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 @@ -16,6 +16,9 @@ test16: 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 diff --git a/_/amazon/template.yml b/_/amazon/template.yml index a3fa352..340efe9 100644 --- a/_/amazon/template.yml +++ b/_/amazon/template.yml @@ -15,6 +15,7 @@ Resources: - nodejs16.x - nodejs18.x - nodejs20.x + - nodejs22.x node16: Type: AWS::Serverless::Function @@ -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 diff --git a/source/helper.ts b/source/helper.ts index 83bd539..95871f2 100644 --- a/source/helper.ts +++ b/source/helper.ts @@ -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; } @@ -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; }