Skip to content

Commit

Permalink
fix: improve support for payload objects and ESM JS files
Browse files Browse the repository at this point in the history
  • Loading branch information
uglow committed May 29, 2022
1 parent f1d8921 commit 166d384
Show file tree
Hide file tree
Showing 14 changed files with 3,666 additions and 1,285 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/gh-pages-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
run: npm ci
- name: Lint
run: npm run verify
- name: Test
run: npm run test:report

release:
# Only release on push to master
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.nyc_output/
node_modules/

reports/
test-reports/
/.semverDetails
4 changes: 4 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env node
import { main } from '../src/ptx.js';

await main();
21 changes: 21 additions & 0 deletions examples/configs/payloadArray.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"lambdaARN": "arn:aws:lambda:ap-southeast-2:0000000000:function:your-lambda",
"powerValues": [384, 512, 768, 1024, 1280],
"num": 20,
"payload": [
{
"payload": {
"$$include1": "../payloads/p1.json"
},
"weight": 10
},
{
"payload": {
"$$include1": "../payloads/p2.json"
},
"weight": 10
}
],
"parallelInvocation": true,
"strategy": "balanced"
}
16 changes: 16 additions & 0 deletions examples/configs/payloadCJSFunction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"lambdaARN": "arn:aws:lambda:ap-southeast-2:0000000000:function:your-lambda",
"powerValues": [384, 512, 768, 1024, 1280],
"num": 20,
"payload": [
{
"payload": {
"$$include1": "./testFunction.cjs",
"$$args1": ["Hello", "World CJS"]
},
"weight": 20
}
],
"parallelInvocation": true,
"strategy": "balanced"
}
11 changes: 11 additions & 0 deletions examples/configs/payloadESMFunction.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"lambdaARN": "arn:aws:lambda:ap-southeast-2:0000000000:function:your-lambda",
"powerValues": [384, 512, 768, 1024, 1280],
"num": 20,
"payload": {
"$$include1": "./testFunction.js",
"$$args1": ["Hello", "World ESM"]
},
"parallelInvocation": true,
"strategy": "balanced"
}
10 changes: 10 additions & 0 deletions examples/configs/payloadObject.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"lambdaARN": "arn:aws:lambda:ap-southeast-2:0000000000:function:your-lambda",
"powerValues": [384, 512, 768, 1024, 1280],
"num": 20,
"payload": {
"$$include1": "../payloads/p1.json"
},
"parallelInvocation": true,
"strategy": "balanced"
}
6 changes: 6 additions & 0 deletions examples/configs/testFunction.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = function payloadAdaptor(arg1, arg2) {
return {
isBase64Encoded: false,
body: `${arg1} ${arg2}!`,
};
};
6 changes: 6 additions & 0 deletions examples/configs/testFunction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default function payloadAdaptor(arg1, arg2) {
return {
isBase64Encoded: false,
body: `${arg1} ${arg2}!`,
};
}
43 changes: 43 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/configuration
*/

export default {
// The test environment that will be used for testing
testEnvironment: 'node',

// See https://jestjs.io/docs/ecmascript-modules
transform: {},

// All imported modules in your tests should be mocked automatically
automock: false,

// Automatically clear mock calls and instances between every test
clearMocks: true,

reporters: ['default'],

collectCoverageFrom: ['src/**/*.js', '!src/logger.js'],
coverageReporters: ['json-summary', 'lcov', 'text', 'html'],
coverageDirectory: '<rootDir>/test-reports/coverage',
coverageThreshold: {
global: {
statements: 30,
branches: 80,
functions: 12,
lines: 30,
},
},

// Indicates which provider should be used to instrument code for coverage
coverageProvider: 'v8',

moduleDirectories: ['node_modules'],

// https://github.com/chalk/chalk/issues/532

moduleNameMapper: {
'#(.*)': '<rootDir>/node_modules/$1',
},
};
Loading

0 comments on commit 166d384

Please sign in to comment.