From 7b28f257744381af377e53c4aaf2ff151e1d3f0c Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 24 Jul 2025 11:47:23 -0400 Subject: [PATCH 01/34] improve layer build --- .../workflows/build_publish_lambda_layer.yml | 1 + lambda/build.sh | 3 +++ lambda/otel/Dockerfile | 24 ++++++++++++------- lambda/otel/layer/Gemfile | 7 +----- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index b173c149..d88e8c7c 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -46,6 +46,7 @@ jobs: env: GITHUB_RUBY_TOKEN: ${{ secrets.PACKAGE_GITHUB_TOKEN }} SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} + PUBLISH_DEST: ${{ github.event.inputs.publish-dest }} - name: Show directory contents run: | diff --git a/lambda/build.sh b/lambda/build.sh index 6bc44474..9c39d07b 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -1,6 +1,7 @@ #!/bin/sh set -e +echo "Build from source: $SOLARWINDS_SOURCE. Publish to $PUBLISH_DEST." if [ $SOLARWINDS_SOURCE = 'Local' ]; then cd ../ sudo apt-get update && sudo apt-get install -y --no-install-recommends ruby ruby-dev g++ make @@ -16,6 +17,7 @@ fi mkdir -p build for ruby_version in 3.2 3.3 3.4; do + echo "Build container for ruby $ruby_version." docker build --no-cache \ --build-arg RUBY_VERSION=${ruby_version} \ --progress plain \ @@ -29,4 +31,5 @@ cd build/ mkdir solarwinds-apm && mkdir ruby && mkdir ruby/gems unzip -q gems-3.2.0.zip -d ruby/gems/ && unzip -q gems-3.3.0.zip -d ruby/gems/ && unzip -q gems-3.4.0.zip -d ruby/gems/ cp ../otel/layer/otel_wrapper.rb . && cp ../otel/layer/wrapper solarwinds-apm/ +echo "Zip built solarwinds_apm and installed opentelemetry gem into single layer." zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb diff --git a/lambda/otel/Dockerfile b/lambda/otel/Dockerfile index 11290ce0..769bb067 100644 --- a/lambda/otel/Dockerfile +++ b/lambda/otel/Dockerfile @@ -13,24 +13,32 @@ RUN bundle config set --local path 'ruby' # Save gem filename if present RUN ls | grep solarwinds_apm-*.gem > gem_file.txt 2>/dev/null || true -# Install dependencies -RUN bundle update +# (for local gem only) +RUN gem_file=$(cat gem_file.txt) && \ + if [ -f "$gem_file" ]; then \ + gem install $gem_file; \ + gem unpack $gem_file --target solarwinds_apm/; \ + gem unpack $gem_file --target solarwinds_apm/ --spec; \ + mv solarwinds_apm/*.gemspec solarwinds_apm/solarwinds_apm-*/; \ + LOCAL_GEM_DIR=$(find solarwinds_apm -type d -name "solarwinds_apm-*"); \ + sed -i.bak -E "s|^gem 'solarwinds_apm'.*|gem 'solarwinds_apm', path: '$LOCAL_GEM_DIR'|" Gemfile; \ + fi + +# install get gem +RUN bundle install -# Install wget RUN sh -c '(command -v dnf && dnf install -y wget) || (command -v yum && yum install -y wget)' -# Install aarch64 version of protobuf gem ENV ARCH=aarch64 RUN PROTOBUF_VERSION=$(bundle exec ruby -e 'puts Gem.loaded_specs["google-protobuf"].version.to_s') && \ wget "https://rubygems.org/downloads/google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" && \ bundle exec gem install "google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" -# Install solarwinds_apm gem (from file, if exists; for local build only) +# (for local gem only) RUN gem_file=$(cat gem_file.txt) && \ if [ -f "$gem_file" ]; then \ - gem install $gem_file; \ - bundle exec gem uninstall solarwinds_apm; \ - mv /var/lang/lib/ruby/gems/${RUBY_VERSION}.0/gems/solarwinds_apm-*/ /build/layer/ruby/ruby/${RUBY_VERSION}.0/gems/; \ + rm solarwinds_apm/solarwinds_apm-*/*.gemspec; \ + mv /build/layer/solarwinds_apm/solarwinds_apm-*/ /build/layer/ruby/ruby/${RUBY_VERSION}.0/gems/; \ mv /var/lang/lib/ruby/gems/${RUBY_VERSION}.0/specifications/solarwinds_apm-* /build/layer/ruby/ruby/${RUBY_VERSION}.0/specifications/; \ fi diff --git a/lambda/otel/layer/Gemfile b/lambda/otel/layer/Gemfile index e85297fc..a0133230 100644 --- a/lambda/otel/layer/Gemfile +++ b/lambda/otel/layer/Gemfile @@ -1,9 +1,4 @@ # frozen_string_literal: true source 'https://rubygems.org' - -## keep in case we need custom packages again -# source 'https://rubygems.pkg.github.com/solarwinds' do -# end - -gem 'solarwinds_apm', '7.0.0.prev1' +gem 'solarwinds_apm' \ No newline at end of file From c27a5d48468b45d5663999d7a8b28034e3d65023 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 24 Jul 2025 12:47:38 -0400 Subject: [PATCH 02/34] update version extract --- .github/workflows/build_publish_lambda_layer.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index d88e8c7c..2c74d32c 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -76,9 +76,17 @@ jobs: name: ruby-layer.zip path: lambda + - name: extract current solarwinds_apm version from Local + if: ${{ github.event.inputs.solarwinds-source == 'Local' }} + run: | + APM_VERSION=$(ruby -r './lib/solarwinds_apm/version.rb' -e 'puts SolarWindsAPM::Version::STRING') + echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV + - name: extract current solarwinds_apm version + if: ${{ github.event.inputs.solarwinds-source == 'RubyGem' }} run: | - APM_VERSION=$(grep "gem 'solarwinds_apm'" lambda/otel/layer/Gemfile | awk -F"'" '{print $4}') + sudo apt-get update && apt-get install -y jq curl + APM_VERSION=$(curl -s https://rubygems.org/api/v1/gems/solarwinds_apm.json | jq -r .version) echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV - name: Scan build artifact on the Portal From fced5e20f628c85f9fa2ca7e7751ed28351f1bc9 Mon Sep 17 00:00:00 2001 From: Xuan <112967240+xuan-cao-swi@users.noreply.github.com> Date: Thu, 24 Jul 2025 12:49:04 -0400 Subject: [PATCH 03/34] Update Gemfile --- lambda/otel/layer/Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda/otel/layer/Gemfile b/lambda/otel/layer/Gemfile index a0133230..7e8452ad 100644 --- a/lambda/otel/layer/Gemfile +++ b/lambda/otel/layer/Gemfile @@ -1,4 +1,4 @@ # frozen_string_literal: true source 'https://rubygems.org' -gem 'solarwinds_apm' \ No newline at end of file +gem 'solarwinds_apm' From 703ba77fd4a032440f620d3d7866dc33e7c9fc80 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 24 Jul 2025 20:06:15 -0400 Subject: [PATCH 04/34] gem install to directory --- lambda/build.sh | 22 ++++++++++------------ lambda/otel/Dockerfile | 28 ++++++++++------------------ 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/lambda/build.sh b/lambda/build.sh index 9c39d07b..b80d174a 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -1,23 +1,22 @@ #!/bin/sh -set -e +set -xe echo "Build from source: $SOLARWINDS_SOURCE. Publish to $PUBLISH_DEST." if [ $SOLARWINDS_SOURCE = 'Local' ]; then - cd ../ - sudo apt-get update && sudo apt-get install -y --no-install-recommends ruby ruby-dev g++ make - sudo gem install bundler - sudo echo 'gem: --no-document' >> ~/.gemrc - sudo bundle config set --local without 'test development' - sudo gem build solarwinds_apm.gemspec - CURRENT_GEM=$(ls | grep solarwinds_apm-*.gem) - mv $CURRENT_GEM lambda/otel/layer/ - cd - + cd ../ + sudo apt-get update && sudo apt-get install -y --no-install-recommends ruby ruby-dev g++ make + sudo gem install bundler + sudo echo 'gem: --no-document' >> ~/.gemrc + sudo bundle config set --local without 'test development' + sudo gem build solarwinds_apm.gemspec + CURRENT_GEM=$(ls | grep solarwinds_apm-*.gem) + mv $CURRENT_GEM lambda/otel/layer/ + cd - fi mkdir -p build for ruby_version in 3.2 3.3 3.4; do - echo "Build container for ruby $ruby_version." docker build --no-cache \ --build-arg RUBY_VERSION=${ruby_version} \ --progress plain \ @@ -31,5 +30,4 @@ cd build/ mkdir solarwinds-apm && mkdir ruby && mkdir ruby/gems unzip -q gems-3.2.0.zip -d ruby/gems/ && unzip -q gems-3.3.0.zip -d ruby/gems/ && unzip -q gems-3.4.0.zip -d ruby/gems/ cp ../otel/layer/otel_wrapper.rb . && cp ../otel/layer/wrapper solarwinds-apm/ -echo "Zip built solarwinds_apm and installed opentelemetry gem into single layer." zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb diff --git a/lambda/otel/Dockerfile b/lambda/otel/Dockerfile index 769bb067..bcf06bd1 100644 --- a/lambda/otel/Dockerfile +++ b/lambda/otel/Dockerfile @@ -13,33 +13,25 @@ RUN bundle config set --local path 'ruby' # Save gem filename if present RUN ls | grep solarwinds_apm-*.gem > gem_file.txt 2>/dev/null || true -# (for local gem only) RUN gem_file=$(cat gem_file.txt) && \ if [ -f "$gem_file" ]; then \ - gem install $gem_file; \ - gem unpack $gem_file --target solarwinds_apm/; \ - gem unpack $gem_file --target solarwinds_apm/ --spec; \ - mv solarwinds_apm/*.gemspec solarwinds_apm/solarwinds_apm-*/; \ - LOCAL_GEM_DIR=$(find solarwinds_apm -type d -name "solarwinds_apm-*"); \ - sed -i.bak -E "s|^gem 'solarwinds_apm'.*|gem 'solarwinds_apm', path: '$LOCAL_GEM_DIR'|" Gemfile; \ + mkdir -p ruby/ruby/${RUBY_VERSION}.0; \ + gem install solarwinds_apm-7.0.0.prev3.gem --install-dir /build/layer/ruby/ruby/${RUBY_VERSION}.0; \ + else \ + bundle install; \ fi -# install get gem -RUN bundle install - RUN sh -c '(command -v dnf && dnf install -y wget) || (command -v yum && yum install -y wget)' ENV ARCH=aarch64 RUN PROTOBUF_VERSION=$(bundle exec ruby -e 'puts Gem.loaded_specs["google-protobuf"].version.to_s') && \ + echo "PROTOBUF_VERSION=${PROTOBUF_VERSION}" && \ wget "https://rubygems.org/downloads/google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" && \ - bundle exec gem install "google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" - -# (for local gem only) -RUN gem_file=$(cat gem_file.txt) && \ - if [ -f "$gem_file" ]; then \ - rm solarwinds_apm/solarwinds_apm-*/*.gemspec; \ - mv /build/layer/solarwinds_apm/solarwinds_apm-*/ /build/layer/ruby/ruby/${RUBY_VERSION}.0/gems/; \ - mv /var/lang/lib/ruby/gems/${RUBY_VERSION}.0/specifications/solarwinds_apm-* /build/layer/ruby/ruby/${RUBY_VERSION}.0/specifications/; \ + gem_file=$(cat gem_file.txt) && \ + if [ -n "$gem_file" ] && [ -f "$gem_file" ]; then \ + gem install "google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" --install-dir /build/layer/ruby/ruby/${RUBY_VERSION}.0; \ + else \ + bundle exec gem install "google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem"; \ fi # Clean up cache and docs From c756a6bebe1cd7b9fff6d475c2041f071afe328f Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Fri, 25 Jul 2025 11:25:48 -0400 Subject: [PATCH 05/34] update version extraction for uploading layer --- .github/workflows/build_publish_lambda_layer.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 2c74d32c..4d9c8ddb 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -150,10 +150,17 @@ jobs: name: ruby-layer.zip path: lambda + - name: extract current solarwinds_apm version from Local + if: ${{ github.event.inputs.solarwinds-source == 'Local' }} + run: | + APM_VERSION=$(ruby -r './lib/solarwinds_apm/version.rb' -e 'puts SolarWindsAPM::Version::STRING') + echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV + - name: extract current solarwinds_apm version + if: ${{ github.event.inputs.solarwinds-source == 'RubyGem' }} run: | - APM_VERSION=$(grep "gem 'solarwinds_apm'" lambda/otel/layer/Gemfile | awk -F"'" '{print $4}') - APM_VERSION="${APM_VERSION//./_}" + sudo apt-get update && apt-get install -y jq curl + APM_VERSION=$(curl -s https://rubygems.org/api/v1/gems/solarwinds_apm.json | jq -r .version) echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV - name: publish lambda layer From e3ba1150d752a85005a3e96d326dd3ad049240cd Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Fri, 25 Jul 2025 15:29:46 -0400 Subject: [PATCH 06/34] fix the layer name --- .github/workflows/build_publish_lambda_layer.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 4d9c8ddb..fbaa68db 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -154,6 +154,7 @@ jobs: if: ${{ github.event.inputs.solarwinds-source == 'Local' }} run: | APM_VERSION=$(ruby -r './lib/solarwinds_apm/version.rb' -e 'puts SolarWindsAPM::Version::STRING') + APM_VERSION=$(echo "$APM_VERSION" | tr '.' '_') echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV - name: extract current solarwinds_apm version @@ -161,6 +162,7 @@ jobs: run: | sudo apt-get update && apt-get install -y jq curl APM_VERSION=$(curl -s https://rubygems.org/api/v1/gems/solarwinds_apm.json | jq -r .version) + APM_VERSION=$(echo "$APM_VERSION" | tr '.' '_') echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV - name: publish lambda layer From cc8e8345dd882d9c7acec43a82a1f44f57b9f167 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Mon, 28 Jul 2025 11:09:42 -0400 Subject: [PATCH 07/34] refactor --- .../workflows/build_publish_lambda_layer.yml | 45 ++++++++++--------- lambda/build.sh | 8 +++- lambda/otel/Dockerfile | 28 ++++-------- 3 files changed, 38 insertions(+), 43 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index fbaa68db..95e99383 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -24,6 +24,10 @@ on: - staging - production + ruby-version: + description: 'Supported ruby version for lambda layer' + default: '3.2 3.3 3.4' + permissions: id-token: write # This is required for requesting the JWT contents: read # This is required for actions/checkout @@ -47,6 +51,7 @@ jobs: GITHUB_RUBY_TOKEN: ${{ secrets.PACKAGE_GITHUB_TOKEN }} SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} PUBLISH_DEST: ${{ github.event.inputs.publish-dest }} + ALLOWED_RUBY_VERSION: ${{ github.event.inputs.ruby-version }} - name: Show directory contents run: | @@ -64,6 +69,10 @@ jobs: needs: - build_layer runs-on: ubuntu-latest + + outputs: + apm_ruby_version: ${{ steps.version.outputs.SOLARWINDS_APM_VERSION }} + strategy: fail-fast: false @@ -76,18 +85,18 @@ jobs: name: ruby-layer.zip path: lambda - - name: extract current solarwinds_apm version from Local - if: ${{ github.event.inputs.solarwinds-source == 'Local' }} - run: | - APM_VERSION=$(ruby -r './lib/solarwinds_apm/version.rb' -e 'puts SolarWindsAPM::Version::STRING') - echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV - - name: extract current solarwinds_apm version - if: ${{ github.event.inputs.solarwinds-source == 'RubyGem' }} + id: version run: | - sudo apt-get update && apt-get install -y jq curl - APM_VERSION=$(curl -s https://rubygems.org/api/v1/gems/solarwinds_apm.json | jq -r .version) + if [ $SOLARWINDS_SOURCE = 'Local' ]; then \ + APM_VERSION=$(ruby -r './lib/solarwinds_apm/version.rb' -e 'puts SolarWindsAPM::Version::STRING'); \ + else \ + apt-get update && apt-get install -y jq curl; \ + APM_VERSION=$(curl -s https://rubygems.org/api/v1/gems/solarwinds_apm.json | jq -r .version); \ + fi echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV + env: + SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} - name: Scan build artifact on the Portal id: rl-scan @@ -150,20 +159,14 @@ jobs: name: ruby-layer.zip path: lambda - - name: extract current solarwinds_apm version from Local - if: ${{ github.event.inputs.solarwinds-source == 'Local' }} + - name: format version for aws lambda and define lambda ruby version run: | - APM_VERSION=$(ruby -r './lib/solarwinds_apm/version.rb' -e 'puts SolarWindsAPM::Version::STRING') - APM_VERSION=$(echo "$APM_VERSION" | tr '.' '_') - echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV - - - name: extract current solarwinds_apm version - if: ${{ github.event.inputs.solarwinds-source == 'RubyGem' }} - run: | - sudo apt-get update && apt-get install -y jq curl - APM_VERSION=$(curl -s https://rubygems.org/api/v1/gems/solarwinds_apm.json | jq -r .version) APM_VERSION=$(echo "$APM_VERSION" | tr '.' '_') echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV + echo "LAMBDA_RUBY_VERSION=$(echo $ALLOWED_RUBY_VERSION | sed 's/\([0-9]\+\.[0-9]\+\)/ruby\1/g')" >> $GITHUB_ENV + env: + APM_VERSION: ${{needs.reverselab_scan_layer.outputs.apm_ruby_version}} + ALLOWED_RUBY_VERSION: ${{ github.event.inputs.ruby-version }} - name: publish lambda layer run: | @@ -172,7 +175,7 @@ jobs: --layer-name solarwinds-apm-ruby-${{ env.SOLARWINDS_APM_VERSION }} \ --license-info "Apache 2.0" \ --compatible-architectures x86_64 arm64 \ - --compatible-runtimes ruby3.2 ruby3.3 ruby3.4 \ + --compatible-runtimes ${{ env.LAMBDA_RUBY_VERSION }} \ --zip-file fileb://ruby-layer.zip \ --query 'LayerVersionArn' \ --output text diff --git a/lambda/build.sh b/lambda/build.sh index b80d174a..b782cf06 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -16,7 +16,7 @@ fi mkdir -p build -for ruby_version in 3.2 3.3 3.4; do +for ruby_version in $ALLOWED_RUBY_VERSION; do docker build --no-cache \ --build-arg RUBY_VERSION=${ruby_version} \ --progress plain \ @@ -28,6 +28,10 @@ done cd build/ mkdir solarwinds-apm && mkdir ruby && mkdir ruby/gems -unzip -q gems-3.2.0.zip -d ruby/gems/ && unzip -q gems-3.3.0.zip -d ruby/gems/ && unzip -q gems-3.4.0.zip -d ruby/gems/ + +for ruby_version in $ALLOWED_RUBY_VERSION; do + unzip -q gems-$ruby_version.0.zip -d ruby/gems/ +done + cp ../otel/layer/otel_wrapper.rb . && cp ../otel/layer/wrapper solarwinds-apm/ zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb diff --git a/lambda/otel/Dockerfile b/lambda/otel/Dockerfile index bcf06bd1..824a416e 100644 --- a/lambda/otel/Dockerfile +++ b/lambda/otel/Dockerfile @@ -4,35 +4,23 @@ FROM public.ecr.aws/sam/build-ruby${RUBY_VERSION}:latest ARG RUBY_VERSION ENV RUBY_VERSION=${RUBY_VERSION} -RUN mkdir /build -COPY . /build - WORKDIR /build/layer -RUN bundle config set --local path 'ruby' +COPY . /build +RUN mkdir -p ruby/ruby/${RUBY_VERSION}.0 # Save gem filename if present RUN ls | grep solarwinds_apm-*.gem > gem_file.txt 2>/dev/null || true -RUN gem_file=$(cat gem_file.txt) && \ - if [ -f "$gem_file" ]; then \ - mkdir -p ruby/ruby/${RUBY_VERSION}.0; \ - gem install solarwinds_apm-7.0.0.prev3.gem --install-dir /build/layer/ruby/ruby/${RUBY_VERSION}.0; \ - else \ - bundle install; \ - fi +RUN gem_file=$(ls | grep solarwinds_apm-*.gem 2>/dev/null || true) && \ + gem install ${gem_file:-solarwinds_apm} --install-dir ruby/ruby/${RUBY_VERSION}.0 --no-document RUN sh -c '(command -v dnf && dnf install -y wget) || (command -v yum && yum install -y wget)' -ENV ARCH=aarch64 -RUN PROTOBUF_VERSION=$(bundle exec ruby -e 'puts Gem.loaded_specs["google-protobuf"].version.to_s') && \ - echo "PROTOBUF_VERSION=${PROTOBUF_VERSION}" && \ +# bundle need Gemfile; can't find correct way to set additional gem path +ENV ARCH=x86_64 +RUN PROTOBUF_VERSION=$(GEM_PATH=ruby/ruby/${RUBY_VERSION}.0/ ruby -e 'require "google/protobuf"; puts Gem.loaded_specs["google-protobuf"].version.to_s') && \ wget "https://rubygems.org/downloads/google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" && \ - gem_file=$(cat gem_file.txt) && \ - if [ -n "$gem_file" ] && [ -f "$gem_file" ]; then \ - gem install "google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" --install-dir /build/layer/ruby/ruby/${RUBY_VERSION}.0; \ - else \ - bundle exec gem install "google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem"; \ - fi + gem install "google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" --install-dir ruby/ruby/${RUBY_VERSION}.0 --no-document # Clean up cache and docs RUN rm -rf /build/layer/ruby/ruby/${RUBY_VERSION}.0/cache/* && \ From 71d43efe34a85b535dd8bee4dd74cb8797f5c2d7 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Mon, 28 Jul 2025 11:22:42 -0400 Subject: [PATCH 08/34] refactor --- .github/workflows/build_publish_lambda_layer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 95e99383..d16f775d 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -122,7 +122,7 @@ jobs: # extract the built layer from artifacts, then publish it based on region publish_layer: needs: - - build_layer + - reverselab_scan_layer runs-on: ubuntu-latest strategy: matrix: From 81a2621ff388818d3c51cae37d0996e8eea93b29 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Mon, 28 Jul 2025 11:31:56 -0400 Subject: [PATCH 09/34] refactor --- .github/workflows/build_publish_lambda_layer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index d16f775d..2694625f 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -94,7 +94,7 @@ jobs: apt-get update && apt-get install -y jq curl; \ APM_VERSION=$(curl -s https://rubygems.org/api/v1/gems/solarwinds_apm.json | jq -r .version); \ fi - echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV + echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_OUTPUT env: SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} From 9b97dbbc0ce6d4093989f9adc37cbb1931bc364d Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Mon, 28 Jul 2025 11:37:43 -0400 Subject: [PATCH 10/34] refactor --- .github/workflows/build_publish_lambda_layer.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 2694625f..815bc7bd 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -94,6 +94,7 @@ jobs: apt-get update && apt-get install -y jq curl; \ APM_VERSION=$(curl -s https://rubygems.org/api/v1/gems/solarwinds_apm.json | jq -r .version); \ fi + echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_ENV echo "SOLARWINDS_APM_VERSION=$APM_VERSION" >> $GITHUB_OUTPUT env: SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} From 67db14c0075108f2bfe455cef677891674593e33 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Mon, 28 Jul 2025 11:49:13 -0400 Subject: [PATCH 11/34] remove gemfile --- lambda/otel/Dockerfile | 1 - lambda/otel/layer/Gemfile | 5 ----- 2 files changed, 6 deletions(-) delete mode 100644 lambda/otel/layer/Gemfile diff --git a/lambda/otel/Dockerfile b/lambda/otel/Dockerfile index 824a416e..8edf205b 100644 --- a/lambda/otel/Dockerfile +++ b/lambda/otel/Dockerfile @@ -16,7 +16,6 @@ RUN gem_file=$(ls | grep solarwinds_apm-*.gem 2>/dev/null || true) && \ RUN sh -c '(command -v dnf && dnf install -y wget) || (command -v yum && yum install -y wget)' -# bundle need Gemfile; can't find correct way to set additional gem path ENV ARCH=x86_64 RUN PROTOBUF_VERSION=$(GEM_PATH=ruby/ruby/${RUBY_VERSION}.0/ ruby -e 'require "google/protobuf"; puts Gem.loaded_specs["google-protobuf"].version.to_s') && \ wget "https://rubygems.org/downloads/google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" && \ diff --git a/lambda/otel/layer/Gemfile b/lambda/otel/layer/Gemfile deleted file mode 100644 index 08e7f8f5..00000000 --- a/lambda/otel/layer/Gemfile +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -gem 'solarwinds_apm' From 26a7060c661cc07c643b99ef229fb9f87c172622 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Tue, 29 Jul 2025 10:28:08 -0400 Subject: [PATCH 12/34] fix arch --- lambda/otel/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda/otel/Dockerfile b/lambda/otel/Dockerfile index 8edf205b..9d36896a 100644 --- a/lambda/otel/Dockerfile +++ b/lambda/otel/Dockerfile @@ -16,7 +16,7 @@ RUN gem_file=$(ls | grep solarwinds_apm-*.gem 2>/dev/null || true) && \ RUN sh -c '(command -v dnf && dnf install -y wget) || (command -v yum && yum install -y wget)' -ENV ARCH=x86_64 +ENV ARCH=aarch64 RUN PROTOBUF_VERSION=$(GEM_PATH=ruby/ruby/${RUBY_VERSION}.0/ ruby -e 'require "google/protobuf"; puts Gem.loaded_specs["google-protobuf"].version.to_s') && \ wget "https://rubygems.org/downloads/google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" && \ gem install "google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" --install-dir ruby/ruby/${RUBY_VERSION}.0 --no-document From fe3e12c8ebedaa30edb8e7d7fcbbc8e223759dfd Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 13:47:20 -0400 Subject: [PATCH 13/34] test --- .../workflows/build_publish_lambda_layer.yml | 52 +++++++++++++++++-- lambda/build.sh | 12 +++-- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 815bc7bd..5cbbb13f 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -51,7 +51,7 @@ jobs: GITHUB_RUBY_TOKEN: ${{ secrets.PACKAGE_GITHUB_TOKEN }} SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} PUBLISH_DEST: ${{ github.event.inputs.publish-dest }} - ALLOWED_RUBY_VERSION: ${{ github.event.inputs.ruby-version }} + ALLOWED_RUBY_VERSION: '3.4' - name: Show directory contents run: | @@ -64,18 +64,59 @@ jobs: name: ruby-layer.zip path: lambda/build/ruby-layer.zip + build_bigdecimal_arm64: + needs: + - build_layer + runs-on: fromJSON('{"group":"apm-arm-runner"}') + + steps: + - uses: actions/checkout@v4 + + - name: Build ruby lambda layer on arm64 machine + run: | + uname -a + ./build.sh + shell: bash + working-directory: lambda/ + env: + GITHUB_RUBY_TOKEN: ${{ secrets.PACKAGE_GITHUB_TOKEN }} + SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} + PUBLISH_DEST: ${{ github.event.inputs.publish-dest }} + ALLOWED_RUBY_VERSION: '3.4' + BIGDECIMAL: true + + - name: extract layer zip from artifacts + uses: actions/download-artifact@v4 + with: + name: ruby-layer.zip + path: lambda/build + + - name: Combine to single layer + run: | + unzip ruby-layer.zip + mkdir -p bigdecimal + unzip -d bigdecimal/ bigdecimal-aarch64.zip + mkdir -p ruby/gems/3.4.0/extensions/aarch64-linux/ + mv bigdecimal/ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-*/ ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ + zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb + working-directory: lambda/build + + - name: Upload to artifact + uses: actions/upload-artifact@v4 + with: + name: ruby-layer.zip + path: lambda/build/ruby-layer.zip + # extract the built layer from artifacts, then scan it with reverselab reverselab_scan_layer: + if: false # Disable this job needs: - - build_layer + - build_bigdecimal_arm64 runs-on: ubuntu-latest outputs: apm_ruby_version: ${{ steps.version.outputs.SOLARWINDS_APM_VERSION }} - strategy: - fail-fast: false - steps: - uses: actions/checkout@v4 @@ -122,6 +163,7 @@ jobs: # extract the built layer from artifacts, then publish it based on region publish_layer: + if: false # Disable this job needs: - reverselab_scan_layer runs-on: ubuntu-latest diff --git a/lambda/build.sh b/lambda/build.sh index b782cf06..5e75c7bd 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -27,11 +27,17 @@ for ruby_version in $ALLOWED_RUBY_VERSION; do done cd build/ -mkdir solarwinds-apm && mkdir ruby && mkdir ruby/gems +mkdir -p ruby/gems for ruby_version in $ALLOWED_RUBY_VERSION; do unzip -q gems-$ruby_version.0.zip -d ruby/gems/ done -cp ../otel/layer/otel_wrapper.rb . && cp ../otel/layer/wrapper solarwinds-apm/ -zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb +if [ $BIGDECIMAL = 'true' ]; then + zip -qr bigdecimal-aarch64.zip ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-*/ + rm -rf ruby/ +else + mkdir solarwinds-apm + cp ../otel/layer/otel_wrapper.rb . && cp ../otel/layer/wrapper solarwinds-apm/ + zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb +fi From 338f315ce511dea30350a2b5bf14ec6e96852012 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 13:51:19 -0400 Subject: [PATCH 14/34] update --- .github/workflows/build_publish_lambda_layer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 5cbbb13f..7747943b 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -67,7 +67,7 @@ jobs: build_bigdecimal_arm64: needs: - build_layer - runs-on: fromJSON('{"group":"apm-arm-runner"}') + runs-on: ${{ fromJSON('{"group":"apm-arm-runner"}') }} steps: - uses: actions/checkout@v4 From cbcbc076b07d8458e6a9a96929f77f73c2dd4a73 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 13:52:13 -0400 Subject: [PATCH 15/34] update --- .github/workflows/build_publish_lambda_layer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 7747943b..c487ddea 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -67,7 +67,7 @@ jobs: build_bigdecimal_arm64: needs: - build_layer - runs-on: ${{ fromJSON('{"group":"apm-arm-runner"}') }} + runs-on: [self-hosted, apm-arm-runner] steps: - uses: actions/checkout@v4 From 423c956e4a58b35656d92629317d62a92f223489 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 13:52:36 -0400 Subject: [PATCH 16/34] update --- .github/workflows/build_publish_lambda_layer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index c487ddea..7391d37f 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -67,7 +67,7 @@ jobs: build_bigdecimal_arm64: needs: - build_layer - runs-on: [self-hosted, apm-arm-runner] + runs-on: apm-arm-runner steps: - uses: actions/checkout@v4 From 09bde6ca97a3c0c8b2617c6fb3140c08e06e53c7 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 13:54:30 -0400 Subject: [PATCH 17/34] update --- .../workflows/build_publish_lambda_layer.yml | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 7391d37f..0e7cdfab 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -67,7 +67,7 @@ jobs: build_bigdecimal_arm64: needs: - build_layer - runs-on: apm-arm-runner + runs-on: ${{ fromJSON('{"group":"apm-arm-runner"}') }} steps: - uses: actions/checkout@v4 @@ -85,27 +85,27 @@ jobs: ALLOWED_RUBY_VERSION: '3.4' BIGDECIMAL: true - - name: extract layer zip from artifacts - uses: actions/download-artifact@v4 - with: - name: ruby-layer.zip - path: lambda/build - - - name: Combine to single layer - run: | - unzip ruby-layer.zip - mkdir -p bigdecimal - unzip -d bigdecimal/ bigdecimal-aarch64.zip - mkdir -p ruby/gems/3.4.0/extensions/aarch64-linux/ - mv bigdecimal/ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-*/ ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ - zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb - working-directory: lambda/build - - - name: Upload to artifact - uses: actions/upload-artifact@v4 - with: - name: ruby-layer.zip - path: lambda/build/ruby-layer.zip + - name: extract layer zip from artifacts + uses: actions/download-artifact@v4 + with: + name: ruby-layer.zip + path: lambda/build + + - name: Combine to single layer + run: | + unzip ruby-layer.zip + mkdir -p bigdecimal + unzip -d bigdecimal/ bigdecimal-aarch64.zip + mkdir -p ruby/gems/3.4.0/extensions/aarch64-linux/ + mv bigdecimal/ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-*/ ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ + zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb + working-directory: lambda/build + + - name: Upload to artifact + uses: actions/upload-artifact@v4 + with: + name: ruby-layer.zip + path: lambda/build/ruby-layer.zip # extract the built layer from artifacts, then scan it with reverselab reverselab_scan_layer: From 794e39ad2369ab29101312a9454c3b36fd964757 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 13:55:06 -0400 Subject: [PATCH 18/34] update --- .github/workflows/build_publish_lambda_layer.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 0e7cdfab..feccc3bd 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -86,10 +86,10 @@ jobs: BIGDECIMAL: true - name: extract layer zip from artifacts - uses: actions/download-artifact@v4 - with: - name: ruby-layer.zip - path: lambda/build + uses: actions/download-artifact@v4 + with: + name: ruby-layer.zip + path: lambda/build - name: Combine to single layer run: | @@ -102,10 +102,10 @@ jobs: working-directory: lambda/build - name: Upload to artifact - uses: actions/upload-artifact@v4 - with: - name: ruby-layer.zip - path: lambda/build/ruby-layer.zip + uses: actions/upload-artifact@v4 + with: + name: ruby-layer.zip + path: lambda/build/ruby-layer.zip # extract the built layer from artifacts, then scan it with reverselab reverselab_scan_layer: From c8abc5e847b6381854adf5330ef1230c17680771 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 13:56:54 -0400 Subject: [PATCH 19/34] update --- .github/workflows/build_publish_lambda_layer.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index feccc3bd..004ec92c 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -67,7 +67,7 @@ jobs: build_bigdecimal_arm64: needs: - build_layer - runs-on: ${{ fromJSON('{"group":"apm-arm-runner"}') }} + runs-on: [self-hosted, apm-arm-runner] steps: - uses: actions/checkout@v4 From fc8a540ead5735b40070c137b820caf79b220c05 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 16:52:23 -0400 Subject: [PATCH 20/34] try qemu --- .../workflows/build_publish_lambda_layer.yml | 51 ++++++++++++++++++- lambda/build.sh | 25 ++++++--- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 004ec92c..36898c9a 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -67,11 +67,17 @@ jobs: build_bigdecimal_arm64: needs: - build_layer - runs-on: [self-hosted, apm-arm-runner] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build ruby lambda layer on arm64 machine run: | uname -a @@ -107,6 +113,49 @@ jobs: name: ruby-layer.zip path: lambda/build/ruby-layer.zip + # build_bigdecimal_arm64: + # needs: + # - build_layer + # runs-on: [self-hosted, apm-arm-runner] + + # steps: + # - uses: actions/checkout@v4 + + # - name: Build ruby lambda layer on arm64 machine + # run: | + # uname -a + # ./build.sh + # shell: bash + # working-directory: lambda/ + # env: + # GITHUB_RUBY_TOKEN: ${{ secrets.PACKAGE_GITHUB_TOKEN }} + # SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} + # PUBLISH_DEST: ${{ github.event.inputs.publish-dest }} + # ALLOWED_RUBY_VERSION: '3.4' + # BIGDECIMAL: true + + # - name: extract layer zip from artifacts + # uses: actions/download-artifact@v4 + # with: + # name: ruby-layer.zip + # path: lambda/build + + # - name: Combine to single layer + # run: | + # unzip ruby-layer.zip + # mkdir -p bigdecimal + # unzip -d bigdecimal/ bigdecimal-aarch64.zip + # mkdir -p ruby/gems/3.4.0/extensions/aarch64-linux/ + # mv bigdecimal/ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-*/ ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ + # zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb + # working-directory: lambda/build + + # - name: Upload to artifact + # uses: actions/upload-artifact@v4 + # with: + # name: ruby-layer.zip + # path: lambda/build/ruby-layer.zip + # extract the built layer from artifacts, then scan it with reverselab reverselab_scan_layer: if: false # Disable this job diff --git a/lambda/build.sh b/lambda/build.sh index 5e75c7bd..ec1f542c 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -17,13 +17,24 @@ fi mkdir -p build for ruby_version in $ALLOWED_RUBY_VERSION; do - docker build --no-cache \ - --build-arg RUBY_VERSION=${ruby_version} \ - --progress plain \ - -f otel/Dockerfile \ - -t sw-lambda-ruby-layer-${ruby_version} otel + if [ "$BIGDECIMAL" = 'true' ]; then + docker buildx --no-cache \ + --platform linux/arm64 + --build-arg RUBY_VERSION=${ruby_version} \ + --progress plain \ + -f otel/Dockerfile \ + -t sw-lambda-ruby-layer-${ruby_version} otel - docker run --rm -v "$(pwd)/build:/out" sw-lambda-ruby-layer-${ruby_version} + docker run --rm -v "$(pwd)/build:/out" sw-lambda-ruby-layer-${ruby_version} + else + docker build --no-cache \ + --build-arg RUBY_VERSION=${ruby_version} \ + --progress plain \ + -f otel/Dockerfile \ + -t sw-lambda-ruby-layer-${ruby_version} otel + + docker run --rm -v "$(pwd)/build:/out" sw-lambda-ruby-layer-${ruby_version} + fi done cd build/ @@ -33,7 +44,7 @@ for ruby_version in $ALLOWED_RUBY_VERSION; do unzip -q gems-$ruby_version.0.zip -d ruby/gems/ done -if [ $BIGDECIMAL = 'true' ]; then +if [ "$BIGDECIMAL" = 'true' ]; then zip -qr bigdecimal-aarch64.zip ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-*/ rm -rf ruby/ else From 33448e3c8361e06c0a765f75a9a7bf2bd7feb23c Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 17:20:32 -0400 Subject: [PATCH 21/34] update --- lambda/build.sh | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lambda/build.sh b/lambda/build.sh index ec1f542c..a71de4fe 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -18,12 +18,11 @@ mkdir -p build for ruby_version in $ALLOWED_RUBY_VERSION; do if [ "$BIGDECIMAL" = 'true' ]; then - docker buildx --no-cache \ - --platform linux/arm64 - --build-arg RUBY_VERSION=${ruby_version} \ - --progress plain \ - -f otel/Dockerfile \ - -t sw-lambda-ruby-layer-${ruby_version} otel + docker buildx --platform linux/arm64 \ + --build-arg RUBY_VERSION=${ruby_version} \ + --progress plain \ + -f otel/Dockerfile \ + -t sw-lambda-ruby-layer-${ruby_version} otel docker run --rm -v "$(pwd)/build:/out" sw-lambda-ruby-layer-${ruby_version} else From a33a7881a6c136c466979be6d3e9c92dd3d0ae3c Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 18:04:35 -0400 Subject: [PATCH 22/34] update --- lambda/build.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lambda/build.sh b/lambda/build.sh index a71de4fe..acb30df5 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -18,11 +18,12 @@ mkdir -p build for ruby_version in $ALLOWED_RUBY_VERSION; do if [ "$BIGDECIMAL" = 'true' ]; then - docker buildx --platform linux/arm64 \ - --build-arg RUBY_VERSION=${ruby_version} \ - --progress plain \ - -f otel/Dockerfile \ - -t sw-lambda-ruby-layer-${ruby_version} otel + docker buildx build --no-cache \ + --platform linux/arm64 + --build-arg RUBY_VERSION=${ruby_version} \ + --progress plain \ + -f otel/Dockerfile \ + -t sw-lambda-ruby-layer-${ruby_version} otel docker run --rm -v "$(pwd)/build:/out" sw-lambda-ruby-layer-${ruby_version} else From 3ec7bc72d560d68aeffd6de25393b36be7b94124 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 18:23:22 -0400 Subject: [PATCH 23/34] update --- lambda/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda/build.sh b/lambda/build.sh index acb30df5..be5f1385 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -19,7 +19,7 @@ mkdir -p build for ruby_version in $ALLOWED_RUBY_VERSION; do if [ "$BIGDECIMAL" = 'true' ]; then docker buildx build --no-cache \ - --platform linux/arm64 + --platform linux/arm64 \ --build-arg RUBY_VERSION=${ruby_version} \ --progress plain \ -f otel/Dockerfile \ From 78a4d1e3cbbe94f8567a1a422ccdb42fa4d1554c Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 19:14:44 -0400 Subject: [PATCH 24/34] update --- lambda/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lambda/build.sh b/lambda/build.sh index be5f1385..df61304e 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -25,7 +25,7 @@ for ruby_version in $ALLOWED_RUBY_VERSION; do -f otel/Dockerfile \ -t sw-lambda-ruby-layer-${ruby_version} otel - docker run --rm -v "$(pwd)/build:/out" sw-lambda-ruby-layer-${ruby_version} + docker run --rm --platform linux/arm64 -v "$(pwd)/build:/out" sw-lambda-ruby-layer-${ruby_version} else docker build --no-cache \ --build-arg RUBY_VERSION=${ruby_version} \ From b4e6faf38852ded39f336e43a30cb578cc114aa1 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 21:08:42 -0400 Subject: [PATCH 25/34] update --- .github/workflows/run_unit_tests.yml | 1 + lambda/build.sh | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/run_unit_tests.yml b/.github/workflows/run_unit_tests.yml index 9dde86a8..1eab3926 100644 --- a/.github/workflows/run_unit_tests.yml +++ b/.github/workflows/run_unit_tests.yml @@ -10,6 +10,7 @@ on: paths-ignore: - 'test/Dockerfile' - '.github/*' + - 'lambda/*' workflow_dispatch: jobs: diff --git a/lambda/build.sh b/lambda/build.sh index df61304e..e9902a46 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -22,6 +22,7 @@ for ruby_version in $ALLOWED_RUBY_VERSION; do --platform linux/arm64 \ --build-arg RUBY_VERSION=${ruby_version} \ --progress plain \ + --load \ -f otel/Dockerfile \ -t sw-lambda-ruby-layer-${ruby_version} otel From f5eff75ff8f9c982cc73eb9f0f0540d9ba0486f8 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 21:31:22 -0400 Subject: [PATCH 26/34] update --- .github/workflows/build_publish_lambda_layer.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 36898c9a..a88cdf16 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -112,6 +112,7 @@ jobs: with: name: ruby-layer.zip path: lambda/build/ruby-layer.zip + overwrite: true # build_bigdecimal_arm64: # needs: From 0e78ba3d77e76c1b04b12a152523bd4b4f230106 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Wed, 30 Jul 2025 22:11:02 -0400 Subject: [PATCH 27/34] update --- .github/workflows/build_publish_lambda_layer.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index a88cdf16..175cdb05 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -102,8 +102,8 @@ jobs: unzip ruby-layer.zip mkdir -p bigdecimal unzip -d bigdecimal/ bigdecimal-aarch64.zip - mkdir -p ruby/gems/3.4.0/extensions/aarch64-linux/ - mv bigdecimal/ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-*/ ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ + mkdir -p ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ + mv bigdecimal/ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-* ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb working-directory: lambda/build From c8ddc2c65698703f4ebe05538765348c879c5cd8 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 31 Jul 2025 10:46:33 -0400 Subject: [PATCH 28/34] update --- .../workflows/build_publish_lambda_layer.yml | 53 +------------------ 1 file changed, 2 insertions(+), 51 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 175cdb05..aa8c50b7 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -24,10 +24,6 @@ on: - staging - production - ruby-version: - description: 'Supported ruby version for lambda layer' - default: '3.2 3.3 3.4' - permissions: id-token: write # This is required for requesting the JWT contents: read # This is required for actions/checkout @@ -51,7 +47,7 @@ jobs: GITHUB_RUBY_TOKEN: ${{ secrets.PACKAGE_GITHUB_TOKEN }} SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} PUBLISH_DEST: ${{ github.event.inputs.publish-dest }} - ALLOWED_RUBY_VERSION: '3.4' + ALLOWED_RUBY_VERSION: '3.2 3.3 3.4' - name: Show directory contents run: | @@ -101,7 +97,7 @@ jobs: run: | unzip ruby-layer.zip mkdir -p bigdecimal - unzip -d bigdecimal/ bigdecimal-aarch64.zip + unzip -q -d bigdecimal/ bigdecimal-aarch64.zip mkdir -p ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ mv bigdecimal/ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-* ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb @@ -114,52 +110,8 @@ jobs: path: lambda/build/ruby-layer.zip overwrite: true - # build_bigdecimal_arm64: - # needs: - # - build_layer - # runs-on: [self-hosted, apm-arm-runner] - - # steps: - # - uses: actions/checkout@v4 - - # - name: Build ruby lambda layer on arm64 machine - # run: | - # uname -a - # ./build.sh - # shell: bash - # working-directory: lambda/ - # env: - # GITHUB_RUBY_TOKEN: ${{ secrets.PACKAGE_GITHUB_TOKEN }} - # SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} - # PUBLISH_DEST: ${{ github.event.inputs.publish-dest }} - # ALLOWED_RUBY_VERSION: '3.4' - # BIGDECIMAL: true - - # - name: extract layer zip from artifacts - # uses: actions/download-artifact@v4 - # with: - # name: ruby-layer.zip - # path: lambda/build - - # - name: Combine to single layer - # run: | - # unzip ruby-layer.zip - # mkdir -p bigdecimal - # unzip -d bigdecimal/ bigdecimal-aarch64.zip - # mkdir -p ruby/gems/3.4.0/extensions/aarch64-linux/ - # mv bigdecimal/ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-*/ ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ - # zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb - # working-directory: lambda/build - - # - name: Upload to artifact - # uses: actions/upload-artifact@v4 - # with: - # name: ruby-layer.zip - # path: lambda/build/ruby-layer.zip - # extract the built layer from artifacts, then scan it with reverselab reverselab_scan_layer: - if: false # Disable this job needs: - build_bigdecimal_arm64 runs-on: ubuntu-latest @@ -213,7 +165,6 @@ jobs: # extract the built layer from artifacts, then publish it based on region publish_layer: - if: false # Disable this job needs: - reverselab_scan_layer runs-on: ubuntu-latest From 1d79e97f344527d1a2b612e436c3f8336252b0fa Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 31 Jul 2025 11:28:10 -0400 Subject: [PATCH 29/34] update --- .github/workflows/build_publish_lambda_layer.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index aa8c50b7..e04a32c3 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -24,6 +24,10 @@ on: - staging - production + ruby-version: + description: 'Supported ruby version for lambda layer' + default: '3.2 3.3 3.4' + permissions: id-token: write # This is required for requesting the JWT contents: read # This is required for actions/checkout @@ -47,7 +51,7 @@ jobs: GITHUB_RUBY_TOKEN: ${{ secrets.PACKAGE_GITHUB_TOKEN }} SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} PUBLISH_DEST: ${{ github.event.inputs.publish-dest }} - ALLOWED_RUBY_VERSION: '3.2 3.3 3.4' + ALLOWED_RUBY_VERSION: ${{ github.event.inputs.ruby-version }} - name: Show directory contents run: | From a59e9b183cdfcce31a950a756f9244b6dfcc2fd5 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 31 Jul 2025 14:58:51 -0400 Subject: [PATCH 30/34] update --- .../workflows/build_publish_lambda_layer.yml | 8 +------ lambda/build.sh | 24 +++++-------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index e04a32c3..8ffb3442 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -67,17 +67,11 @@ jobs: build_bigdecimal_arm64: needs: - build_layer - runs-on: ubuntu-latest + runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - name: Build ruby lambda layer on arm64 machine run: | uname -a diff --git a/lambda/build.sh b/lambda/build.sh index e9902a46..d9ac504c 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -17,25 +17,13 @@ fi mkdir -p build for ruby_version in $ALLOWED_RUBY_VERSION; do - if [ "$BIGDECIMAL" = 'true' ]; then - docker buildx build --no-cache \ - --platform linux/arm64 \ - --build-arg RUBY_VERSION=${ruby_version} \ - --progress plain \ - --load \ - -f otel/Dockerfile \ - -t sw-lambda-ruby-layer-${ruby_version} otel + docker build --no-cache \ + --build-arg RUBY_VERSION=${ruby_version} \ + --progress plain \ + -f otel/Dockerfile \ + -t sw-lambda-ruby-layer-${ruby_version} otel - docker run --rm --platform linux/arm64 -v "$(pwd)/build:/out" sw-lambda-ruby-layer-${ruby_version} - else - docker build --no-cache \ - --build-arg RUBY_VERSION=${ruby_version} \ - --progress plain \ - -f otel/Dockerfile \ - -t sw-lambda-ruby-layer-${ruby_version} otel - - docker run --rm -v "$(pwd)/build:/out" sw-lambda-ruby-layer-${ruby_version} - fi + docker run --rm -v "$(pwd)/build:/out" sw-lambda-ruby-layer-${ruby_version} done cd build/ From b93d019893f340664ac2cf8c4557790a798f04f1 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 31 Jul 2025 17:09:27 -0400 Subject: [PATCH 31/34] arm64 for all ruby version big decimal --- .github/workflows/build_publish_lambda_layer.yml | 14 +++++++++----- lambda/build.sh | 5 +++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 8ffb3442..db22bc9c 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -82,7 +82,7 @@ jobs: GITHUB_RUBY_TOKEN: ${{ secrets.PACKAGE_GITHUB_TOKEN }} SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} PUBLISH_DEST: ${{ github.event.inputs.publish-dest }} - ALLOWED_RUBY_VERSION: '3.4' + ALLOWED_RUBY_VERSION: ${{ github.event.inputs.ruby-version }} BIGDECIMAL: true - name: extract layer zip from artifacts @@ -94,12 +94,16 @@ jobs: - name: Combine to single layer run: | unzip ruby-layer.zip - mkdir -p bigdecimal - unzip -q -d bigdecimal/ bigdecimal-aarch64.zip - mkdir -p ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ - mv bigdecimal/ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-* ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ + for ruby_version in $ALLOWED_RUBY_VERSION; do + mkdir -p bigdecimal-${ruby_version} + unzip -q -d bigdecimal-${ruby_version}/ bigdecimal-aarch64-${ruby_version}.zip + mkdir -p ruby/gems/${ruby_version}.0/extensions/aarch64-linux/${ruby_version}.0/ + mv bigdecimal-${ruby_version}/ruby/gems/${ruby_version}.0/extensions/aarch64-linux/${ruby_version}.0/bigdecimal-* ruby/gems/${ruby_version}.0/extensions/aarch64-linux/${ruby_version}.0/ + done zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb working-directory: lambda/build + env: + ALLOWED_RUBY_VERSION: ${{ github.event.inputs.ruby-version }} - name: Upload to artifact uses: actions/upload-artifact@v4 diff --git a/lambda/build.sh b/lambda/build.sh index d9ac504c..3c09a547 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -34,8 +34,9 @@ for ruby_version in $ALLOWED_RUBY_VERSION; do done if [ "$BIGDECIMAL" = 'true' ]; then - zip -qr bigdecimal-aarch64.zip ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-*/ - rm -rf ruby/ + for ruby_version in $ALLOWED_RUBY_VERSION; do + zip -qr bigdecimal-aarch64-${ruby_version}.zip ruby/gems/${ruby_version}.0/extensions/aarch64-linux/${ruby_version}.0/bigdecimal-*/ + done else mkdir solarwinds-apm cp ../otel/layer/otel_wrapper.rb . && cp ../otel/layer/wrapper solarwinds-apm/ From 28f9225c9b99c8c75cea56ebe737de0961f4497c Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 31 Jul 2025 17:29:47 -0400 Subject: [PATCH 32/34] Revert "arm64 for all ruby version big decimal" This reverts commit b93d019893f340664ac2cf8c4557790a798f04f1. --- .github/workflows/build_publish_lambda_layer.yml | 14 +++++--------- lambda/build.sh | 5 ++--- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index db22bc9c..8ffb3442 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -82,7 +82,7 @@ jobs: GITHUB_RUBY_TOKEN: ${{ secrets.PACKAGE_GITHUB_TOKEN }} SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} PUBLISH_DEST: ${{ github.event.inputs.publish-dest }} - ALLOWED_RUBY_VERSION: ${{ github.event.inputs.ruby-version }} + ALLOWED_RUBY_VERSION: '3.4' BIGDECIMAL: true - name: extract layer zip from artifacts @@ -94,16 +94,12 @@ jobs: - name: Combine to single layer run: | unzip ruby-layer.zip - for ruby_version in $ALLOWED_RUBY_VERSION; do - mkdir -p bigdecimal-${ruby_version} - unzip -q -d bigdecimal-${ruby_version}/ bigdecimal-aarch64-${ruby_version}.zip - mkdir -p ruby/gems/${ruby_version}.0/extensions/aarch64-linux/${ruby_version}.0/ - mv bigdecimal-${ruby_version}/ruby/gems/${ruby_version}.0/extensions/aarch64-linux/${ruby_version}.0/bigdecimal-* ruby/gems/${ruby_version}.0/extensions/aarch64-linux/${ruby_version}.0/ - done + mkdir -p bigdecimal + unzip -q -d bigdecimal/ bigdecimal-aarch64.zip + mkdir -p ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ + mv bigdecimal/ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-* ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb working-directory: lambda/build - env: - ALLOWED_RUBY_VERSION: ${{ github.event.inputs.ruby-version }} - name: Upload to artifact uses: actions/upload-artifact@v4 diff --git a/lambda/build.sh b/lambda/build.sh index 3c09a547..d9ac504c 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -34,9 +34,8 @@ for ruby_version in $ALLOWED_RUBY_VERSION; do done if [ "$BIGDECIMAL" = 'true' ]; then - for ruby_version in $ALLOWED_RUBY_VERSION; do - zip -qr bigdecimal-aarch64-${ruby_version}.zip ruby/gems/${ruby_version}.0/extensions/aarch64-linux/${ruby_version}.0/bigdecimal-*/ - done + zip -qr bigdecimal-aarch64.zip ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-*/ + rm -rf ruby/ else mkdir solarwinds-apm cp ../otel/layer/otel_wrapper.rb . && cp ../otel/layer/wrapper solarwinds-apm/ From 33e06c59c542d7c115260ace33ad002ed7b5bb93 Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Thu, 31 Jul 2025 23:58:29 -0400 Subject: [PATCH 33/34] update --- .../workflows/build_publish_lambda_layer.yml | 86 +++++++------------ lambda/build.sh | 11 +-- lambda/otel/Dockerfile | 7 -- 3 files changed, 34 insertions(+), 70 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index 8ffb3442..aa7b4ac6 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -36,12 +36,19 @@ jobs: # build layer on arm64 and amd64, then upload to artifacts # act -j build_layer --container-architecture linux/arm64 build_layer: - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + arch: + - x86_64 + - arm64 + + runs-on: ${{ matrix.arch == 'arm64' && fromJSON('{"group":"apm-arm-runner"}') || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 - - name: Build ruby lambda layer + - name: Build ruby lambda layer on ${{ matrix.arch }} run: | uname -a ./build.sh @@ -52,6 +59,7 @@ jobs: SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} PUBLISH_DEST: ${{ github.event.inputs.publish-dest }} ALLOWED_RUBY_VERSION: ${{ github.event.inputs.ruby-version }} + ARCHITECTURE: ${{ matrix.arch }} - name: Show directory contents run: | @@ -61,57 +69,20 @@ jobs: - name: Upload to artifact uses: actions/upload-artifact@v4 with: - name: ruby-layer.zip - path: lambda/build/ruby-layer.zip - - build_bigdecimal_arm64: - needs: - - build_layer - runs-on: ubuntu-24.04-arm - - steps: - - uses: actions/checkout@v4 - - - name: Build ruby lambda layer on arm64 machine - run: | - uname -a - ./build.sh - shell: bash - working-directory: lambda/ - env: - GITHUB_RUBY_TOKEN: ${{ secrets.PACKAGE_GITHUB_TOKEN }} - SOLARWINDS_SOURCE: ${{ github.event.inputs.solarwinds-source }} - PUBLISH_DEST: ${{ github.event.inputs.publish-dest }} - ALLOWED_RUBY_VERSION: '3.4' - BIGDECIMAL: true - - - name: extract layer zip from artifacts - uses: actions/download-artifact@v4 - with: - name: ruby-layer.zip - path: lambda/build - - - name: Combine to single layer - run: | - unzip ruby-layer.zip - mkdir -p bigdecimal - unzip -q -d bigdecimal/ bigdecimal-aarch64.zip - mkdir -p ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ - mv bigdecimal/ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-* ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/ - zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb - working-directory: lambda/build - - - name: Upload to artifact - uses: actions/upload-artifact@v4 - with: - name: ruby-layer.zip - path: lambda/build/ruby-layer.zip - overwrite: true + name: ruby-layer-${{ matrix.arch }}.zip + path: lambda/build/ruby-layer-${{ matrix.arch }}.zip # extract the built layer from artifacts, then scan it with reverselab reverselab_scan_layer: needs: - - build_bigdecimal_arm64 + - build_layer + strategy: + fail-fast: false + matrix: + arch: + - x86_64 + - arm64 + runs-on: ubuntu-latest outputs: @@ -123,7 +94,7 @@ jobs: - name: extract layer zip from artifacts uses: actions/download-artifact@v4 with: - name: ruby-layer.zip + name: ruby-layer-${{ matrix.arch }}.zip path: lambda - name: extract current solarwinds_apm version @@ -153,7 +124,7 @@ jobs: rl-portal-server: solarwinds rl-portal-org: SolarWinds rl-portal-group: SaaS-Agents-SWO - rl-package-url: solarwinds-apm-ruby/apm-ruby-lambda-layer@${{ env.SOLARWINDS_APM_VERSION }} + rl-package-url: solarwinds-apm-ruby/apm-ruby-lambda-layer-${{ matrix.arch }}@${{ env.SOLARWINDS_APM_VERSION }} - name: report the scan status if: success() || failure() @@ -165,8 +136,8 @@ jobs: publish_layer: needs: - reverselab_scan_layer - runs-on: ubuntu-latest strategy: + fail-fast: false matrix: aws_region: - ap-northeast-1 @@ -185,6 +156,11 @@ jobs: - us-east-2 - us-west-1 - us-west-2 + arch: + - x86_64 + - arm64 + + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -214,9 +190,9 @@ jobs: run: | cd lambda/ aws lambda publish-layer-version \ - --layer-name solarwinds-apm-ruby-${{ env.SOLARWINDS_APM_VERSION }} \ + --layer-name solarwinds-apm-ruby-${{ matrix.arch }}-${{ env.SOLARWINDS_APM_VERSION }} \ --license-info "Apache 2.0" \ - --compatible-architectures x86_64 arm64 \ + --compatible-architectures ${{ matrix.arch }} \ --compatible-runtimes ${{ env.LAMBDA_RUBY_VERSION }} \ --zip-file fileb://ruby-layer.zip \ --query 'LayerVersionArn' \ @@ -224,7 +200,7 @@ jobs: - name: grant permissions to public for the published layer run: | - layer_name=solarwinds-apm-ruby-${{ env.SOLARWINDS_APM_VERSION }} + layer_name=solarwinds-apm-ruby-${{ matrix.arch }}-${{ env.SOLARWINDS_APM_VERSION }} latest_version=$(aws lambda list-layer-versions --layer-name $layer_name | jq -r '.LayerVersions | max_by(.Version) | .Version') aws lambda add-layer-version-permission \ --layer-name $layer_name \ diff --git a/lambda/build.sh b/lambda/build.sh index d9ac504c..00973d73 100755 --- a/lambda/build.sh +++ b/lambda/build.sh @@ -33,11 +33,6 @@ for ruby_version in $ALLOWED_RUBY_VERSION; do unzip -q gems-$ruby_version.0.zip -d ruby/gems/ done -if [ "$BIGDECIMAL" = 'true' ]; then - zip -qr bigdecimal-aarch64.zip ruby/gems/3.4.0/extensions/aarch64-linux/3.4.0/bigdecimal-*/ - rm -rf ruby/ -else - mkdir solarwinds-apm - cp ../otel/layer/otel_wrapper.rb . && cp ../otel/layer/wrapper solarwinds-apm/ - zip -qr ruby-layer.zip ruby/ solarwinds-apm/ otel_wrapper.rb -fi +mkdir solarwinds-apm +cp ../otel/layer/otel_wrapper.rb . && cp ../otel/layer/wrapper solarwinds-apm/ +zip -qr ruby-layer-${ARCHITECTURE}.zip ruby/ solarwinds-apm/ otel_wrapper.rb diff --git a/lambda/otel/Dockerfile b/lambda/otel/Dockerfile index 9d36896a..17f86ed1 100644 --- a/lambda/otel/Dockerfile +++ b/lambda/otel/Dockerfile @@ -14,13 +14,6 @@ RUN ls | grep solarwinds_apm-*.gem > gem_file.txt 2>/dev/null || true RUN gem_file=$(ls | grep solarwinds_apm-*.gem 2>/dev/null || true) && \ gem install ${gem_file:-solarwinds_apm} --install-dir ruby/ruby/${RUBY_VERSION}.0 --no-document -RUN sh -c '(command -v dnf && dnf install -y wget) || (command -v yum && yum install -y wget)' - -ENV ARCH=aarch64 -RUN PROTOBUF_VERSION=$(GEM_PATH=ruby/ruby/${RUBY_VERSION}.0/ ruby -e 'require "google/protobuf"; puts Gem.loaded_specs["google-protobuf"].version.to_s') && \ - wget "https://rubygems.org/downloads/google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" && \ - gem install "google-protobuf-${PROTOBUF_VERSION}-${ARCH}-linux-gnu.gem" --install-dir ruby/ruby/${RUBY_VERSION}.0 --no-document - # Clean up cache and docs RUN rm -rf /build/layer/ruby/ruby/${RUBY_VERSION}.0/cache/* && \ rm -rf /build/layer/ruby/ruby/${RUBY_VERSION}.0/doc/* From d625ddb31a8d9e5d5d7ae317631cbe9b8e7d422e Mon Sep 17 00:00:00 2001 From: xuan-cao-swi Date: Fri, 1 Aug 2025 00:12:25 -0400 Subject: [PATCH 34/34] update --- .github/workflows/build_publish_lambda_layer.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_publish_lambda_layer.yml b/.github/workflows/build_publish_lambda_layer.yml index aa7b4ac6..da844446 100644 --- a/.github/workflows/build_publish_lambda_layer.yml +++ b/.github/workflows/build_publish_lambda_layer.yml @@ -119,7 +119,7 @@ jobs: uses: reversinglabs/gh-action-rl-scanner-cloud-only@v1 with: - artifact-to-scan: ./lambda/ruby-layer.zip + artifact-to-scan: ./lambda/ruby-layer-${{ matrix.arch }}.zip rl-verbose: true rl-portal-server: solarwinds rl-portal-org: SolarWinds @@ -174,7 +174,7 @@ jobs: - name: extract layer zip from artifacts uses: actions/download-artifact@v4 with: - name: ruby-layer.zip + name: ruby-layer-${{ matrix.arch }}.zip path: lambda - name: format version for aws lambda and define lambda ruby version @@ -194,7 +194,7 @@ jobs: --license-info "Apache 2.0" \ --compatible-architectures ${{ matrix.arch }} \ --compatible-runtimes ${{ env.LAMBDA_RUBY_VERSION }} \ - --zip-file fileb://ruby-layer.zip \ + --zip-file fileb://ruby-layer-${{ matrix.arch }}.zip \ --query 'LayerVersionArn' \ --output text