diff --git a/.github/workflows/run-e2e-tests.yml b/.github/workflows/run-e2e-tests.yml index 6ba30c5d5f..e5c4c27b0a 100644 --- a/.github/workflows/run-e2e-tests.yml +++ b/.github/workflows/run-e2e-tests.yml @@ -81,20 +81,40 @@ jobs: matrix: version: [12, 14, 16] steps: - - name: "Checkout" + - name: Checkout uses: actions/checkout@v3 - - name: "Use NodeJS 14" + - name: Use NodeJS uses: actions/setup-node@v3 with: # Always use version 16 as we use TypeScript target es2020 node-version: 16 - - name: "Install npm@8.x" + - name: Install npm@8.x run: npm i -g npm@next-8 - name: "Configure AWS credentials" uses: aws-actions/configure-aws-credentials@v1.6.1 with: role-to-assume: ${{ secrets.AWS_ROLE_ARN_TO_ASSUME }} aws-region: eu-west-1 + - name: Cache node modules for commons + id: cache-node-modules + uses: actions/cache@v3 + with: + path: "./node_modules" + # Use the combo between node version, name, and SHA-256 hash of the lock file as cache key so that + # if one of them changes the cache is invalidated/discarded + key: ${{ matrix.version }}-cache-utils-node-modules-${{ hashFiles('./package-lock.json') }} + - name: Install dependencies + # We can skip the install if there was a cache hit + if: steps.cache-node-modules.outputs.cache-hit != 'true' + # See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts + run: npm ci --foreground-scripts + - name: Build packages + # If there's a cache hit we still need to manually build the packages + # this would otherwise have been done automatically as a part of the + # postinstall npm hook + if: steps.cache-node-modules.outputs.cache-hit == 'true' + run: | + npm run build -w packages/commons - name: "Run layer integration tests" run: | npm ci --foreground-scripts diff --git a/layer-publisher/tests/e2e/happy-case.test.lambda.ts b/layer-publisher/tests/e2e/happy-case.test.lambda.ts index 801a9bccb0..db91d2724b 100644 --- a/layer-publisher/tests/e2e/happy-case.test.lambda.ts +++ b/layer-publisher/tests/e2e/happy-case.test.lambda.ts @@ -1,7 +1,6 @@ import { Logger } from '@aws-lambda-powertools/logger'; import { Metrics } from '@aws-lambda-powertools/metrics'; import { Tracer } from '@aws-lambda-powertools/tracer'; -import { Context } from 'aws-lambda'; import fs from 'fs'; const SERVICE_NAME = 'e2e-tests-layer-consumer'; @@ -9,7 +8,7 @@ const logger = new Logger({ serviceName: SERVICE_NAME, logLevel: 'DEBUG' }); const metrics = new Metrics({ serviceName: SERVICE_NAME }); const tracer = new Tracer({ serviceName: SERVICE_NAME }); -exports.handler = function (_event: never, _ctx: Context): void { +exports.handler = function (_event: never, _ctx: unknown): void { // check logger lib access logger.injectLambdaContext(); logger.debug('Hello World!'); diff --git a/layer-publisher/tests/e2e/happy-case.test.ts b/layer-publisher/tests/e2e/happy-case.test.ts index 2b1e0ce69b..7bdc2c6234 100644 --- a/layer-publisher/tests/e2e/happy-case.test.ts +++ b/layer-publisher/tests/e2e/happy-case.test.ts @@ -26,7 +26,7 @@ const layerStack = new LayerPublisher.LayerPublisherStack( { layerName: `e2e-tests-layer-${runtime.name.split('.')[0]}`, powerToolsPackageVersion: powerToolsPackageVersion, - ssmParameterLayerArn: '/e2e-tests-layertools-layer-arn', + ssmParameterLayerArn: `/e2e-tests-layertools-layer-arn-${runtime.name.split('.')[0]}`, } ); @@ -70,6 +70,14 @@ const createSampleLambda = (runtime: cdk.aws_lambda.Runtime): { consumerStack: c handler: 'handler', functionName, runtime: runtime, + bundling: { + externalModules: [ + '@aws-lambda-powertools/commons', + '@aws-lambda-powertools/logger', + '@aws-lambda-powertools/metrics', + '@aws-lambda-powertools/tracer' + ] + }, environment: { POWERTOOLS_PACKAGE_VERSION: powerToolsPackageVersion, },