Skip to content

chore(layers): moved layer-publisher into npm workspace #1292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/scripts/setup_tmp_layer_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
rm -rf tmp/nodejs
mkdir -p tmp/nodejs
cd tmp/nodejs
npm init -y
npm i \
@aws-lambda-powertools/logger@$VERSION \
@aws-lambda-powertools/metrics@$VERSION \
@aws-lambda-powertools/tracer@$VERSION
rm -rf node_modules/@types \
package.json \
package-lock.json
cd ../..
35 changes: 21 additions & 14 deletions .github/workflows/publish_layer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ jobs:
build-layer:
runs-on: ubuntu-latest
if: ${{ (github.event.workflow_run.conclusion == 'success') || (github.event_name == 'workflow_dispatch') }}
defaults:
run:
working-directory: ./layer-publisher
steps:
- name: checkout
uses: actions/checkout@v3
Expand All @@ -41,22 +38,32 @@ jobs:
LATEST_TAG=$(git describe --tag --abbrev=0)
RELEASE_TAG_VERSION=${RELEASE_INPUT:-$LATEST_TAG}
echo "RELEASE_TAG_VERSION=${RELEASE_TAG_VERSION:1}" >> $GITHUB_ENV
- name: install cdk and deps
run: |
npm install -g aws-cdk@2.55.0
cdk --version
- name: install deps
- name: Cache node modules
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: 18-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# We can skip the installation 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: Create layer files
run: |
npm ci
export VERSION=$RELEASE_TAG_VERSION
bash .github/scripts/setup_tmp_layer_files.sh
- name: CDK build
run: cdk synth --context PowerToolsPackageVersion=$RELEASE_TAG_VERSION -o cdk.out
run: npm run cdk -w layers -- synth --context PowertoolsPackageVersion=$RELEASE_TAG_VERSION -o cdk.out
- name: zip output
run: zip -r cdk.out.zip cdk.out
- name: Archive CDK artifacts
uses: actions/upload-artifact@v3
with:
name: cdk-layer-artefact
path: layer-publisher/cdk.out.zip
name: cdk-layer-artifact
path: layers/cdk.out.zip

# Deploy layer to all regions in beta account
deploy-beta:
Expand All @@ -65,7 +72,7 @@ jobs:
uses: ./.github/workflows/reusable_deploy_layer_stack.yml
with:
stage: "BETA"
artefact-name: "cdk-layer-artefact"
artifact-name: "cdk-layer-artifact"
secrets:
target-account-role: ${{ secrets.AWS_LAYERS_BETA_ROLE_ARN }}

Expand All @@ -76,6 +83,6 @@ jobs:
uses: ./.github/workflows/reusable_deploy_layer_stack.yml
with:
stage: "PROD"
artefact-name: "cdk-layer-artefact"
artifact-name: "cdk-layer-artifact"
secrets:
target-account-role: ${{ secrets.AWS_LAYERS_PROD_ROLE_ARN }}
25 changes: 14 additions & 11 deletions .github/workflows/reusable-run-linting-check-and-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ jobs:
runs-on: ubuntu-latest
env:
NODE_ENV: dev
defaults:
run:
working-directory: layer-publisher
steps:
- name: Checkout code
uses: actions/checkout@v3
Expand All @@ -103,17 +100,23 @@ jobs:
id: cache-node-modules
uses: actions/cache@v3
with:
path: "./layer-publisher/node_modules"
# Use the combo between example, name, and SHA-256 hash of the layer-publisher lock files as cache key.
key: cache-layer-publisher-node-modules-${{ hashFiles('./layer-publisher/package-lock.json') }}
- name: Install Layer publisher
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: 18-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# We can skip the installation if there was a cache hit
if: steps.cache-node-modules.outputs.cache-hit != 'true'
run: npm ci
# See https://github.com/npm/cli/issues/4475 to see why --foreground-scripts
run: npm ci --foreground-scripts
- name: Run linting
run: npm run lint
run: npm run lint -w layers
- name: Create layer files
run: |
export VERSION=latest
bash .github/scripts/setup_tmp_layer_files.sh
- name: Run tests
run: npm t
run: npm run test:unit -w layers
check-docs-snippets:
runs-on: ubuntu-latest
env:
Expand Down Expand Up @@ -150,4 +153,4 @@ jobs:
npm run build -w packages/commons
npm run build -w packages/logger & npm run build -w packages/tracer & npm run build -w packages/metrics & npm run build -w packages/parameters & npm run build -w packages/idempotency & npm run build -w docs/snippets
- name: Run linting
run: npm run lint -w packages/commons -w packages/logger -w packages/tracer -w packages/metrics -w packages/parameters -w packages/idempotency -w docs/snippets
run: npm run lint -w docs/snippets
35 changes: 19 additions & 16 deletions .github/workflows/reusable_deploy_layer_stack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:
stage:
required: true
type: string
artefact-name:
artifact-name:
required: true
type: string
secrets:
Expand All @@ -20,9 +20,6 @@ on:
jobs:
deploy-cdk-stack:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./layer-publisher
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -63,19 +60,25 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: "18"
- name: install cdk and deps
run: |
npm install -g aws-cdk@2.55.0
cdk --version
- name: install deps
run: |
npm ci
- name: Cache node modules
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: 18-cache-utilities-node-modules-${{ hashFiles('./package-lock.json') }}
- name: Install dependencies
# We can skip the installation 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: Download artifact
uses: actions/download-artifact@v3
with:
name: ${{ inputs.artefact-name }}
path: layer-publisher
- name: unzip artefact
name: ${{ inputs.artifact-name }}
path: layers
- name: Unzip artifact
run: unzip cdk.out.zip
- name: CDK Deploy Layer
run: cdk deploy --app cdk.out --context region=${{ matrix.region }} 'LayerPublisherStack' --require-approval never --verbose
- name: Deploy Layer
run: npm run cdk -w layers -- deploy --app cdk.out --context region=${{ matrix.region }} 'LayerPublisherStack' --require-approval never --verbose
9 changes: 5 additions & 4 deletions .github/workflows/run-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ jobs:
if: steps.cache-node-modules.outputs.cache-hit == 'true'
run: |
npm run build -w packages/commons
- name: Run integration test on layers
- name: Create layer files
run: |
npm ci --foreground-scripts
RUNTIME=nodejs${{ matrix.version }}.x npm run test:e2e
working-directory: layer-publisher
export VERSION=latest
bash .github/scripts/setup_tmp_layer_files.sh
- name: Run integration test on layers
run: RUNTIME=nodejs${{ matrix.version }}.x npm run test:e2e -w layers
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ site

# SAM Example copies files
/examples/sam/src/handlers/*
!/examples/sam/src/handlers/COPY_LAMBDA_FUNCTIONS_HERE
!/examples/sam/src/handlers/COPY_LAMBDA_FUNCTIONS_HERE

# Layer temp files
tmp
4 changes: 1 addition & 3 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ npm run lint-fix -ws
cd examples/sam && npm run lint-fix
cd ../..
cd examples/cdk && npm run lint-fix
cd ../..
cd layer-publisher && npm run lint-fix
cd ..
cd ../..
8 changes: 7 additions & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm t -ws
npm t \
-w packages/commons && \
-w packages/logger && \
-w packages/metrics && \
-w packages/tracer && \
-w packages/idempotency && \
-w packages/parameters
8 changes: 0 additions & 8 deletions layer-publisher/jest.config.js

This file was deleted.

Loading