Skip to content

Commit b1f508b

Browse files
dreamorosiflochaz
andcommitted
feat(all): nodejs16x support (#877)
* feat: added node16 to e2e test * Added runtime to e2eUtils * feat: added node16 to e2e test * chore: added runtime key * chore: update occurrences of nodejs14x * test sam version * test sam version * revert * sam * sam * sam * sam * chore: added .nvmrc * chore: updated cdk example runtime * Update packages/metrics/tests/e2e/basicFeatures.decorators.test.ts Co-authored-by: Florian Chazal <[email protected]> Co-authored-by: Florian Chazal <[email protected]>
1 parent 937bf62 commit b1f508b

30 files changed

+64
-41
lines changed

Diff for: .devcontainer/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/blob/v0.212.0/containers/javascript-node/.devcontainer/base.Dockerfile
22
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 16, 14, 12, 16-bullseye, 14-bullseye, 12-bullseye, 16-buster, 14-buster, 12-buster
3-
ARG VARIANT="14-bullseye"
3+
ARG VARIANT="16-bullseye"
44
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
55

66
# This section to install additional OS packages.

Diff for: .devcontainer/devcontainer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Update 'VARIANT' to pick a Node version: 16, 14, 12.
88
// Append -bullseye or -buster to pin to an OS version.
99
// Use -bullseye variants on local arm64/Apple Silicon.
10-
"args": { "VARIANT": "14-bullseye" }
10+
"args": { "VARIANT": "16-bullseye" }
1111
},
1212

1313
// Set *default* container specific settings.json values on container create.

Diff for: .github/workflows/on-merge-to-main.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
#########################
2222
# Release new version
2323
#########################
24-
- name: "Use NodeJS 14"
24+
- name: "Use NodeJS 16"
2525
uses: actions/setup-node@v3
2626
with:
27-
node-version: '14'
27+
node-version: '16'
2828
- name: Install [email protected]
2929
run: npm i -g npm@next-8
3030
- name: "Setup npm"
@@ -39,6 +39,11 @@ jobs:
3939
# the dependencies in a separate step
4040
working-directory: ./examples/cdk
4141
run: npm ci
42+
- name: "Setup SAM"
43+
# We use an ad-hoc action so we can specify the SAM CLI version
44+
uses: aws-actions/setup-sam@v2
45+
with:
46+
version: 1.49.0
4247
- name: Install SAM example packages
4348
# Since we are not managing the SAM examples with npm workspaces we install
4449
# the dependencies in a separate step

Diff for: .github/workflows/on-release-prod.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
#########################
2222
# Release new version
2323
#########################
24-
- name: "Use NodeJS 14"
24+
- name: "Use NodeJS 16"
2525
uses: actions/setup-node@v3
2626
with:
27-
node-version: '14'
27+
node-version: '16'
2828
- name: Install [email protected]
2929
run: npm i -g npm@next-8
3030
- name: "Setup npm"
@@ -39,6 +39,11 @@ jobs:
3939
# the dependencies in a separate step
4040
working-directory: ./examples/cdk
4141
run: npm ci
42+
- name: "Setup SAM"
43+
# We use an ad-hoc action so we can specify the SAM CLI version
44+
uses: aws-actions/setup-sam@v2
45+
with:
46+
version: 1.49.0
4247
- name: Install SAM example packages
4348
# Since we are not managing the SAM examples with npm workspaces we install
4449
# the dependencies in a separate step

Diff for: .github/workflows/pr_lint_and_test.yml

+7-2
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ jobs:
99
NODE_ENV: dev
1010
steps:
1111
- uses: actions/checkout@v3
12-
- name: Set up Node
12+
- name: "Use NodeJS 16"
1313
uses: actions/setup-node@v3
1414
with:
15-
node-version: '14'
15+
node-version: '16'
1616
- name: Install [email protected]
1717
run: npm i -g npm@next-8
1818
- name: "Setup npm"
@@ -27,6 +27,11 @@ jobs:
2727
# the dependencies in a separate step
2828
working-directory: ./examples/cdk
2929
run: npm ci
30+
- name: "Setup SAM"
31+
# We use an ad-hoc action so we can specify the SAM CLI version
32+
uses: aws-actions/setup-sam@v2
33+
with:
34+
version: 1.49.0
3035
- name: Install SAM example packages
3136
# Since we are not managing the SAM examples with npm workspaces we install
3237
# the dependencies in a separate step

Diff for: .github/workflows/run-e2e-tests.yml

