Skip to content

Commit e3fd639

Browse files
author
Florian Chazal
committed
add github action for e2e
1 parent 4f99256 commit e3fd639

File tree

11 files changed

+361
-1209
lines changed

11 files changed

+361
-1209
lines changed

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

+35-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
cd examples/cdk
3737
npm install ../../packages/**/dist/aws-lambda-powertools-*
3838
npm run test
39-
e2e-tests:
39+
package-e2e-tests:
4040
runs-on: ubuntu-latest
4141
permissions:
4242
id-token: write # needed to interact with GitHub's OIDC Token endpoint.
@@ -64,6 +64,39 @@ jobs:
6464
with:
6565
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
6666
aws-region: eu-west-1
67-
- name: "Run integration tests"
67+
- name: "Run packages integration tests"
6868
run: |
6969
RUNTIME=nodejs${{ matrix.version }}x npm run test:e2e -w packages/${{ matrix.package }}
70+
layer-e2e-tests:
71+
runs-on: ubuntu-latest
72+
permissions:
73+
id-token: write # needed to interact with GitHub's OIDC Token endpoint.
74+
contents: read
75+
strategy:
76+
matrix:
77+
version: [12, 14]
78+
steps:
79+
- name: "Checkout"
80+
uses: actions/checkout@v3
81+
- name: "Use NodeJS 14"
82+
uses: actions/setup-node@v3
83+
with:
84+
# Always use version 14 as we use TypeScript target es2020
85+
node-version: 14
86+
- name: "Install [email protected]"
87+
run: npm i -g npm@next-8
88+
- name: "Install monorepo packages"
89+
# This installs all the dependencies of ./packages/*
90+
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
91+
run: npm ci --foreground-scripts
92+
- name: "Configure AWS credentials"
93+
uses: aws-actions/[email protected]
94+
with:
95+
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
96+
aws-region: eu-west-1
97+
- name: "Run layer integration tests"
98+
run: |
99+
npm ci
100+
RUNTIME=nodejs${{ matrix.version }}x npm run test:e2e
101+
working-directory: layer-publisher
102+

Diff for: layer-publisher/jest.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = {
22
testEnvironment: 'node',
3-
roots: ['<rootDir>/test'],
3+
runner: 'groups',
4+
roots: ['<rootDir>/tests'],
45
testMatch: ['**/*.test.ts'],
56
transform: {
67
'^.+\\.tsx?$': 'ts-jest'

Diff for: layer-publisher/package-lock.json

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

Diff for: layer-publisher/package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
"scripts": {
88
"build": "tsc",
99
"watch": "tsc -w",
10-
"test": "jest",
11-
"cdk": "cdk"
10+
"test": "npm run test:unit",
11+
"cdk": "cdk",
12+
"package": "echo 'Not applicable'",
13+
"test:unit": "jest --group=unit",
14+
"test:e2e": "jest --group=e2e"
1215
},
1316
"devDependencies": {
1417
"@types/jest": "^26.0.10",
@@ -23,6 +26,7 @@
2326
"aws-cdk-lib": "^2.24.1",
2427
"cdk-lambda-powertools-python-layer": "file:../../cdk-lambda-powertools-python-layer/dist/js/[email protected]",
2528
"constructs": "^10.0.0",
29+
"jest-runner-groups": "^2.2.0",
2630
"source-map-support": "^0.5.16"
2731
}
2832
}

Diff for: layer-publisher/test/e2e/happy-case.test.ts renamed to layer-publisher/tests/e2e/happy-case.test.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Test layer
3+
*
4+
* @group e2e/happy-case
5+
*/
6+
17
import * as cdk from 'aws-cdk-lib';
28
import { Stack } from 'aws-cdk-lib';
39
// import { randomUUID } from 'crypto';
@@ -15,7 +21,7 @@ const layerStack = new LayerPublisher.LayerPublisherStack(e2eTestLayerPublicatio
1521

1622
test('The layer Created is usable by node 14 runtime lambda', async () => {
1723
// GIVEN
18-
const runtime = lambda.Runtime.NODEJS_14_X;
24+
const runtime = lambda.Runtime.ALL.find(r => r.name === process.env.RUNTIME) ?? lambda.Runtime.NODEJS_14_X;
1925
const { consumerStack, functionName } = createSampleLambda(runtime);
2026

2127
await deployStack(e2eTestLayerPublicationApp, layerStack);

Diff for: layer-publisher/test/unit/layer-publisher.test.ts renamed to layer-publisher/tests/unit/layer-publisher.test.ts

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* Test layer publisher
3+
*
4+
* @group unit/layer-publisher
5+
*/
6+
17
import * as cdk from 'aws-cdk-lib';
28
import { Template } from 'aws-cdk-lib/assertions';
39
import * as LayerPublisher from '../../src/layer-publisher-stack';

Diff for: lerna.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"packages": [
33
"packages/*",
44
"examples/cdk",
5-
"examples/sam"
5+
"examples/sam",
6+
"layer-publisher"
67
],
78
"version": "0.9.0",
89
"npmClient": "npm",

0 commit comments

Comments
 (0)