-
Notifications
You must be signed in to change notification settings - Fork 0
Validate #45
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?
Validate #45
Changes from all commits
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 |
|---|---|---|
|
|
@@ -150,7 +150,15 @@ jobs: | |
| path: vendor-${{ matrix.platform.ruby_platform }}.tar | ||
|
|
||
| package: | ||
| name: Package | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| gem_platform: | ||
| - x86_64-linux | ||
| - aarch64-linux | ||
| - arm64-darwin | ||
| - ruby | ||
| name: Package (${{ matrix.gem_platform }}) | ||
| needs: [build-linux, build-macos] | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
|
|
@@ -169,10 +177,107 @@ jobs: | |
| for tarball in vendor-*.tar; do | ||
| tar xf "${tarball}" | ||
| done | ||
| - name: Package gems | ||
| run: bundle exec rake package | ||
| - name: Upload gems | ||
| - name: Package gem | ||
| run: bundle exec rake "gem:package[${{ matrix.gem_platform }}]" | ||
| - name: Upload gem | ||
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | ||
| with: | ||
| name: gems | ||
| name: gem-${{ matrix.gem_platform }} | ||
| path: pkg/*.gem | ||
|
|
||
| validate-linux: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| gem_source: [binary, ruby] | ||
| platform: | ||
| - ruby_platform: x86_64-linux | ||
| gem_platform: x86_64-linux | ||
| base: ubuntu-24.04 | ||
| image: ghcr.io/datadog/images-rb/engines/ruby:4.0-gnu-gcc | ||
| - ruby_platform: x86_64-linux-musl | ||
| gem_platform: x86_64-linux | ||
| base: ubuntu-24.04 | ||
| image: ghcr.io/datadog/images-rb/engines/ruby:4.0-musl-gcc | ||
| - ruby_platform: aarch64-linux | ||
| gem_platform: aarch64-linux | ||
| base: ubuntu-24.04-arm | ||
| image: ghcr.io/datadog/images-rb/engines/ruby:4.0-gnu-gcc | ||
| - ruby_platform: aarch64-linux-musl | ||
| gem_platform: aarch64-linux | ||
| base: ubuntu-24.04-arm | ||
| image: ghcr.io/datadog/images-rb/engines/ruby:4.0-musl-gcc | ||
| name: Validate (${{ matrix.platform.ruby_platform }}, ${{ matrix.gem_source }}) | ||
| needs: [package] | ||
| runs-on: ${{ matrix.platform.base }} | ||
| steps: | ||
| - name: Download gem | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| name: gem-${{ matrix.gem_source == 'ruby' && 'ruby' || matrix.platform.gem_platform }} | ||
| path: pkg | ||
| - name: Start container | ||
| run: docker run --rm --detach --name validate --volume "${PWD}:${PWD}" -w "${PWD}" ${{ matrix.platform.image }} sleep 86400 | ||
| - name: Install gem | ||
| run: docker exec validate gem install pkg/*.gem | ||
| - name: Validate gem | ||
| run: | | ||
| docker exec validate ruby -e ' | ||
| require "libdatadog" | ||
| puts "version: #{Libdatadog::VERSION}" | ||
| puts "platform: #{RUBY_PLATFORM}" | ||
| puts "binaries: #{Libdatadog.available_binaries}" | ||
| puts "pkgconfig: #{Libdatadog.pkgconfig_folder}" | ||
| puts "receiver: #{Libdatadog.path_to_crashtracking_receiver_binary}" | ||
| raise "pkgconfig_folder is nil" unless Libdatadog.pkgconfig_folder | ||
| raise "crashtracking receiver not found" unless Libdatadog.path_to_crashtracking_receiver_binary | ||
| ' | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| sparse-checkout: spec/smoke | ||
| - name: Smoke test (compile and run C program against libdatadog) | ||
| run: docker exec validate ruby spec/smoke/run.rb | ||
| - name: Stop container | ||
| if: always() | ||
| run: docker stop validate || true | ||
|
|
||
| validate-macos: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| gem_source: [binary, ruby] | ||
| platform: | ||
| - ruby_platform: arm64-darwin | ||
| gem_platform: arm64-darwin | ||
| base: macos-15 | ||
| name: Validate (${{ matrix.platform.ruby_platform }}, ${{ matrix.gem_source }}) | ||
| needs: [package] | ||
| runs-on: ${{ matrix.platform.base }} | ||
| steps: | ||
| - uses: ruby/setup-ruby@7372622e62b60b3cb750dcd2b9e32c247ffec26a # v1.302.0 | ||
| with: | ||
| ruby-version: "4.0" | ||
| - name: Download gem | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| name: gem-${{ matrix.gem_source == 'ruby' && 'ruby' || matrix.platform.gem_platform }} | ||
| path: pkg | ||
| - name: Install gem | ||
| run: gem install pkg/*.gem | ||
| - name: Validate gem | ||
| run: | | ||
| ruby -e ' | ||
| require "libdatadog" | ||
| puts "version: #{Libdatadog::VERSION}" | ||
| puts "platform: #{RUBY_PLATFORM}" | ||
| puts "binaries: #{Libdatadog.available_binaries}" | ||
| puts "pkgconfig: #{Libdatadog.pkgconfig_folder}" | ||
| puts "receiver: #{Libdatadog.path_to_crashtracking_receiver_binary}" | ||
| raise "pkgconfig_folder is nil" unless Libdatadog.pkgconfig_folder | ||
| raise "crashtracking receiver not found" unless Libdatadog.path_to_crashtracking_receiver_binary | ||
| ' | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| sparse-checkout: spec/smoke | ||
| - name: Smoke test (compile and run C program against libdatadog) | ||
| run: ruby spec/smoke/run.rb | ||
|
Comment on lines
+210
to
+283
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. Minor: Maybe we could combine these, to avoid having two variants of the logic (It needs two variants because we can't say "use docker on linux; don't use docker on macOS") |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,9 @@ | |
| /.envrc | ||
| /.direnv | ||
|
|
||
| # smoke test compiled binary | ||
| /spec/smoke/smoke_test | ||
|
|
||
| # temporary files | ||
| *~ | ||
| *.swp | ||
|
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. Minor: We discussed that this setup may get out-of-sync with how dd-trace-rb consumes libdatadog-rb; and that we could have a very small gem to try to mimic things more closely but not for this PR. (maybe never?) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "libdatadog" | ||
|
|
||
| pkgconfig_folder = Libdatadog.pkgconfig_folder | ||
| abort "FAIL: Libdatadog.pkgconfig_folder returned nil (no binaries for #{RUBY_PLATFORM}?)" unless pkgconfig_folder | ||
|
|
||
| libdir = File.expand_path("../../lib", pkgconfig_folder) | ||
| includedir = File.expand_path("../../include", pkgconfig_folder) | ||
|
|
||
| src = File.expand_path("smoke_test.c", __dir__) | ||
| out = File.expand_path("smoke_test", __dir__) | ||
|
|
||
| # Compile | ||
| cc = ENV.fetch("CC", "cc") | ||
| compile_cmd = [cc, "-o", out, src, "-I#{includedir}", "-L#{libdir}", "-ldatadog_profiling", "-Wl,-rpath,#{libdir}"] | ||
| puts "Compiling: #{compile_cmd.join(" ")}" | ||
| unless system(*compile_cmd) | ||
| abort "FAIL: compilation failed" | ||
| end | ||
|
|
||
| # Run | ||
| puts "Running: #{out}" | ||
| unless system(out) | ||
| abort "FAIL: smoke test binary exited with non-zero status" | ||
| end | ||
|
|
||
| puts "PASS" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // Minimal smoke test for the libdatadog Rust↔C FFI. | ||
| // Creates a tag vector, pushes a tag, and verifies the round-trip works. | ||
|
|
||
| #include <stdio.h> | ||
| #include <datadog/common.h> | ||
|
|
||
| int main(void) { | ||
| ddog_Vec_Tag tags = ddog_Vec_Tag_new(); | ||
|
|
||
| ddog_Vec_Tag_PushResult result = | ||
| ddog_Vec_Tag_push(&tags, DDOG_CHARSLICE_C("test.key"), DDOG_CHARSLICE_C("test.value")); | ||
|
|
||
| if (result.tag != DDOG_VEC_TAG_PUSH_RESULT_OK) { | ||
| ddog_CharSlice msg = ddog_Error_message(&result.err); | ||
| fprintf(stderr, "FAIL: ddog_Vec_Tag_push error: %.*s\n", (int)msg.len, msg.ptr); | ||
| ddog_Error_drop(&result.err); | ||
| ddog_Vec_Tag_drop(tags); | ||
| return 1; | ||
| } | ||
|
|
||
| ddog_Vec_Tag_drop(tags); | ||
|
|
||
| printf("OK: libdatadog FFI smoke test passed\n"); | ||
| return 0; | ||
| } |
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.
Minor: We discussed that here we actually download all of the binary tarballs; but it's kinda awkward to describe that in github, so for now every run downloads every tarball.
Also it would be nice to only download the ones we need to make sure we don't package anything extra, but probably not for this PR.
We could also do all the packaging in one step, but maybe not for now.