Skip to content

Commit a0f1db2

Browse files
authored
Fix(build): e2e workflow failing (aws-powertools#1047)
* fix: added dependency install for commons * fix: added dependency install for commons * fix: made ssmParam name unique * chore: made PT packages external since they are in the layer * chore: fixed steps names
1 parent 5ebd1cf commit a0f1db2

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

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

+23-3
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,40 @@ jobs:
8181
matrix:
8282
version: [12, 14, 16]
8383
steps:
84-
- name: "Checkout"
84+
- name: Checkout
8585
uses: actions/checkout@v3
86-
- name: "Use NodeJS 14"
86+
- name: Use NodeJS
8787
uses: actions/setup-node@v3
8888
with:
8989
# Always use version 16 as we use TypeScript target es2020
9090
node-version: 16
91-
- name: "Install [email protected]"
91+
- name: Install [email protected]
9292
run: npm i -g npm@next-8
9393
- name: "Configure AWS credentials"
9494
uses: aws-actions/[email protected]
9595
with:
9696
role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }}
9797
aws-region: eu-west-1
98+
- name: Cache node modules for commons
99+
id: cache-node-modules
100+
uses: actions/cache@v3
101+
with:
102+
path: "./node_modules"
103+
# Use the combo between node version, name, and SHA-256 hash of the lock file as cache key so that
104+
# if one of them changes the cache is invalidated/discarded
105+
key: ${{ matrix.version }}-cache-utils-node-modules-${{ hashFiles('./package-lock.json') }}
106+
- name: Install dependencies
107+
# We can skip the install if there was a cache hit
108+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
109+
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
110+
run: npm ci --foreground-scripts
111+
- name: Build packages
112+
# If there's a cache hit we still need to manually build the packages
113+
# this would otherwise have been done automatically as a part of the
114+
# postinstall npm hook
115+
if: steps.cache-node-modules.outputs.cache-hit == 'true'
116+
run: |
117+
npm run build -w packages/commons
98118
- name: "Run layer integration tests"
99119
run: |
100120
npm ci --foreground-scripts

layer-publisher/tests/e2e/happy-case.test.lambda.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { Logger } from '@aws-lambda-powertools/logger';
22
import { Metrics } from '@aws-lambda-powertools/metrics';
33
import { Tracer } from '@aws-lambda-powertools/tracer';
4-
import { Context } from 'aws-lambda';
54
import fs from 'fs';
65

76
const SERVICE_NAME = 'e2e-tests-layer-consumer';
87
const logger = new Logger({ serviceName: SERVICE_NAME, logLevel: 'DEBUG' });
98
const metrics = new Metrics({ serviceName: SERVICE_NAME });
109
const tracer = new Tracer({ serviceName: SERVICE_NAME });
1110

12-
exports.handler = function (_event: never, _ctx: Context): void {
11+
exports.handler = function (_event: never, _ctx: unknown): void {
1312
// check logger lib access
1413
logger.injectLambdaContext();
1514
logger.debug('Hello World!');

layer-publisher/tests/e2e/happy-case.test.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const layerStack = new LayerPublisher.LayerPublisherStack(
2626
{
2727
layerName: `e2e-tests-layer-${runtime.name.split('.')[0]}`,
2828
powerToolsPackageVersion: powerToolsPackageVersion,
29-
ssmParameterLayerArn: '/e2e-tests-layertools-layer-arn',
29+
ssmParameterLayerArn: `/e2e-tests-layertools-layer-arn-${runtime.name.split('.')[0]}`,
3030
}
3131
);
3232

@@ -70,6 +70,14 @@ const createSampleLambda = (runtime: cdk.aws_lambda.Runtime): { consumerStack: c
7070
handler: 'handler',
7171
functionName,
7272
runtime: runtime,
73+
bundling: {
74+
externalModules: [
75+
'@aws-lambda-powertools/commons',
76+
'@aws-lambda-powertools/logger',
77+
'@aws-lambda-powertools/metrics',
78+
'@aws-lambda-powertools/tracer'
79+
]
80+
},
7381
environment: {
7482
POWERTOOLS_PACKAGE_VERSION: powerToolsPackageVersion,
7583
},

0 commit comments

Comments
 (0)