From e354b5e32b5176ccf84da5436c0798f0f9ef610d Mon Sep 17 00:00:00 2001 From: Olivier John Ndjike Nzia Date: Tue, 5 May 2026 10:18:11 -0400 Subject: [PATCH 1/7] build layer using dd-trace branch --- .gitlab/scripts/build_layer.sh | 4 +++- Dockerfile | 14 +++++++++++++- scripts/build_layers.sh | 6 ++++-- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/.gitlab/scripts/build_layer.sh b/.gitlab/scripts/build_layer.sh index 36a2d24..fe548cc 100755 --- a/.gitlab/scripts/build_layer.sh +++ b/.gitlab/scripts/build_layer.sh @@ -37,6 +37,7 @@ function docker_build_zip { destination=$(make_path_absolute $2) arch=$3 + ref=$4 # Install datadog ruby in a docker container to avoid the mess from switching # between different ruby runtimes. @@ -44,6 +45,7 @@ function docker_build_zip { docker buildx build -t datadog-lambda-ruby-${arch}:$1 . --no-cache \ --build-arg "image=ruby:${1}" \ --build-arg "runtime=${1}.0" \ + --build-arg "git_ref=${ref}" \ --platform linux/${arch} \ --progress=plain \ -o $temp_dir @@ -59,7 +61,7 @@ rm -rf $LAYER_DIR mkdir $LAYER_DIR echo "Building layer for Ruby $RUBY_VERSION with architecture $ARCH" -docker_build_zip $RUBY_VERSION $LAYER_DIR/${LAYER_FILES_PREFIX}-${ARCH}-${RUBY_VERSION}.zip $ARCH +docker_build_zip $RUBY_VERSION $LAYER_DIR/${LAYER_FILES_PREFIX}-${ARCH}-${RUBY_VERSION}.zip $ARCH $GIT_REF echo "Done creating layers:" ls $LAYER_DIR | xargs -I _ echo "$LAYER_DIR/_" diff --git a/Dockerfile b/Dockerfile index d6e2867..0346dc4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,9 @@ ARG image FROM $image AS builder +ARG git_ref ARG runtime +RUN echo "git_ref:" +RUN echo $git_ref # Install dev dependencies COPY . /var/task/datadog-lambda-rb WORKDIR /var/task/datadog-lambda-rb @@ -12,7 +15,16 @@ RUN gem build datadog-lambda # Install ddtrace gem RUN gem install datadog-lambda --install-dir "/opt/ruby/gems/$runtime" -RUN gem install datadog -v 2.12 --install-dir "/opt/ruby/gems/$runtime" +RUN set -eux; \ + if [ -z "${git_ref:-}" ]; then \ + gem install datadog -v 2.12 --install-dir "/opt/ruby/gems/$runtime"; \ + else \ + git clone https://github.com/DataDog/dd-trace-rb.git /tmp/dd-trace-rb; \ + cd /tmp/dd-trace-rb; \ + git checkout "$git_ref"; \ + gem build datadog.gemspec; \ + gem install ./datadog-*.gem --install-dir "/opt/ruby/gems/$runtime"; \ + fi WORKDIR /opt # Remove native extension debase-ruby_core_source (25MB) runtimes below Ruby 2.6 diff --git a/scripts/build_layers.sh b/scripts/build_layers.sh index 304b334..086992d 100755 --- a/scripts/build_layers.sh +++ b/scripts/build_layers.sh @@ -33,6 +33,7 @@ function docker_build_zip { destination=$(make_path_absolute $2) arch=$3 + ref=$4 # Install datadog ruby in a docker container to avoid the mess from switching # between different ruby runtimes. @@ -40,6 +41,7 @@ function docker_build_zip { docker buildx build -t datadog-lambda-ruby-${arch}:$1 . --no-cache \ --build-arg "image=ruby:${1}" \ --build-arg "runtime=${1}.0" \ + --build-arg "git_ref=${ref}" \ --platform linux/${arch} \ --progress=plain \ -o $temp_dir @@ -57,10 +59,10 @@ mkdir $LAYER_DIR for ruby_version in "${RUBY_VERSIONS[@]}" do echo "Building layer for Ruby ${ruby_version} arch=arm64" - docker_build_zip ${ruby_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-arm64-${ruby_version}.zip arm64 + docker_build_zip ${ruby_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-arm64-${ruby_version}.zip arm64 $GIT_REF echo "Building layer for Ruby ${ruby_version} arch=amd64" - docker_build_zip ${ruby_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-amd64-${ruby_version}.zip amd64 + docker_build_zip ${ruby_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-amd64-${ruby_version}.zip amd64 $GIT_REF done From dfd578efb7154ab77d6ee767e4a0725540a741a9 Mon Sep 17 00:00:00 2001 From: Olivier John Ndjike Nzia Date: Thu, 7 May 2026 23:30:01 -0400 Subject: [PATCH 2/7] only clone 1 branch --- Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0346dc4..09d753e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,9 +19,8 @@ RUN set -eux; \ if [ -z "${git_ref:-}" ]; then \ gem install datadog -v 2.12 --install-dir "/opt/ruby/gems/$runtime"; \ else \ - git clone https://github.com/DataDog/dd-trace-rb.git /tmp/dd-trace-rb; \ + git clone https://github.com/DataDog/dd-trace-rb.git --depth 1 --single-branch -b $git_ref /tmp/dd-trace-rb; \ cd /tmp/dd-trace-rb; \ - git checkout "$git_ref"; \ gem build datadog.gemspec; \ gem install ./datadog-*.gem --install-dir "/opt/ruby/gems/$runtime"; \ fi From 01029bd0f0311523b309945b815aa196a544ea1e Mon Sep 17 00:00:00 2001 From: Olivier John Ndjike Nzia Date: Thu, 7 May 2026 23:30:15 -0400 Subject: [PATCH 3/7] add gitlab variables --- .gitlab/template.yaml.tpl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.gitlab/template.yaml.tpl b/.gitlab/template.yaml.tpl index 1c91ae5..a04123b 100644 --- a/.gitlab/template.yaml.tpl +++ b/.gitlab/template.yaml.tpl @@ -1,6 +1,12 @@ variables: CI_DOCKER_TARGET_IMAGE: registry.ddbuild.io/ci/datadog-lambda-rb CI_DOCKER_TARGET_VERSION: latest + GIT_REF: + description: branch/ref of dd-trace-rb to build the layer from. leave empty to use the latest release + value: + UPDATE_SNAPSHOTS: + description: whether or not to create new snapshots + value: false stages: - build From 8bbc067683ec975d6d45917aeb4acecc5522cb91 Mon Sep 17 00:00:00 2001 From: Olivier John Ndjike Nzia Date: Wed, 13 May 2026 14:26:28 -0500 Subject: [PATCH 4/7] add git_ref variables --- .gitlab-ci.yml | 6 ++++++ .gitlab/template.yaml.tpl | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1b274c4..ed44447 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,12 @@ variables: DOCKER_TARGET_IMAGE: registry.ddbuild.io/ci/datadog-lambda-rb DOCKER_TARGET_VERSION: latest + GIT_REF: + description: branch/ref of dd-trace-rb to build the layer from. leave empty to use the latest release + value: "" + UPDATE_SNAPSHOTS: + description: whether or not to create new snapshots + value: "false" stages: - pre diff --git a/.gitlab/template.yaml.tpl b/.gitlab/template.yaml.tpl index a04123b..1c91ae5 100644 --- a/.gitlab/template.yaml.tpl +++ b/.gitlab/template.yaml.tpl @@ -1,12 +1,6 @@ variables: CI_DOCKER_TARGET_IMAGE: registry.ddbuild.io/ci/datadog-lambda-rb CI_DOCKER_TARGET_VERSION: latest - GIT_REF: - description: branch/ref of dd-trace-rb to build the layer from. leave empty to use the latest release - value: - UPDATE_SNAPSHOTS: - description: whether or not to create new snapshots - value: false stages: - build From 72e4b86bc20115ea69c8797884c5b427c3801b5c Mon Sep 17 00:00:00 2001 From: Olivier John Ndjike Nzia Date: Wed, 13 May 2026 16:28:29 -0500 Subject: [PATCH 5/7] add artifacts --- .gitlab/template.yaml.tpl | 8 +++++++- Dockerfile | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitlab/template.yaml.tpl b/.gitlab/template.yaml.tpl index 1c91ae5..2074a0e 100644 --- a/.gitlab/template.yaml.tpl +++ b/.gitlab/template.yaml.tpl @@ -63,11 +63,17 @@ integration test ({{ $runtime.ruby_version }}, {{ $runtime.arch }}): stage: test tags: ["arch:amd64"] image: ${CI_DOCKER_TARGET_IMAGE}:${CI_DOCKER_TARGET_VERSION} - needs: + needs: - build layer ({{ $runtime.ruby_version }}, {{ $runtime.arch }}) dependencies: - build layer ({{ $runtime.ruby_version }}, {{ $runtime.arch }}) cache: &{{ $runtime.name }}-{{ $runtime.arch }}-cache + artifacts: + when: always + expire_in: 1 week + name: snapshots-{{ $runtime.ruby_version }}-{{ $runtime.arch }}-${CI_JOB_ID} + paths: + - integration_tests/snapshots/ before_script: - EXTERNAL_ID_NAME=integration-test-externalid ROLE_TO_ASSUME=sandbox-integration-test-deployer AWS_ACCOUNT=425362996713 source .gitlab/scripts/get_secrets.sh - cd integration_tests && yarn install && cd .. diff --git a/Dockerfile b/Dockerfile index 09d753e..73dee08 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,7 @@ RUN set -eux; \ if [ -z "${git_ref:-}" ]; then \ gem install datadog -v 2.12 --install-dir "/opt/ruby/gems/$runtime"; \ else \ + echo "building tracer from ref: $git_ref" \ git clone https://github.com/DataDog/dd-trace-rb.git --depth 1 --single-branch -b $git_ref /tmp/dd-trace-rb; \ cd /tmp/dd-trace-rb; \ gem build datadog.gemspec; \ From bdcfabc1ba3757f7188d6872d6c97009d7f70223 Mon Sep 17 00:00:00 2001 From: Olivier John Ndjike Nzia Date: Wed, 13 May 2026 18:56:25 -0500 Subject: [PATCH 6/7] forward --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ed44447..f1930c8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -6,7 +6,7 @@ variables: value: "" UPDATE_SNAPSHOTS: description: whether or not to create new snapshots - value: "false" + value: "" stages: - pre @@ -51,6 +51,9 @@ generator: build: stage: build trigger: + forward: + pipeline_variables: true + yaml_variables: true include: - artifact: .gitlab/build-pipeline.yaml job: generator From 902d480b6a0562affbe82920452e67431f4a179e Mon Sep 17 00:00:00 2001 From: Olivier John Ndjike Nzia Date: Wed, 13 May 2026 19:27:15 -0500 Subject: [PATCH 7/7] syntax fix --- Dockerfile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 73dee08..3c1e4c4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,7 @@ ARG image FROM $image AS builder ARG git_ref ARG runtime -RUN echo "git_ref:" -RUN echo $git_ref +RUN echo "git_ref: $git_ref" # Install dev dependencies COPY . /var/task/datadog-lambda-rb WORKDIR /var/task/datadog-lambda-rb @@ -19,7 +18,7 @@ RUN set -eux; \ if [ -z "${git_ref:-}" ]; then \ gem install datadog -v 2.12 --install-dir "/opt/ruby/gems/$runtime"; \ else \ - echo "building tracer from ref: $git_ref" \ + echo "building tracer from ref: $git_ref\n"; \ git clone https://github.com/DataDog/dd-trace-rb.git --depth 1 --single-branch -b $git_ref /tmp/dd-trace-rb; \ cd /tmp/dd-trace-rb; \ gem build datadog.gemspec; \