From 24c525dacfa92ea81ed0410da68fcf828850feb3 Mon Sep 17 00:00:00 2001 From: Bryan English Date: Mon, 11 Nov 2024 15:53:30 -0500 Subject: [PATCH] add ESM tests to lib-injection tests --- .github/workflows/run-lib-injection.yml | 7 ++++++- .../build/docker/nodejs/sample-app-esm-20/Dockerfile | 9 +++++++++ .../build/docker/nodejs/sample-app-esm-20/build.sh | 7 +++++++ .../build/docker/nodejs/sample-app-esm-20/index.mjs | 11 +++++++++++ .../build/docker/nodejs/sample-app-esm-22/Dockerfile | 9 +++++++++ .../build/docker/nodejs/sample-app-esm-22/build.sh | 7 +++++++ .../build/docker/nodejs/sample-app-esm-22/index.mjs | 11 +++++++++++ 7 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 lib-injection/build/docker/nodejs/sample-app-esm-20/Dockerfile create mode 100755 lib-injection/build/docker/nodejs/sample-app-esm-20/build.sh create mode 100644 lib-injection/build/docker/nodejs/sample-app-esm-20/index.mjs create mode 100644 lib-injection/build/docker/nodejs/sample-app-esm-22/Dockerfile create mode 100755 lib-injection/build/docker/nodejs/sample-app-esm-22/build.sh create mode 100644 lib-injection/build/docker/nodejs/sample-app-esm-22/index.mjs diff --git a/.github/workflows/run-lib-injection.yml b/.github/workflows/run-lib-injection.yml index 9b44d08997..342fa1b996 100644 --- a/.github/workflows/run-lib-injection.yml +++ b/.github/workflows/run-lib-injection.yml @@ -42,7 +42,12 @@ jobs: "dotnet": [{"name":"dd-lib-dotnet-init-test-app","supported":"true"}], "golang": [], "java": [{"name":"dd-lib-java-init-test-app","supported":"true"},{"name":"jdk7-app","supported":"false"}], - "nodejs": [{"name":"sample-app","supported":"true"},{"name":"sample-app-node13","supported":"false"}], + "nodejs": [ + {"name":"sample-app","supported":"true"}, + {"name":"sample-app-esm-20","supported":"true"}, + {"name":"sample-app-esm-22","supported":"true"}, + {"name":"sample-app-node13","supported":"false"} + ], "php": [], "python": [{"name":"dd-lib-python-init-test-django","supported":"true"}, {"name":"dd-lib-python-init-test-django-gunicorn", "supported":"true"}, diff --git a/lib-injection/build/docker/nodejs/sample-app-esm-20/Dockerfile b/lib-injection/build/docker/nodejs/sample-app-esm-20/Dockerfile new file mode 100644 index 0000000000..ac2cf60fa3 --- /dev/null +++ b/lib-injection/build/docker/nodejs/sample-app-esm-20/Dockerfile @@ -0,0 +1,9 @@ +FROM node:20.0.0 + +# Create app directory +WORKDIR /usr/src/app + +COPY . . + +EXPOSE 18080 +CMD [ "node", "index.mjs" ] diff --git a/lib-injection/build/docker/nodejs/sample-app-esm-20/build.sh b/lib-injection/build/docker/nodejs/sample-app-esm-20/build.sh new file mode 100755 index 0000000000..9c2b6dc9f2 --- /dev/null +++ b/lib-injection/build/docker/nodejs/sample-app-esm-20/build.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [ -z "${BUILDX_PLATFORMS}" ] ; then + BUILDX_PLATFORMS=`docker buildx imagetools inspect --raw python:3.12 | jq -r 'reduce (.manifests[] | [ .platform.os, .platform.architecture, .platform.variant ] | join("/") | sub("\\/$"; "")) as $item (""; . + "," + $item)' | sed 's/,//'` +fi +echo "Build for platforms: ${BUILDX_PLATFORMS}" +docker buildx build --platform ${BUILDX_PLATFORMS} --tag ${LIBRARY_INJECTION_TEST_APP_IMAGE} --push . \ No newline at end of file diff --git a/lib-injection/build/docker/nodejs/sample-app-esm-20/index.mjs b/lib-injection/build/docker/nodejs/sample-app-esm-20/index.mjs new file mode 100644 index 0000000000..3084f3bd6c --- /dev/null +++ b/lib-injection/build/docker/nodejs/sample-app-esm-20/index.mjs @@ -0,0 +1,11 @@ +process.on('SIGTERM', (signal) => { + process.exit(0); +}); + +import { createServer } from 'http'; + +createServer((req, res) => { + res.end('Hello, world!\n') +}).listen(18080, () => { + console.log('listening on port 18080') // eslint-disable-line no-console +}) diff --git a/lib-injection/build/docker/nodejs/sample-app-esm-22/Dockerfile b/lib-injection/build/docker/nodejs/sample-app-esm-22/Dockerfile new file mode 100644 index 0000000000..bdc0e3ab42 --- /dev/null +++ b/lib-injection/build/docker/nodejs/sample-app-esm-22/Dockerfile @@ -0,0 +1,9 @@ +FROM node:22 + +# Create app directory +WORKDIR /usr/src/app + +COPY . . + +EXPOSE 18080 +CMD [ "node", "index.mjs" ] diff --git a/lib-injection/build/docker/nodejs/sample-app-esm-22/build.sh b/lib-injection/build/docker/nodejs/sample-app-esm-22/build.sh new file mode 100755 index 0000000000..9c2b6dc9f2 --- /dev/null +++ b/lib-injection/build/docker/nodejs/sample-app-esm-22/build.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [ -z "${BUILDX_PLATFORMS}" ] ; then + BUILDX_PLATFORMS=`docker buildx imagetools inspect --raw python:3.12 | jq -r 'reduce (.manifests[] | [ .platform.os, .platform.architecture, .platform.variant ] | join("/") | sub("\\/$"; "")) as $item (""; . + "," + $item)' | sed 's/,//'` +fi +echo "Build for platforms: ${BUILDX_PLATFORMS}" +docker buildx build --platform ${BUILDX_PLATFORMS} --tag ${LIBRARY_INJECTION_TEST_APP_IMAGE} --push . \ No newline at end of file diff --git a/lib-injection/build/docker/nodejs/sample-app-esm-22/index.mjs b/lib-injection/build/docker/nodejs/sample-app-esm-22/index.mjs new file mode 100644 index 0000000000..3084f3bd6c --- /dev/null +++ b/lib-injection/build/docker/nodejs/sample-app-esm-22/index.mjs @@ -0,0 +1,11 @@ +process.on('SIGTERM', (signal) => { + process.exit(0); +}); + +import { createServer } from 'http'; + +createServer((req, res) => { + res.end('Hello, world!\n') +}).listen(18080, () => { + console.log('listening on port 18080') // eslint-disable-line no-console +})