Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/actions/build-layer/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ inputs:
language:
description: 'Language of the layer to build (nodejs, python, ruby, javaagent, javawrapper)'
required: true
architecture:
description: 'Target architecture (amd64 or arm64). Only used for ruby.'
required: false
default: amd64

outputs:
artifact-path:
Expand All @@ -28,6 +32,8 @@ runs:
- if: ${{ inputs.language == 'ruby' }}
id: ruby
uses: ./.github/actions/build-ruby-layer
with:
architecture: ${{ inputs.architecture }}

- if: ${{ inputs.language == 'javaagent' || inputs.language == 'javawrapper' }}
id: java
Expand Down
27 changes: 24 additions & 3 deletions .github/actions/build-ruby-layer/action.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,49 @@
name: 'Build Ruby Lambda Layer'
description: 'Builds the OpenTelemetry Ruby Lambda layer'

inputs:
architecture:
description: 'Target architecture (amd64 or arm64)'
required: false
default: amd64

outputs:
artifact-path:
description: 'Absolute path to the layer zip artifact'
value: ${{ github.workspace }}/ruby/src/build/opentelemetry-ruby-layer.zip
value: ${{ github.workspace }}/ruby/src/build/opentelemetry-ruby-layer-${{ inputs.architecture }}.zip
component-version:
description: 'OpenTelemetry Ruby SDK version included in the layer'
value: ${{ steps.version.outputs.component-version }}
value: ${{ steps.version.outputs.component-version || steps.version-skip.outputs.component-version }}

runs:
using: composite
steps:
- name: Set up QEMU for cross-platform builds
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0

- name: Build Ruby layer
shell: bash
working-directory: ruby/src
env:
ARCH: ${{ inputs.architecture }}
run: ./build.sh

- name: Save Ruby OpenTelemetry SDK version
if: ${{ inputs.architecture == 'amd64' }}
id: version
shell: bash
working-directory: ruby/src
run: |
unzip -q build/opentelemetry-ruby-layer.zip
unzip -q build/opentelemetry-ruby-layer-amd64.zip
export GEM_PATH=$PWD/ruby/gems/3.3.0/
SDK_VERSION=$(ruby -e 'require "opentelemetry-sdk"; puts OpenTelemetry::SDK::VERSION')
echo "component-version=$SDK_VERSION" >> "$GITHUB_OUTPUT"

- name: Skip version output for non-amd64
if: ${{ inputs.architecture != 'amd64' }}
id: version-skip
shell: bash
run: echo "component-version=" >> "$GITHUB_OUTPUT"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this quite confusing, you seem to have done a lot of work here and in the release workflow to skip outputting the version. IIRC the collector release has the same matrixed amd64/arm64 build and handles this with no such extra logic. As I said earlier, might be worth taking a look how the collector builds / releases are setup. Let me reiterate that you're basically building the same mechanism that is already in place there.

35 changes: 32 additions & 3 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,29 @@ jobs:
fail-fast: false
matrix:
language: ${{ fromJson(needs.prepare-languages.outputs.languages) }}
architecture: [amd64, arm64]
exclude:
- language: nodejs
architecture: arm64
- language: python
architecture: arm64
- language: javaagent
architecture: arm64
- language: javawrapper
architecture: arm64
Comment thread
DCchoudhury15 marked this conversation as resolved.
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: ./.github/actions/build-layer
id: build
with:
language: ${{ matrix.language }}
architecture: ${{ matrix.architecture }}
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: opentelemetry-${{ matrix.language }}-layer.zip
name: >-
${{ matrix.language == 'ruby'
&& format('opentelemetry-ruby-layer-{0}.zip', matrix.architecture)
|| format('opentelemetry-{0}-layer.zip', matrix.language) }}
path: ${{ steps.build.outputs.artifact-path }}

test:
Expand All @@ -93,6 +107,15 @@ jobs:
matrix:
language: ${{ fromJson(needs.prepare-languages.outputs.languages) }}
architecture: [amd64, arm64]
exclude:
- language: nodejs
architecture: arm64
- language: python
architecture: arm64
- language: javaagent
architecture: arm64
- language: javawrapper
architecture: arm64
runs-on: ubuntu-latest
permissions:
contents: read
Expand All @@ -111,7 +134,10 @@ jobs:

- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: opentelemetry-${{ matrix.language }}-layer.zip
name: >-
${{ matrix.language == 'ruby'
&& format('opentelemetry-ruby-layer-{0}.zip', matrix.architecture)
|| format('opentelemetry-{0}-layer.zip', matrix.language) }}
path: artifacts/

- uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
Expand Down Expand Up @@ -148,6 +174,9 @@ jobs:
TEST_LANGUAGE: ${{ matrix.language }}
TEST_ARCHITECTURE: ${{ matrix.architecture }}
COLLECTOR_LAYER_ZIP: ${{ github.workspace }}/artifacts/opentelemetry-collector-layer-${{ matrix.architecture }}.zip
INSTRUMENTATION_LAYER_ZIP: ${{ github.workspace }}/artifacts/opentelemetry-${{ matrix.language }}-layer.zip
INSTRUMENTATION_LAYER_ZIP: >-
${{ matrix.language == 'ruby'
&& format('{0}/artifacts/opentelemetry-ruby-layer-{1}.zip', github.workspace, matrix.architecture)
|| format('{0}/artifacts/opentelemetry-{1}-layer.zip', github.workspace, matrix.language) }}
GITHUB_RUN_ID: ${{ github.run_id }}
GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }}
62 changes: 52 additions & 10 deletions .github/workflows/release-layer-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,52 @@ permissions:
jobs:
build-layer:
runs-on: ubuntu-latest
outputs:
component-version: ${{ steps.build.outputs.component-version }}
strategy:
fail-fast: false
matrix:
architecture:
- amd64
- arm64
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- uses: ./.github/actions/build-ruby-layer
id: build
with:
architecture: ${{ matrix.architecture }}

- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
name: Save assembled layer to build
with:
name: opentelemetry-ruby-layer.zip
name: opentelemetry-ruby-layer-${{ matrix.architecture }}.zip
path: ${{ steps.build.outputs.artifact-path }}

- name: Save component version to file (amd64 only)
if: ${{ matrix.architecture == 'amd64' }}
shell: bash
run: echo "${{ steps.build.outputs.component-version }}" > component-version.txt

- name: Upload component version artifact (amd64 only)
if: ${{ matrix.architecture == 'amd64' }}
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ruby-component-version
path: component-version.txt

get-version:
runs-on: ubuntu-latest
needs: [build-layer]
outputs:
component-version: ${{ steps.read-version.outputs.version }}
steps:
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: ruby-component-version

- id: read-version
shell: bash
run: echo "version=$(cat component-version.txt)" >> "$GITHUB_OUTPUT"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here, can we please take a look at the collector release workflow? I'm not convinced that we need all of this stuff.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @wpessers, Thanks for your patience and for pointing me back to the collector pattern , that was definitely the right approach.

For integration-test.yml, I originally tried using runner + include to assign the native arm64 runner only to Ruby builds. I overlooked the fact that include adds extra matrix combinations rather than modifying existing ones, which would have caused the Ruby tests to run with every non-Ruby language trigger as well. I've switched to using exclude instead, which is much cleaner and avoids that issue entirely.

For the version-skip step and get-version job in the release workflow, I was trying to prevent a matrix race condition where the arm64 shard finishing last might overwrite the component-version output with an empty value. After taking another look at the collector workflow, I realized it already handles this cleanly with an if: architecture == 'amd64' guard on the version step and a direct outputs reference. I was overthinking it, so I've reverted the implementation to match the collector pattern.Again than you for your patience and guidance.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wpessers changes up for review

integration-test:
permissions:
contents: read
Expand All @@ -52,21 +84,30 @@ jobs:

- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: opentelemetry-ruby-layer.zip
name: opentelemetry-ruby-layer-amd64.zip

- name: Add Binary to Release
run: gh release upload ${{ github.ref_name }} opentelemetry-ruby-layer.zip
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: opentelemetry-ruby-layer-arm64.zip

- name: Add Binaries to Release
run: |
gh release upload ${{ github.ref_name }} opentelemetry-ruby-layer-amd64.zip
gh release upload ${{ github.ref_name }} opentelemetry-ruby-layer-arm64.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-layer:
permissions: # required by the reusable workflow
permissions:
contents: read
id-token: write
uses: ./.github/workflows/layer-publish.yml
needs: [build-layer, create-release]
needs: [build-layer, create-release, get-version]
strategy:
matrix:
architecture:
- amd64
- arm64
aws_region:
- af-south-1
- ap-east-1
Expand Down Expand Up @@ -103,9 +144,10 @@ jobs:
- us-west-1
- us-west-2
with:
artifact-name: opentelemetry-ruby-layer.zip
artifact-name: opentelemetry-ruby-layer-${{ matrix.architecture }}.zip
layer-name: opentelemetry-ruby
component-version: ${{ needs.build-layer.outputs.component-version }}
component-version: ${{ needs.get-version.outputs.component-version }}
architecture: ${{ matrix.architecture }}
runtimes: ruby3.3 ruby3.4
release-group: prod
aws_region: ${{ matrix.aws_region }}
Expand Down
13 changes: 11 additions & 2 deletions ruby/src/build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#!/bin/sh
set -e

ARCH=${ARCH:-amd64}
PLATFORM="linux/${ARCH}"

mkdir -p build

docker build --progress plain -t aws-otel-lambda-ruby-layer otel
docker run --rm -v "$(pwd)/build:/out" aws-otel-lambda-ruby-layer
docker build --progress plain --platform "$PLATFORM" \
-t "aws-otel-lambda-ruby-layer-${ARCH}" otel

docker run --rm --platform "$PLATFORM" \
-v "$(pwd)/build:/out" \
"aws-otel-lambda-ruby-layer-${ARCH}"

mv build/opentelemetry-ruby-layer.zip "build/opentelemetry-ruby-layer-${ARCH}.zip"