Skip to content

Commit

Permalink
feat: Prepared for Node 20 support
Browse files Browse the repository at this point in the history
Signed-off-by: mrickard <maurice@mauricerickard.com>
  • Loading branch information
mrickard committed Nov 16, 2023
1 parent 4c9d718 commit 432da66
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
23 changes: 23 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ jobs:
name: Publish layer
command: make publish-nodejs18x-ci

publish-nodejs20x:
docker:
- image: cimg/node:20.4.0
steps:
- checkout
- setup_remote_docker
- run:
name: Node 20 unit tests
command: cd nodejs && npm install && npm run test
- run:
name: Publish layer
command: make publish-nodejs20x-ci

publish-python37:
docker:
- image: cimg/python:3.7
Expand Down Expand Up @@ -167,6 +180,16 @@ workflows:
- codecov/upload:
file: ./nodejs/coverage/unit/lcov.info
flags: nodejs-18-unit
- publish-nodejs20x:
filters:
branches:
ignore: /.*/
tags:
only: /v[0-9]+(\.[0-9]+)*_nodejs/
post-steps:
- codecov/upload:
file: ./nodejs/coverage/unit/lcov.info
flags: nodejs-20-unit
- publish-python37:
filters:
branches:
Expand Down
6 changes: 6 additions & 0 deletions libBuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ function layer_name_str() {
"nodejs18.x")
rt_part="NodeJS18X"
;;
"nodejs20.x")
rt_part="NodeJS20X"
;;
esac

case $2 in
Expand Down Expand Up @@ -164,6 +167,9 @@ function s3_prefix() {
"nodejs18.x")
name="nr-nodejs18.x"
;;
"nodejs20.x")
name="nr-nodejs20.x"
;;
esac

echo $name
Expand Down
64 changes: 63 additions & 1 deletion nodejs/publish-layers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ source ../libBuild.sh

NJS16X_DIST_ARM64=$DIST_DIR/nodejs16x.arm64.zip
NJS18X_DIST_ARM64=$DIST_DIR/nodejs18x.arm64.zip
NJS20X_DIST_ARM64=$DIST_DIR/nodejs20x.arm64.zip

NJS16X_DIST_X86_64=$DIST_DIR/nodejs16x.x86_64.zip
NJS18X_DIST_X86_64=$DIST_DIR/nodejs18x.x86_64.zip
NJS20X_DIST_X86_64=$DIST_DIR/nodejs20x.x86_64.zip

function usage {
echo "./publish-layers.sh [nodejs16x|nodejs18x]"
echo "./publish-layers.sh [nodejs16x|nodejs18x|nodejs20x]"
}

function build-nodejs16x-arm64 {
Expand Down Expand Up @@ -113,6 +115,54 @@ function publish-nodejs18x-x86 {
done
}

function build-nodejs20x-arm64 {
echo "Building new relic layer for nodejs20.x (arm64)"
rm -rf $BUILD_DIR $NJS20X_DIST_ARM64
mkdir -p $DIST_DIR
npm install --prefix $BUILD_DIR newrelic@latest
mkdir -p $BUILD_DIR/node_modules/newrelic-lambda-wrapper
cp index.js $BUILD_DIR/node_modules/newrelic-lambda-wrapper
download_extension arm64
zip -rq $NJS20X_DIST_ARM64 $BUILD_DIR $EXTENSION_DIST_DIR $EXTENSION_DIST_PREVIEW_FILE
rm -rf $BUILD_DIR $EXTENSION_DIST_DIR $EXTENSION_DIST_PREVIEW_FILE
echo "Build complete: ${NJS20X_DIST_ARM64}"
}

function build-nodejs20x-x86 {
echo "Building new relic layer for nodejs20.x (x86_64)"
rm -rf $BUILD_DIR $NJS20X_DIST_X86_64
mkdir -p $DIST_DIR
npm install --prefix $BUILD_DIR newrelic@latest
mkdir -p $BUILD_DIR/node_modules/newrelic-lambda-wrapper
cp index.js $BUILD_DIR/node_modules/newrelic-lambda-wrapper
download_extension x86_64
zip -rq $NJS20X_DIST_X86_64 $BUILD_DIR $EXTENSION_DIST_DIR $EXTENSION_DIST_PREVIEW_FILE
rm -rf $BUILD_DIR $EXTENSION_DIST_DIR $EXTENSION_DIST_PREVIEW_FILE
echo "Build complete: ${NJS20X_DIST_X86_64}"
}

function publish-nodejs20x-arm64 {
if [ ! -f $NJS20X_DIST_ARM64 ]; then
echo "Package not found: ${NJS20X_DIST_ARM64}"
exit 1
fi

for region in "${REGIONS_ARM[@]}"; do
publish_layer $NJS20X_DIST_ARM64 $region nodejs20.x arm64
done
}

function publish-nodejs20x-x86 {
if [ ! -f $NJS20X_DIST_X86_64 ]; then
echo "Package not found: ${NJS20X_DIST_X86_64}"
exit 1
fi

for region in "${REGIONS_X86[@]}"; do
publish_layer $NJS20X_DIST_X86_64 $region nodejs20.x x86_64
done
}

case "$1" in
"build-nodejs16x")
build-nodejs16x-arm64
Expand All @@ -130,6 +180,14 @@ case "$1" in
publish-nodejs18x-arm64
publish-nodejs18x-x86
;;
"build-nodejs20x")
build-nodejs20x-arm64
build-nodejs20x-x86
;;
"publish-nodejs20x")
publish-nodejs20x-arm64
publish-nodejs20x-x86
;;
"nodejs16x")
$0 build-nodejs16x
$0 publish-nodejs16x
Expand All @@ -138,6 +196,10 @@ case "$1" in
$0 build-nodejs18x
$0 publish-nodejs18x
;;
"nodejs20x")
$0 build-nodejs20x
$0 publish-nodejs20x
;;
*)
usage
;;
Expand Down

0 comments on commit 432da66

Please sign in to comment.