+10-7
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ jobs:
99
steps:
1010
- name: "Checkout"
1111
uses: actions/checkout@v3
12-
- name: "Use NodeJS 14"
12+
- name: "Use NodeJS 16"
1313
uses: actions/setup-node@v3
1414
with:
15-
# Always use version 14 as we use TypeScript target es2020
16-
node-version: 14
15+
node-version: 16
1716
- name: "Install [email protected]"
1817
run: npm i -g npm@next-8
1918
- name: "Install monorepo packages"
@@ -25,6 +24,11 @@ jobs:
2524
# the dependencies in a separate step
2625
working-directory: ./examples/cdk
2726
run: npm ci
27+
- name: "Setup SAM"
28+
# We use an ad-hoc action so we can specify the SAM CLI version
29+
uses: aws-actions/setup-sam@v2
30+
with:
31+
version: 1.49.0
2832
- name: Install SAM example packages
2933
# Since we are not managing the SAM examples with npm workspaces we install
3034
# the dependencies in a separate step
@@ -43,16 +47,15 @@ jobs:
4347
contents: read
4448
strategy:
4549
matrix:
46-
version: [12, 14]
4750
package: [logger, metrics, tracer]
51+
version: [12, 14, 16]
4852
steps:
4953
- name: "Checkout"
5054
uses: actions/checkout@v3
51-
- name: "Use NodeJS 14"
55+
- name: "Use NodeJS 16"
5256
uses: actions/setup-node@v3
5357
with:
54-
# Always use version 14 as we use TypeScript target es2020
55-
node-version: 14
58+
node-version: 16
5659
- name: "Install [email protected]"
5760
run: npm i -g npm@next-8
5861
- name: "Install monorepo packages"

Diff for: .nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
lts/fermium
1+
lts/gallium

