Skip to content

Commit 0a8cbdd

Browse files
authored
test(all): switch to use GitHub strategy matrix and fix flaky tests (#828)
1 parent 0b890fb commit 0a8cbdd

File tree

11 files changed

+106
-203
lines changed

11 files changed

+106
-203
lines changed

.github/workflows/run-e2e-tests.yml

+55-40
Original file line numberDiff line numberDiff line change
@@ -2,48 +2,63 @@ name: run-e2e-tests
22
on:
33
workflow_dispatch: {}
44
jobs:
5-
run:
6-
#########################
7-
# Force Github action to run only a single job at a time (based on the group name)
8-
# This is to prevent "race-condition" in building e2e tests infrastructure
9-
#########################
10-
concurrency:
11-
group: e2e-tests
5+
example-and-package-check:
6+
runs-on: ubuntu-latest
7+
permissions:
8+
contents: read
9+
steps:
10+
- name: "Checkout"
11+
uses: actions/checkout@v3
12+
- name: "Use NodeJS 14"
13+
uses: actions/setup-node@v3
14+
with:
15+
# Always use version 14 as we use TypeScript target es2020
16+
node-version: 14
17+
- name: "Install [email protected]"
18+
run: npm i -g npm@next-8
19+
- name: "Install monorepo packages"
20+
# This installs all the dependencies of ./packages/*
21+
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
22+
run: npm ci --foreground-scripts
23+
- name: "Install example packages"
24+
# Since we are not managing the cdk examples with npm workspaces we install
25+
# the dependencies in a separate step
26+
working-directory: ./examples/cdk
27+
run: npm ci
28+
- name: "Test packaging"
29+
run: |
30+
npm run lerna-package
31+
cd examples/cdk
32+
npm install ../../packages/**/dist/aws-lambda-powertools-*
33+
npm run test
34+
e2e-tests:
1235
runs-on: ubuntu-latest
1336
permissions:
1437
id-token: write # needed to interact with GitHub's OIDC Token endpoint.
1538
contents: read
39+
strategy:
40+
matrix:
41+
version: [12, 14]
42+
package: [logger, metrics, tracing]
1643
steps:
17-
- name: "Checkout"
18-
uses: actions/checkout@v3
19-
#########################
20-
# Release new version
21-
#########################
22-
- name: "Use NodeJS 14"
23-
uses: actions/setup-node@v3
24-
with:
25-
node-version: '14'
26-
- name: Install [email protected]
27-
run: npm i -g npm@next-8
28-
- name: Install monorepo packages
29-
# This installs all the dependencies of ./packages/*
30-
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
31-
run: npm ci --foreground-scripts
32-
- name: Install example packages
33-
# Since we are not managing the cdk examples with npm workspaces we install
34-
# the dependencies in a separate step
35-
working-directory: ./examples/cdk
36-
run: npm ci
37-
- name: Configure AWS credentials
38-
uses: aws-actions/[email protected]
39-
with:
40-
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
41-
aws-region: eu-west-1
42-
- name: Run integration tests
43-
run: npm run lerna-test:e2e
44-
- name: Test packaging
45-
run: |
46-
npm run lerna-package
47-
cd examples/cdk
48-
npm install ../../packages/**/dist/aws-lambda-powertools-*
49-
npm run test
44+
- name: "Checkout"
45+
uses: actions/checkout@v3
46+
- name: "Use NodeJS 14"
47+
uses: actions/setup-node@v3
48+
with:
49+
# Always use version 14 as we use TypeScript target es2020
50+
node-version: 14
51+
- name: "Install [email protected]"
52+
run: npm i -g npm@next-8
53+
- name: "Install monorepo packages"
54+
# This installs all the dependencies of ./packages/*
55+
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
56+
run: npm ci --foreground-scripts
57+
- name: "Configure AWS credentials"
58+
uses: aws-actions/[email protected]
59+
with:
60+
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
61+
aws-region: eu-west-1
62+
- name: "Run integration tests"
63+
run: |
64+
RUNTIME=nodejs${{ matrix.version }}x npm run test:e2e -w packages/${{ matrix.package }}

package-lock.json

+1-146
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/commons/tests/utils/e2eUtils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const createStackWithLambdaFunction = (params: StackWithLambdaFunctionOpt
5757
};
5858

5959
export const generateUniqueName = (name_prefix: string, uuid: string, runtime: string, testName: string): string =>
60-
`${name_prefix}-${runtime}-${testName}-${uuid}`.substring(0, 64);
60+
`${name_prefix}-${runtime}-${uuid.substring(0,5)}-${testName}`.substring(0, 64);
6161

6262
export const invokeFunction = async (functionName: string, times: number = 1, invocationMode: 'PARALLEL' | 'SEQUENTIAL' = 'PARALLEL', payload: FunctionPayload = {}): Promise<InvocationLogs[]> => {
6363
const invocationLogs: InvocationLogs[] = [];

packages/logger/package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +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": "concurrently \"npm:test:e2e:nodejs12x\" \"npm:test:e2e:nodejs14x\"",
18+
"test:e2e": "jest --group=e2e",
1919
"watch": "jest --watch --group=unit",
2020
"build": "tsc",
2121
"lint": "eslint --ext .ts --fix --no-error-on-unmatched-pattern src tests",
@@ -47,8 +47,7 @@
4747
"devDependencies": {
4848
"@types/lodash.clonedeep": "^4.5.6",
4949
"@types/lodash.merge": "^4.6.6",
50-
"@types/lodash.pickby": "^4.6.6",
51-
"concurrently": "^7.0.0"
50+
"@types/lodash.pickby": "^4.6.6"
5251
},
5352
"files": [
5453
"lib"
+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export const RESOURCE_NAME_PREFIX = 'Logger-E2E';
2-
export const TEST_CASE_TIMEOUT = 20_000; // 20 seconds
3-
export const SETUP_TIMEOUT = 300_000; // 300 seconds
4-
export const TEARDOWN_TIMEOUT = 200_000;
2+
export const ONE_MINUTE = 60 * 1000;
3+
export const TEST_CASE_TIMEOUT = ONE_MINUTE;
4+
export const SETUP_TIMEOUT = 5 * ONE_MINUTE;
5+
export const TEARDOWN_TIMEOUT = 5 * ONE_MINUTE;
56
export const STACK_OUTPUT_LOG_GROUP = 'LogGroupName';

packages/metrics/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +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": "concurrently \"npm:test:e2e:nodejs12x\" \"npm:test:e2e:nodejs14x\"",
18+
"test:e2e": "jest --group=e2e",
1919
"watch": "jest --group=unit --watch ",
2020
"build": "tsc",
2121
"lint": "eslint --ext .ts --fix --no-error-on-unmatched-pattern src tests",
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const RESOURCE_NAME_PREFIX = 'Metrics-E2E';
2-
export const ONE_MINUTE = 60 * 10_00;
3-
export const TEST_CASE_TIMEOUT = 90_000; // 90 seconds
4-
export const SETUP_TIMEOUT = 300_000; // 300 seconds
5-
export const TEARDOWN_TIMEOUT = 200_000;
2+
export const ONE_MINUTE = 60 * 1000;
3+
export const TEST_CASE_TIMEOUT = 3 * ONE_MINUTE;
4+
export const SETUP_TIMEOUT = 5 * ONE_MINUTE;
5+
export const TEARDOWN_TIMEOUT = 5 * ONE_MINUTE;

packages/tracing/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +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": "concurrently \"npm:test:e2e:nodejs12x\" \"npm:test:e2e:nodejs14x\"",
18+
"test:e2e": "jest --group=e2e",
1919
"watch": "jest --watch",
2020
"build": "tsc",
2121
"lint": "eslint --ext .ts --fix --no-error-on-unmatched-pattern src tests",

0 commit comments

Comments
 (0)