Skip to content

Commit d3b18a9

Browse files
authored
ci: add tests for node16 (#105)
* ci: add tests for node16 * ci: working node16 test lambda * workflow: add ci test for node 16 * update README.md
1 parent b61daff commit d3b18a9

File tree

9 files changed

+189
-10
lines changed

9 files changed

+189
-10
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ jobs:
1111
test:
1212
name: Runtime ${{ matrix.runtime }}
1313
runs-on: ubuntu-latest
14-
strategy:
15-
matrix:
16-
runtime: ['py38']
1714
defaults:
1815
run:
1916
working-directory: continous-integration
@@ -29,5 +26,7 @@ jobs:
2926
run: npm ci
3027
- name: CDK Synth
3128
run: npx cdk synth --app "npx ts-node index.ts"
32-
- name: Run integration test against Runtime ${{ matrix.runtime }}
33-
run: npm run test:integration:${{ matrix.runtime }}
29+
- name: Run integration test against Runtime Python 3.8
30+
run: npm run test:integration:py38
31+
- name: Run integration test against Runtime NodeJS 16
32+
run: npm run test:integration:node16

continous-integration/index.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as lambda from 'aws-cdk-lib/aws-lambda';
2+
import * as nodelambda from 'aws-cdk-lib/aws-lambda-nodejs';
23
import { CfnLayerVersion, Code, Runtime } from 'aws-cdk-lib/aws-lambda';
34
import * as path from 'path';
45
import { App, DockerImage, Duration, Stack } from 'aws-cdk-lib';
@@ -41,3 +42,32 @@ new lambda.Function(stack, 'python3.8', {
4142
handler: 'handler.main',
4243
});
4344

45+
46+
new nodelambda.NodejsFunction(stack, 'node16', {
47+
bundling: {
48+
nodeModules: ['tesseractocr'],
49+
commandHooks: {
50+
beforeInstall() {
51+
return [];
52+
},
53+
beforeBundling(inputDir: string, outputDir: string): string[] {
54+
return [
55+
`cp ${inputDir}/faust.png ${outputDir}`,
56+
];
57+
},
58+
afterBundling(inputDir: string, outputDir: string): string[] {
59+
return [];
60+
},
61+
},
62+
},
63+
depsLockFilePath: path.resolve(__dirname, 'lambda-handlers/node16/package-lock.json'),
64+
65+
runtime: Runtime.NODEJS_16_X,
66+
entry: path.resolve(__dirname, 'lambda-handlers/node16/index.js'),
67+
layers: [al2Layer],
68+
functionName: `node16`,
69+
memorySize: 512,
70+
timeout: Duration.seconds(30),
71+
handler: 'handler',
72+
});
73+
67.9 KB
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import recognize from 'tesseractocr'
2+
3+
exports.handler = async function(event) {
4+
const text = await recognize('faust.png')
5+
return {
6+
statusCode: 200,
7+
body: text
8+
};
9+
};

continous-integration/lambda-handlers/node16/package-lock.json

Lines changed: 110 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "node16",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"author": "",
10+
"license": "MIT",
11+
"dependencies": {
12+
"tesseractocr": "^2.0.3"
13+
}
14+
}

continous-integration/package-lock.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

continous-integration/package.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,17 @@
3434
]
3535
},
3636
"devDependencies": {
37-
"aws-cdk-lib": "^2.0.0",
38-
"aws-cdk": "^2.38.1",
39-
"constructs": "^10.0.0",
4037
"@types/jest": "^26.0.14",
4138
"@types/node": "^14.11.5",
39+
"aws-cdk": "^2.38.1",
40+
"aws-cdk-lib": "^2.0.0",
41+
"constructs": "^10.0.0",
4242
"jest": "^26.5.2",
4343
"source-map-support": "^0.5.19",
4444
"ts-jest": "^26.4.1",
4545
"typescript": "~4.0.3"
46+
},
47+
"dependencies": {
48+
"help": "^3.0.2"
4649
}
47-
}
50+
}

ready-to-use/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
### [Amazon Linux 2](./amazonlinux-2)
66

77
- Python 3.8 (:heavy_check_mark:)
8-
- Node.js 10, 12
8+
- NodeJS 12, 14, 16 (:heavy_check_mark:)
99
- Ruby 2.7
1010
- Java 8 (Coretto), 11 (Coretto)
1111
- .NET Core 3.1
1212

1313
### [Amazon Linux 1](./amazonlinux-1) (:warning: most of these runtimes are old/deprecated and will not be supported in the future)
1414

1515
- Python 2.7, 3.6 (:heavy_check_mark:), 3.7
16+
- NodeJS
1617
- Ruby 2.5
1718
- Java 8 (OpenJDK)
1819
- Go 1.x

0 commit comments

Comments
 (0)