-
Notifications
You must be signed in to change notification settings - Fork 241
feat(ruby): build and release layer for both amd64 and arm64 architec… #2349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 7 commits
0859a60
7741d8d
ddf4cfb
d885bc1
a01610e
7b4af32
20f2e4d
8ce68cd
79a6daa
59b5ccf
cf913b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,28 +1,43 @@ | ||
| 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: 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" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,20 +66,32 @@ jobs: | |
| build-layer: | ||
| needs: prepare-languages | ||
| if: ${{ !inputs.use-existing-layer-artifact }} | ||
| runs-on: ubuntu-latest | ||
| runs-on: ${{ matrix.runner }} | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| language: ${{ fromJson(needs.prepare-languages.outputs.languages) }} | ||
| runner: ["ubuntu-latest"] | ||
| include: | ||
| - language: ruby | ||
| architecture: amd64 | ||
| runner: ubuntu-latest | ||
| - language: ruby | ||
| architecture: arm64 | ||
|
DCchoudhury15 marked this conversation as resolved.
|
||
| runner: ubuntu-24.04-arm | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how this will work when triggered for a single (non-ruby) language like |
||
| 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: | ||
|
|
@@ -111,7 +123,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 | ||
|
|
@@ -148,6 +163,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 }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,21 +11,53 @@ permissions: | |
|
|
||
| jobs: | ||
| build-layer: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| component-version: ${{ steps.build.outputs.component-version }} | ||
| runs-on: ${{ matrix.architecture == 'arm64' && 'ubuntu-24.04-arm' || 'ubuntu-latest' }} | ||
| 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" | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 For the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @wpessers changes up for review |
||
| integration-test: | ||
| permissions: | ||
| contents: read | ||
|
|
@@ -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 | ||
|
|
@@ -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 }} | ||
|
|
||
| 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" |
There was a problem hiding this comment.
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.