Skip to content

Commit

Permalink
feat: Strip minor version in test builds instead of ci to avoid renam…
Browse files Browse the repository at this point in the history
…ing the zip
  • Loading branch information
astuyve committed Mar 8, 2024
1 parent fa5d9e8 commit 4a85c3a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ci/input_files/build.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ build-layer ({{ $runtime.name }}):
variables:
CI_ENABLE_CONTAINER_IMAGE_BUILDS: "true"
script:
- NODE_VERSION={{ $runtime.node_major_version }} ./scripts/build_layers.sh
- NODE_VERSION={{ $runtime.node_version }} ./scripts/build_layers.sh

check-layer-size ({{ $runtime.name }}):
stage: test
Expand Down
6 changes: 3 additions & 3 deletions scripts/build_layers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -e
LAYER_DIR=".layers"
LAYER_FILES_PREFIX="datadog_lambda_node"

export NODE_VERSIONS=("16" "18" "20")
export NODE_VERSIONS=("16.14" "18.12" "20.9")

if [ -z "$NODE_VERSION" ]; then
echo "Node version not specified, running for all node versions."
Expand All @@ -33,12 +33,12 @@ function docker_build_zip {
# Args: [node version] [zip destination]

destination=$(make_path_absolute $2)

node_image_version=$(echo $1 | cut -d '.' -f 1)
# Install datadog node in a docker container to avoid the mess from switching
# between different node runtimes.
temp_dir=$(mktemp -d)
docker buildx build -t datadog-lambda-layer-node:$1 . --no-cache \
--build-arg image=registry.ddbuild.io/images/mirror/node:$1-bullseye --progress=plain -o $temp_dir/nodejs
--build-arg image=registry.ddbuild.io/images/mirror/node:$node_image_version-bullseye --progress=plain -o $temp_dir/nodejs

# Zip to destination, and keep directory structure as based in $temp_dir
(cd $temp_dir && zip -q -r $destination ./)
Expand Down
4 changes: 3 additions & 1 deletion scripts/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@
# Copyright 2019 Datadog, Inc.

# Run unit tests in Docker
# For local use only
set -e

NODE_VERSIONS=("16.14" "18.12" "20.9")

for node_version in "${NODE_VERSIONS[@]}"
do
node_major_version=$(echo $node_version | cut -d '.' -f 1)
echo "Running tests against node${node_version}"
docker build -t datadog-lambda-layer-node-test:$node_version \
-f scripts/Dockerfile_test . \
--quiet \
--build-arg image=registry.ddbuild.io/images/mirror/node:$node_version-bullseye
--build-arg image=registry.ddbuild.io/images/mirror/node:$node_major_version-bullseye
docker run --rm -v `pwd`:/datadog-lambda-layer-node \
-w /datadog-lambda-layer-node \
datadog-lambda-layer-node-test:$node_version \
Expand Down

0 comments on commit 4a85c3a

Please sign in to comment.