From b2edc22b084ec78dd6cdac5d6b7f9abbc95dac2e Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Thu, 22 Feb 2024 09:27:49 -0500 Subject: [PATCH 1/8] Add dockerfile integration test --- .github/workflows/integration.yml | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 1dd038b4..93b37048 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -87,3 +87,42 @@ jobs: run: | cd ./repo ${{ matrix.repo.run }} + dockerfile: + name: Bundle install in Dockerfile + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: ${{ matrix.repo.name }} + ref: ${{ matrix.repo.ref }} + path: repo + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Generate Dockerfile + run: | + echo 'FROM ruby:3.3' > Dockerfile.issue + echo 'FROM ruby:3.3' > Dockerfile.issue + echo 'WORKDIR /app' >> Dockerfile.issue + echo 'RUN apt-get update -qq && \' >> Dockerfile.issue + echo ' apt-get install -y libclang-dev' >> Dockerfile.issue + echo 'COPY Gemfile.issue /app/Gemfile' >> Dockerfile.issue + echo "ADD ./repo/ /rb_sys" >> Dockerfile.issue + echo 'ENV RUBYOPT=-I/rb_sys/gem/lib' >> Dockerfile.issue + echo 'RUN bundle install --verbose --retry=3' >> Dockerfile.issue + cat Dockerfile.issue + + - name: Generate Gemfile + run: | + echo 'source "https://rubygems.org"' > Gemfile.issue + echo "gem('rb_sys', path: '/rb_sys/gem')" >> Gemfile.issue + echo "gem('oxi-test', git: 'https://github.com/oxidize-rb/oxi-test', branch: :main)" >> Gemfile.issue + cat Gemfile.issue + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile.issue + push: false From d1ffd870ff359ed0f1e8daf7c3a7d15e4c5b533e Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Thu, 22 Feb 2024 09:28:12 -0500 Subject: [PATCH 2/8] Fix env var check for RB_SYS_TEST --- gem/lib/rb_sys/cargo_builder.rb | 2 +- gem/lib/rb_sys/mkmf/config.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gem/lib/rb_sys/cargo_builder.rb b/gem/lib/rb_sys/cargo_builder.rb index 99d9ad42..ed1508f3 100644 --- a/gem/lib/rb_sys/cargo_builder.rb +++ b/gem/lib/rb_sys/cargo_builder.rb @@ -328,7 +328,7 @@ def profile_target_directory end def rubygems_invoked? - ENV.key?("SOURCE_DATE_EPOCH") && !ENV["RB_SYS_TEST"] == "1" + ENV.key?("SOURCE_DATE_EPOCH") && ENV["RB_SYS_TEST"] != "1" end # Error raised when no cdylib artifact was created diff --git a/gem/lib/rb_sys/mkmf/config.rb b/gem/lib/rb_sys/mkmf/config.rb index 5912c452..7519fd5f 100644 --- a/gem/lib/rb_sys/mkmf/config.rb +++ b/gem/lib/rb_sys/mkmf/config.rb @@ -55,7 +55,7 @@ def respond_to_missing?(name, include_private = false) # install, to remove bloat. # @api private def rubygems_invoked? - ENV.key?("SOURCE_DATE_EPOCH") && !ENV["RB_SYS_TEST"] == "1" + ENV.key?("SOURCE_DATE_EPOCH") && ENV["RB_SYS_TEST"] != "1" end def use_stable_api_compiled_fallback? From 23dd8a175a775e48218cea00c362e5b45e547639 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Thu, 22 Feb 2024 09:28:27 -0500 Subject: [PATCH 3/8] Fix rb_gc_guard test --- crates/rb-sys-tests/src/memory_test.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/rb-sys-tests/src/memory_test.rs b/crates/rb-sys-tests/src/memory_test.rs index 68df4695..4d60d06f 100644 --- a/crates/rb-sys-tests/src/memory_test.rs +++ b/crates/rb-sys-tests/src/memory_test.rs @@ -26,26 +26,26 @@ fn test_rb_gc_guarded_ptr_vec() { let mut vec_of_values: Vec = Default::default(); let s1 = rb_str_new_cstr(format!("hello world{i}\0").as_ptr() as _); + let s1 = rb_gc_guard!(s1); vec_of_values.push(s1); let s2 = rb_str_new_cstr(format!("hello world{i}\0").as_ptr() as _); + let s2 = rb_gc_guard!(s2); vec_of_values.push(s2); let s3 = rb_str_new_cstr(format!("hello world{i}\0").as_ptr() as _); + let s3 = rb_gc_guard!(s3); vec_of_values.push(s3); let ptr = &vec_of_values.as_ptr(); let len = &vec_of_values.len(); let rarray = rb_sys::rb_ary_new_from_values(*len as _, *ptr); - let mut inspected = rb_sys::rb_inspect(rarray); - let result = rstring_to_string!(inspected); + let rarray = rb_gc_guard!(rarray); - let _ = rb_gc_guard!(s1); - let _ = rb_gc_guard!(s2); - let _ = rb_gc_guard!(s3); - let _ = rb_gc_guard!(rarray); - let _ = rb_gc_guard!(inspected); + let inspected = rb_sys::rb_inspect(rarray); + let mut inspected = rb_gc_guard!(inspected); + let result = rstring_to_string!(inspected); assert_eq!( result, From c735f837033f135bad1ac4d3c134799abd16b467 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Thu, 22 Feb 2024 09:34:29 -0500 Subject: [PATCH 4/8] Upload core dumps --- .github/workflows/ci.yml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d03b8fe3..8508f7fc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,6 +58,8 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: oxidize-rb/actions/upload-core-dumps@v1 + - name: Setup debug info shell: bash run: script/ci/set-debug-env.sh @@ -89,11 +91,15 @@ jobs: shell: bash env: RB_SYS_CARGO_PROFILE: "release" - run: script/ci/upload-on-failure.sh "bundle exec rake test:examples" "examples-test" "./examples" + run: | + ulimit -c unlimited + script/ci/upload-on-failure.sh "bundle exec rake test:examples" "examples-test" "./examples" - name: 🧪 Cargo test shell: bash - run: bundle exec rake test:cargo + run: | + ulimit -c unlimited + bundle exec rake test:cargo - name: 💎 Gem test run: bundle exec rake test:gem @@ -102,6 +108,7 @@ jobs: shell: bash run: | set -ex + ulimit -c unlimited gem update --system 3.3.22 > /dev/null export RUBYOPT="-I$PWD/gem/lib" pushd examples/rust_reverse @@ -149,6 +156,8 @@ jobs: steps: - uses: actions/checkout@v4 + - uses: oxidize-rb/actions/upload-core-dumps@v1 + - uses: oxidize-rb/actions/setup-ruby-and-rust@v1 with: ruby-version: none @@ -185,4 +194,7 @@ jobs: run: bundle install -j3 - name: 🧪 Run tests - run: bundle exec rake test + shell: bash + run: | + ulimit -c unlimited + bundle exec rake test From 54f4f8aec6b1029043534feec05ece4fa77d9d43 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Thu, 22 Feb 2024 09:35:33 -0500 Subject: [PATCH 5/8] Upload core dumps --- .github/workflows/ci.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8508f7fc..280cd957 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,11 +49,6 @@ jobs: sys: os: windows-2022 rust_toolchain: stable-x86_64-pc-windows-msvc - exclude: - - ruby_version: 3.3 # remove this once Ruby 3.3 binaries are available for windows - sys: - os: windows-2022 - rust_toolchain: stable runs-on: ${{ matrix.sys.os }} steps: - uses: actions/checkout@v4 From 8499139f7343935678ec48e92424113fd2786447 Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Thu, 22 Feb 2024 09:41:42 -0500 Subject: [PATCH 6/8] Skip ruby-head for now --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 280cd957..619081f6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,7 +34,7 @@ jobs: fail-fast: false matrix: # Test against all versions supported by rubygems - ruby_version: ["2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "head"] + ruby_version: ["2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3"] sys: - os: ubuntu-latest rust_toolchain: ${{ needs.fetch_ci_data.outputs.minimum-supported-rust-version }} From efe6b64a44137fa9394ec7baab2b51aaf167c65d Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Thu, 22 Feb 2024 09:43:54 -0500 Subject: [PATCH 7/8] Skip ruby-head for now --- .github/workflows/integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 93b37048..c4b372c4 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -31,7 +31,7 @@ jobs: run: cargo test os: ["ubuntu-latest", "windows-latest", "macos-latest"] rust: ["stable"] - ruby: ["2.7", "3.2", "3.3", "ruby-head"] + ruby: ["2.7", "3.2", "3.3"] exclude: - os: windows-latest ruby: '3.3' # remove this once 3.3 binaries are available for windows From 48fd66806d03f0e100f3d1725d73ec718874c3cb Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Thu, 22 Feb 2024 09:51:22 -0500 Subject: [PATCH 8/8] Skip mswin for now --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 619081f6..c66db56d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,6 +92,7 @@ jobs: - name: 🧪 Cargo test shell: bash + if: matrix.ruby_version != 'mswin' run: | ulimit -c unlimited bundle exec rake test:cargo