From 7296bef62feebff767b1f1886e698a15295538f2 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Wed, 10 Aug 2022 16:20:58 +0200 Subject: [PATCH 1/5] fix: added dependency install for commons --- .github/workflows/pr_lint_and_test.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr_lint_and_test.yml b/.github/workflows/pr_lint_and_test.yml index 8ca59e6c32..3d88d642b9 100644 --- a/.github/workflows/pr_lint_and_test.yml +++ b/.github/workflows/pr_lint_and_test.yml @@ -95,7 +95,27 @@ jobs: with: node-version: 16 cache: "npm" - - name: Cache node modules + - 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: 16-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: Cache node modules for layers id: cache-node-modules uses: actions/cache@v3 with: From eb2d9fd30c4a223d13f0cc6cb38ba17284f98987 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Wed, 10 Aug 2022 16:29:28 +0200 Subject: [PATCH 2/5] fix: added dependency install for commons --- .github/workflows/pr_lint_and_test.yml | 22 +--------------------- .github/workflows/run-e2e-tests.yml | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/pr_lint_and_test.yml b/.github/workflows/pr_lint_and_test.yml index 3d88d642b9..8ca59e6c32 100644 --- a/.github/workflows/pr_lint_and_test.yml +++ b/.github/workflows/pr_lint_and_test.yml @@ -95,27 +95,7 @@ jobs: with: node-version: 16 cache: "npm" - - 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: 16-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: Cache node modules for layers + - name: Cache node modules id: cache-node-modules uses: actions/cache@v3 with: diff --git a/.github/workflows/run-e2e-tests.yml b/.github/workflows/run-e2e-tests.yml index 6ba30c5d5f..33f780e509 100644 --- a/.github/workflows/run-e2e-tests.yml +++ b/.github/workflows/run-e2e-tests.yml @@ -95,6 +95,26 @@ jobs: 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: 16-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 From 6e00401c1baf6d2021793b421218b5ca048afcfe Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Wed, 10 Aug 2022 16:42:34 +0200 Subject: [PATCH 3/5] fix: made ssmParam name unique --- layer-publisher/tests/e2e/happy-case.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layer-publisher/tests/e2e/happy-case.test.ts b/layer-publisher/tests/e2e/happy-case.test.ts index 2b1e0ce69b..2512d730d4 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]}`, } ); From badefeed4c3dab6a8996800afab7e1a826836f76 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Wed, 10 Aug 2022 16:52:48 +0200 Subject: [PATCH 4/5] chore: made PT packages external since they are in the layer --- .github/workflows/run-e2e-tests.yml | 2 +- layer-publisher/tests/e2e/happy-case.test.lambda.ts | 3 +-- layer-publisher/tests/e2e/happy-case.test.ts | 8 ++++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-e2e-tests.yml b/.github/workflows/run-e2e-tests.yml index 33f780e509..759cfa892a 100644 --- a/.github/workflows/run-e2e-tests.yml +++ b/.github/workflows/run-e2e-tests.yml @@ -102,7 +102,7 @@ jobs: 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: 16-cache-utils-node-modules-${{ hashFiles('./package-lock.json') }} + 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' 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 2512d730d4..7bdc2c6234 100644 --- a/layer-publisher/tests/e2e/happy-case.test.ts +++ b/layer-publisher/tests/e2e/happy-case.test.ts @@ -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, }, From 0f04f7a59dada8528f843237a97fafec21dd5351 Mon Sep 17 00:00:00 2001 From: Andrea Amorosi Date: Wed, 10 Aug 2022 17:05:20 +0200 Subject: [PATCH 5/5] chore: fixed steps names --- .github/workflows/run-e2e-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/run-e2e-tests.yml b/.github/workflows/run-e2e-tests.yml index 759cfa892a..e5c4c27b0a 100644 --- a/.github/workflows/run-e2e-tests.yml +++ b/.github/workflows/run-e2e-tests.yml @@ -81,14 +81,14 @@ 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