Diff for: CONTRIBUTING.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ The alternative is to use a Cloud IDE like [Gitpod](https://www.gitpod.io/) or [
6161

6262
The following tools need to be installed on your system prior to starting working on a pull request:
6363

64-
- [Node.js >= 14.18.1](https://nodejs.org/download/release/latest-v14.x/)
64+
- [Node.js >= 16.x](https://nodejs.org/download/release/latest-v16.x/)
6565
- We recommend using a version in [Active LTS](https://nodejs.org/en/about/releases/)
6666
- If you use [nvm](https://github.com/nvm-sh/nvm#nvmrc) or [fnm](https://github.com/Schniz/fnm) you can install the latest LTS version with `nvm use` or `fnm use` respectively. Both will use the `.nvmrc` file in the project's root.
6767
- [npm 8.x](https://www.npmjs.com/)
@@ -250,7 +250,7 @@ Contributions via pull requests are much appreciated.
250250
251251
### Summary
252252
253-
* This project uses `node@14.x` and `[email protected]` for development (see [Setup](#setup)).
253+
* This project uses `node@16.x` and `[email protected]` for development (see [Setup](#setup)).
254254
* Before opening a Pull Request, please find the existing related issue or open a new one to discuss the proposed changes. A PR without a related issue or discussion has a high risk of being rejected. We are very appreciative and thankful for your time and efforts, and we want to make sure they are not wasted.
255255
* After your proposal has been reviewed and accepted by at least one of the project's maintainers, you can submit a pull request.
256256
* When opening a PR, make sure to follow the checklist inside the pull request template.

Diff for: docs/core/logger.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ For a **complete list** of supported environment variables, refer to [this secti
8282
ShoppingCartApiFunction:
8383
Type: AWS::Serverless::Function
8484
Properties:
85-
Runtime: nodejs14.x
85+
Runtime: nodejs16.x
8686
Environment:
8787
Variables:
8888
LOG_LEVEL: WARN

Diff for: docs/core/metrics.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ The `Metrics` utility is instantiated outside of the Lambda handler. In doing th
101101
HelloWorldFunction:
102102
Type: AWS::Serverless::Function
103103
Properties:
104-
Runtime: nodejs14.x
104+
Runtime: nodejs16.x
105105
Environment:
106106
Variables:
107107
POWERTOOLS_SERVICE_NAME: orders

Diff for: docs/core/tracer.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ The `Tracer` utility is instantiated outside of the Lambda handler. In doing thi
8888
HelloWorldFunction:
8989
Type: AWS::Serverless::Function
9090
Properties:
91-
Runtime: nodejs14.x
91+
Runtime: nodejs16.x
9292
Tracing: Active
9393
Environment:
9494
Variables:

Diff for: examples/cdk/src/example-function.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { custom_resources, aws_iam } from 'aws-cdk-lib';
22
import { Events } from '@aws-lambda-powertools/commons';
33
import { Construct } from 'constructs';
44
import { NodejsFunction, NodejsFunctionProps } from 'aws-cdk-lib/aws-lambda-nodejs';
5-
import { Tracing } from 'aws-cdk-lib/aws-lambda';
5+
import { Tracing, Runtime } from 'aws-cdk-lib/aws-lambda';
66

77
interface ExampleFunctionProps {
88
readonly functionName: string
@@ -23,6 +23,7 @@ class ExampleFunction extends Construct {
2323

2424
const fn = new NodejsFunction(this, functionName, {
2525
tracing: tracingActive ? Tracing.ACTIVE : Tracing.DISABLED,
26+
runtime: Runtime.NODEJS_16_X,
2627
...fnProps
2728
});
2829

Diff for: examples/sam/template.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Transform: AWS::Serverless-2016-10-31
1515
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-template-anatomy-globals.html
1616
Globals:
1717
Function:
18-
Runtime: nodejs14.x
18+
Runtime: nodejs16.x
1919
Architectures:
2020
- x86_64
2121
MemorySize: 128

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"lib/**/*"
8585
],
8686
"engines": {
87-
"node": ">=10"
87+
"node": ">=12"
8888
},
8989
"dependencies": {
9090
"hosted-git-info": "^5.0.0"

Diff for: packages/commons/tests/utils/e2eUtils.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ import { InvocationLogs } from './InvocationLogs';
1414

1515
const lambdaClient = new AWS.Lambda();
1616

17-
const testRuntimeKeys = [ 'nodejs12x', 'nodejs14x' ];
17+
const testRuntimeKeys = [ 'nodejs12x', 'nodejs14x', 'nodejs16x' ];
1818
export type TestRuntimesKey = typeof testRuntimeKeys[number];
1919
export const TEST_RUNTIMES: Record<TestRuntimesKey, Runtime> = {
2020
nodejs12x: Runtime.NODEJS_12_X,
2121
nodejs14x: Runtime.NODEJS_14_X,
22+
nodejs16x: Runtime.NODEJS_16_X,
2223
};
2324

2425
export type StackWithLambdaFunctionOptions = {

Diff for: packages/logger/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
1616
"test:e2e:nodejs12x": "RUNTIME=nodejs12x jest --group=e2e",
1717
"test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e",
18+
"test:e2e:nodejs16x": "RUNTIME=nodejs16x jest --group=e2e",
1819
"test:e2e": "jest --group=e2e",
1920
"watch": "jest --watch --group=unit",
2021
"build": "tsc",
@@ -65,4 +66,4 @@
6566
"lodash.merge": "^4.6.2",
6667
"lodash.pickby": "^4.6.0"
6768
}
68-
}
69+
}

Diff for: packages/logger/tests/e2e/basicFeatures.middy.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
TEARDOWN_TIMEOUT
2828
} from './constants';
2929

30-
const runtime: string = process.env.RUNTIME || 'nodejs14x';
30+
const runtime: string = process.env.RUNTIME || 'nodejs16x';
3131

3232
if (!isValidRuntimeKey(runtime)) {
3333
throw new Error(`Invalid runtime key value: ${runtime}`);

Diff for: packages/logger/tests/e2e/childLogger.manual.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
TEARDOWN_TIMEOUT
2727
} from './constants';
2828

29-
const runtime: string = process.env.RUNTIME || 'nodejs14x';
29+
const runtime: string = process.env.RUNTIME || 'nodejs16x';
3030

3131
if (!isValidRuntimeKey(runtime)) {
3232
throw new Error(`Invalid runtime key value: ${runtime}`);

Diff for: packages/logger/tests/e2e/sampleRate.decorator.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
TEARDOWN_TIMEOUT
2727
} from './constants';
2828

29-
const runtime: string = process.env.RUNTIME || 'nodejs14x';
29+
const runtime: string = process.env.RUNTIME || 'nodejs16x';
3030

3131
if (!isValidRuntimeKey(runtime)) {
3232
throw new Error(`Invalid runtime key value: ${runtime}`);

Diff for: packages/metrics/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
1616
"test:e2e:nodejs12x": "RUNTIME=nodejs12x jest --group=e2e",
1717
"test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e",
18+
"test:e2e:nodejs16x": "RUNTIME=nodejs16x jest --group=e2e",
1819
"test:e2e": "jest --group=e2e",
1920
"watch": "jest --group=unit --watch ",
2021
"build": "tsc",
@@ -69,4 +70,4 @@
6970
"dependencies": {
7071
"@aws-lambda-powertools/commons": "^0.9.1"
7172
}
72-
}
73+
}

Diff for: packages/metrics/tests/e2e/basicFeatures.decorators.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
} from './constants';
3030
import { getMetrics } from '../helpers/metricsUtils';
3131

32-
const runtime: string = process.env.RUNTIME || 'nodejs14x';
32+
const runtime: string = process.env.RUNTIME || 'nodejs16x';
3333

3434
if (!isValidRuntimeKey(runtime)) {
3535
throw new Error(`Invalid runtime key value: ${runtime}`);

Diff for: packages/metrics/tests/e2e/basicFeatures.manual.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
} from './constants';
3030
import { getMetrics } from '../helpers/metricsUtils';
3131

32-
const runtime: string = process.env.RUNTIME || 'nodejs14x';
32+
const runtime: string = process.env.RUNTIME || 'nodejs16x';
3333

3434
if (!isValidRuntimeKey(runtime)) {
3535
throw new Error(`Invalid runtime key value: ${runtime}`);

Diff for: packages/tracer/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
1616
"test:e2e:nodejs12x": "RUNTIME=nodejs12x jest --group=e2e",
1717
"test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e",
18+
"test:e2e:nodejs16x": "RUNTIME=nodejs16x jest --group=e2e",
1819
"test:e2e": "jest --group=e2e",
1920
"watch": "jest --watch",
2021
"build": "tsc",
@@ -51,4 +52,4 @@
5152
"@aws-lambda-powertools/commons": "^0.9.1",
5253
"aws-xray-sdk-core": "^3.3.4"
5354
}
54-
}
55+
}

Diff for: packages/tracer/tests/e2e/allFeatures.decorator.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
assertErrorAndFault,
4141
} from '../helpers/traceAssertions';
4242

43-
const runtime: string = process.env.RUNTIME || 'nodejs14x';
43+
const runtime: string = process.env.RUNTIME || 'nodejs16x';
4444

4545
if (!isValidRuntimeKey(runtime)) {
4646
throw new Error(`Invalid runtime key value: ${runtime}`);

Diff for: packages/tracer/tests/e2e/allFeatures.manual.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ import {
4141
assertAnnotation
4242
} from '../helpers/traceAssertions';
4343

44-
const runtime: string = process.env.RUNTIME || 'nodejs14x';
44+
const runtime: string = process.env.RUNTIME || 'nodejs16x';
4545

4646
if (!isValidRuntimeKey(runtime)) {
4747
throw new Error(`Invalid runtime key value: ${runtime}`);

Diff for: packages/tracer/tests/e2e/allFeatures.middy.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
assertErrorAndFault,
4141
} from '../helpers/traceAssertions';
4242

43-
const runtime: string = process.env.RUNTIME || 'nodejs14x';
43+
const runtime: string = process.env.RUNTIME || 'nodejs16x';
4444

4545
if (!isValidRuntimeKey(runtime)) {
4646
throw new Error(`Invalid runtime key value: ${runtime}`);

Diff for: packages/tracer/tests/e2e/asyncHandler.decorator.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ import {
4040
assertErrorAndFault,
4141
} from '../helpers/traceAssertions';
4242

43-
const runtime: string = process.env.RUNTIME || 'nodejs14x';
43+
const runtime: string = process.env.RUNTIME || 'nodejs16x';
4444

4545
if (!isValidRuntimeKey(runtime)) {
4646
throw new Error(`Invalid runtime key value: ${runtime}`);

Diff for: packages/tracer/tests/helpers/populateEnvironmentVariables.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Reserved variables
22
process.env._X_AMZN_TRACE_ID = '1-abcdef12-3456abcdef123456abcdef12';
33
process.env.AWS_LAMBDA_FUNCTION_NAME = 'my-lambda-function';
4-
process.env.AWS_EXECUTION_ENV = 'nodejs14.x';
4+
process.env.AWS_EXECUTION_ENV = 'nodejs16.x';
55
process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '128';
66
process.env.AWS_REGION = 'eu-west-1';
77
process.env._HANDLER = 'index.handler';

Diff for: packages/tracer/tests/unit/config/EnvironmentVariablesService.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -175,14 +175,14 @@ describe('Class: EnvironmentVariablesService', () => {
175175
test('It returns the value of the environment variable AWS_EXECUTION_ENV', () => {
176176

177177
// Prepare
178-
process.env.AWS_EXECUTION_ENV = 'nodejs14.x';
178+
process.env.AWS_EXECUTION_ENV = 'nodejs16.x';
179179
const service = new EnvironmentVariablesService();
180180

181181
// Act
182182
const value = service.getAwsExecutionEnv();
183183

184184
// Assess
185-
expect(value).toEqual('nodejs14.x');
185+
expect(value).toEqual('nodejs16.x');
186186
});
187187

188188
});

Diff for: packages/tracer/tests/unit/helpers.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ describe('Helper: createTracer function', () => {
220220

221221
test('when AWS_EXECUTION_ENV environment variable is set, tracing is enabled', () => {
222222
// Prepare
223-
process.env.AWS_EXECUTION_ENV = 'nodejs14.x';
223+
process.env.AWS_EXECUTION_ENV = 'nodejs16.x';
224224

225225
// Act
226226
const tracer = createTracer();

0 commit comments

Comments
 (0)