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(all): nodejs16x support #877

Merged
merged 16 commits into from
May 24, 2022
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/blob/v0.212.0/containers/javascript-node/.devcontainer/base.Dockerfile
# [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
ARG VARIANT="14-bullseye"
ARG VARIANT="16-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}

# This section to install additional OS packages.
Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// Update 'VARIANT' to pick a Node version: 16, 14, 12.
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local arm64/Apple Silicon.
"args": { "VARIANT": "14-bullseye" }
"args": { "VARIANT": "16-bullseye" }
},

// Set *default* container specific settings.json values on container create.
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/on-merge-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
#########################
# Release new version
#########################
- name: "Use NodeJS 14"
- name: "Use NodeJS 16"
uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '16'
- name: Install [email protected]
run: npm i -g npm@next-8
- name: "Setup npm"
Expand All @@ -39,6 +39,11 @@ jobs:
# the dependencies in a separate step
working-directory: ./examples/cdk
run: npm ci
- name: "Setup SAM"
# We use an ad-hoc action so we can specify the SAM CLI version
uses: aws-actions/setup-sam@v2
with:
version: 1.49.0
- name: Install SAM example packages
# Since we are not managing the SAM examples with npm workspaces we install
# the dependencies in a separate step
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/on-release-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ jobs:
#########################
# Release new version
#########################
- name: "Use NodeJS 14"
- name: "Use NodeJS 16"
uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '16'
- name: Install [email protected]
run: npm i -g npm@next-8
- name: "Setup npm"
Expand All @@ -39,6 +39,11 @@ jobs:
# the dependencies in a separate step
working-directory: ./examples/cdk
run: npm ci
- name: "Setup SAM"
# We use an ad-hoc action so we can specify the SAM CLI version
uses: aws-actions/setup-sam@v2
with:
version: 1.49.0
- name: Install SAM example packages
# Since we are not managing the SAM examples with npm workspaces we install
# the dependencies in a separate step
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/pr_lint_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:
NODE_ENV: dev
steps:
- uses: actions/checkout@v3
- name: Set up Node
- name: "Use NodeJS 16"
uses: actions/setup-node@v3
with:
node-version: '14'
node-version: '16'
- name: Install [email protected]
run: npm i -g npm@next-8
- name: "Setup npm"
Expand All @@ -27,6 +27,11 @@ jobs:
# the dependencies in a separate step
working-directory: ./examples/cdk
run: npm ci
- name: "Setup SAM"
# We use an ad-hoc action so we can specify the SAM CLI version
uses: aws-actions/setup-sam@v2
with:
version: 1.49.0
- name: Install SAM example packages
# Since we are not managing the SAM examples with npm workspaces we install
# the dependencies in a separate step
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/run-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ jobs:
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Use NodeJS 14"
- name: "Use NodeJS 16"
uses: actions/setup-node@v3
with:
# Always use version 14 as we use TypeScript target es2020
node-version: 14
node-version: 16
- name: "Install [email protected]"
run: npm i -g npm@next-8
- name: "Install monorepo packages"
Expand All @@ -25,6 +24,11 @@ jobs:
# the dependencies in a separate step
working-directory: ./examples/cdk
run: npm ci
- name: "Setup SAM"
# We use an ad-hoc action so we can specify the SAM CLI version
uses: aws-actions/setup-sam@v2
with:
version: 1.49.0
- name: Install SAM example packages
# Since we are not managing the SAM examples with npm workspaces we install
# the dependencies in a separate step
Expand All @@ -43,16 +47,15 @@ jobs:
contents: read
strategy:
matrix:
version: [12, 14]
package: [logger, metrics, tracer]
version: [12, 14, 16]
steps:
- name: "Checkout"
uses: actions/checkout@v3
- name: "Use NodeJS 14"
- name: "Use NodeJS 16"
uses: actions/setup-node@v3
with:
# Always use version 14 as we use TypeScript target es2020
node-version: 14
node-version: 16
- name: "Install [email protected]"
run: npm i -g npm@next-8
- name: "Install monorepo packages"
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
lts/fermium
lts/gallium
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The alternative is to use a Cloud IDE like [Gitpod](https://www.gitpod.io/) or [

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

- [Node.js >= 14.18.1](https://nodejs.org/download/release/latest-v14.x/)
- [Node.js >= 16.x](https://nodejs.org/download/release/latest-v16.x/)
- We recommend using a version in [Active LTS](https://nodejs.org/en/about/releases/)
- 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.
- [npm 8.x](https://www.npmjs.com/)
Expand Down Expand Up @@ -250,7 +250,7 @@ Contributions via pull requests are much appreciated.

### Summary

* This project uses `node@14.x` and `[email protected]` for development (see [Setup](#setup)).
* This project uses `node@16.x` and `[email protected]` for development (see [Setup](#setup)).
* 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.
* After your proposal has been reviewed and accepted by at least one of the project's maintainers, you can submit a pull request.
* When opening a PR, make sure to follow the checklist inside the pull request template.
Expand Down
2 changes: 1 addition & 1 deletion docs/core/logger.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ For a **complete list** of supported environment variables, refer to [this secti
ShoppingCartApiFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs16.x
Environment:
Variables:
LOG_LEVEL: WARN
Expand Down
2 changes: 1 addition & 1 deletion docs/core/metrics.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ The `Metrics` utility is instantiated outside of the Lambda handler. In doing th
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs16.x
Environment:
Variables:
POWERTOOLS_SERVICE_NAME: orders
Expand Down
2 changes: 1 addition & 1 deletion docs/core/tracer.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ The `Tracer` utility is instantiated outside of the Lambda handler. In doing thi
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
Runtime: nodejs14.x
Runtime: nodejs16.x
Tracing: Active
Environment:
Variables:
Expand Down
3 changes: 2 additions & 1 deletion examples/cdk/src/example-function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { custom_resources, aws_iam } from 'aws-cdk-lib';
import { Events } from '@aws-lambda-powertools/commons';
import { Construct } from 'constructs';
import { NodejsFunction, NodejsFunctionProps } from 'aws-cdk-lib/aws-lambda-nodejs';
import { Tracing } from 'aws-cdk-lib/aws-lambda';
import { Tracing, Runtime } from 'aws-cdk-lib/aws-lambda';

interface ExampleFunctionProps {
readonly functionName: string
Expand All @@ -23,6 +23,7 @@ class ExampleFunction extends Construct {

const fn = new NodejsFunction(this, functionName, {
tracing: tracingActive ? Tracing.ACTIVE : Tracing.DISABLED,
runtime: Runtime.NODEJS_16_X,
...fnProps
});

Expand Down
2 changes: 1 addition & 1 deletion examples/sam/template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Transform: AWS::Serverless-2016-10-31
# https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-template-anatomy-globals.html
Globals:
Function:
Runtime: nodejs14.x
Runtime: nodejs16.x
Architectures:
- x86_64
MemorySize: 128
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@
"lib/**/*"
],
"engines": {
"node": ">=10"
"node": ">=12"
},
"dependencies": {
"hosted-git-info": "^5.0.0"
}
}
}
3 changes: 2 additions & 1 deletion packages/commons/tests/utils/e2eUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ import { InvocationLogs } from './InvocationLogs';

const lambdaClient = new AWS.Lambda();

const testRuntimeKeys = [ 'nodejs12x', 'nodejs14x' ];
const testRuntimeKeys = [ 'nodejs12x', 'nodejs14x', 'nodejs16x' ];
export type TestRuntimesKey = typeof testRuntimeKeys[number];
export const TEST_RUNTIMES: Record<TestRuntimesKey, Runtime> = {
nodejs12x: Runtime.NODEJS_12_X,
nodejs14x: Runtime.NODEJS_14_X,
nodejs16x: Runtime.NODEJS_16_X,
};

export type StackWithLambdaFunctionOptions = {
Expand Down
3 changes: 2 additions & 1 deletion packages/logger/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
"test:e2e:nodejs12x": "RUNTIME=nodejs12x jest --group=e2e",
"test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e",
"test:e2e:nodejs16x": "RUNTIME=nodejs16x jest --group=e2e",
"test:e2e": "jest --group=e2e",
"watch": "jest --watch --group=unit",
"build": "tsc",
Expand Down Expand Up @@ -65,4 +66,4 @@
"lodash.merge": "^4.6.2",
"lodash.pickby": "^4.6.0"
}
}
}
2 changes: 1 addition & 1 deletion packages/logger/tests/e2e/basicFeatures.middy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
TEARDOWN_TIMEOUT
} from './constants';

const runtime: string = process.env.RUNTIME || 'nodejs14x';
const runtime: string = process.env.RUNTIME || 'nodejs16x';

if (!isValidRuntimeKey(runtime)) {
throw new Error(`Invalid runtime key value: ${runtime}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/tests/e2e/childLogger.manual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
TEARDOWN_TIMEOUT
} from './constants';

const runtime: string = process.env.RUNTIME || 'nodejs14x';
const runtime: string = process.env.RUNTIME || 'nodejs16x';

if (!isValidRuntimeKey(runtime)) {
throw new Error(`Invalid runtime key value: ${runtime}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/logger/tests/e2e/sampleRate.decorator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
TEARDOWN_TIMEOUT
} from './constants';

const runtime: string = process.env.RUNTIME || 'nodejs14x';
const runtime: string = process.env.RUNTIME || 'nodejs16x';

if (!isValidRuntimeKey(runtime)) {
throw new Error(`Invalid runtime key value: ${runtime}`);
Expand Down
3 changes: 2 additions & 1 deletion packages/metrics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
"test:e2e:nodejs12x": "RUNTIME=nodejs12x jest --group=e2e",
"test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e",
"test:e2e:nodejs16x": "RUNTIME=nodejs16x jest --group=e2e",
"test:e2e": "jest --group=e2e",
"watch": "jest --group=unit --watch ",
"build": "tsc",
Expand Down Expand Up @@ -69,4 +70,4 @@
"dependencies": {
"@aws-lambda-powertools/commons": "^0.8.1"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from './constants';
import { getMetrics } from '../helpers/metricsUtils';

const runtime: string = process.env.RUNTIME || 'nodejs14x';
const runtime: string = process.env.RUNTIME || 'nodejs16x';

if (!isValidRuntimeKey(runtime)) {
throw new Error(`Invalid runtime key value: ${runtime}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/metrics/tests/e2e/basicFeatures.manual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from './constants';
import { getMetrics } from '../helpers/metricsUtils';

const runtime: string = process.env.RUNTIME || 'nodejs14x';
const runtime: string = process.env.RUNTIME || 'nodejs16x';

if (!isValidRuntimeKey(runtime)) {
throw new Error(`Invalid runtime key value: ${runtime}`);
Expand Down
3 changes: 2 additions & 1 deletion packages/tracer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
"test:e2e:nodejs12x": "RUNTIME=nodejs12x jest --group=e2e",
"test:e2e:nodejs14x": "RUNTIME=nodejs14x jest --group=e2e",
"test:e2e:nodejs16x": "RUNTIME=nodejs16x jest --group=e2e",
"test:e2e": "jest --group=e2e",
"watch": "jest --watch",
"build": "tsc",
Expand Down Expand Up @@ -51,4 +52,4 @@
"@aws-lambda-powertools/commons": "^0.8.1",
"aws-xray-sdk-core": "^3.3.4"
}
}
}
2 changes: 1 addition & 1 deletion packages/tracer/tests/e2e/allFeatures.decorator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
assertErrorAndFault,
} from '../helpers/traceAssertions';

const runtime: string = process.env.RUNTIME || 'nodejs14x';
const runtime: string = process.env.RUNTIME || 'nodejs16x';

if (!isValidRuntimeKey(runtime)) {
throw new Error(`Invalid runtime key value: ${runtime}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/tracer/tests/e2e/allFeatures.manual.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import {
assertAnnotation
} from '../helpers/traceAssertions';

const runtime: string = process.env.RUNTIME || 'nodejs14x';
const runtime: string = process.env.RUNTIME || 'nodejs16x';

if (!isValidRuntimeKey(runtime)) {
throw new Error(`Invalid runtime key value: ${runtime}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/tracer/tests/e2e/allFeatures.middy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
assertErrorAndFault,
} from '../helpers/traceAssertions';

const runtime: string = process.env.RUNTIME || 'nodejs14x';
const runtime: string = process.env.RUNTIME || 'nodejs16x';

if (!isValidRuntimeKey(runtime)) {
throw new Error(`Invalid runtime key value: ${runtime}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/tracer/tests/e2e/asyncHandler.decorator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
assertErrorAndFault,
} from '../helpers/traceAssertions';

const runtime: string = process.env.RUNTIME || 'nodejs14x';
const runtime: string = process.env.RUNTIME || 'nodejs16x';

if (!isValidRuntimeKey(runtime)) {
throw new Error(`Invalid runtime key value: ${runtime}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Reserved variables
process.env._X_AMZN_TRACE_ID = '1-abcdef12-3456abcdef123456abcdef12';
process.env.AWS_LAMBDA_FUNCTION_NAME = 'my-lambda-function';
process.env.AWS_EXECUTION_ENV = 'nodejs14.x';
process.env.AWS_EXECUTION_ENV = 'nodejs16.x';
process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '128';
process.env.AWS_REGION = 'eu-west-1';
process.env._HANDLER = 'index.handler';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,14 @@ describe('Class: EnvironmentVariablesService', () => {
test('It returns the value of the environment variable AWS_EXECUTION_ENV', () => {

// Prepare
process.env.AWS_EXECUTION_ENV = 'nodejs14.x';
process.env.AWS_EXECUTION_ENV = 'nodejs16.x';
const service = new EnvironmentVariablesService();

// Act
const value = service.getAwsExecutionEnv();

// Assess
expect(value).toEqual('nodejs14.x');
expect(value).toEqual('nodejs16.x');
});

});
Expand Down
Loading