From a676a7d96247c8ada4af4adfa73f0db5bff95dd7 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Tue, 4 Aug 2026 18:00:44 +0200 Subject: [PATCH] Make `ruby_memcheck` optional It consistently fails CI when nokogiri tries to install from source. But those steps don't actually need it and the nokogiri version with this fix is still quite a long while out. --- .github/workflows/main.yml | 3 ++- Gemfile | 11 ++++------- rakelib/test.rake | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e0b47ddf8f..782afad346 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -259,7 +259,8 @@ jobs: memcheck: runs-on: ubuntu-24.04 env: - BUNDLER_VERSION: '0' # https://github.com/ruby/ruby/pull/16909 + BUNDLE_WITH: 'memcheck' + BUNDLER_VERSION: '0' steps: - uses: actions/checkout@v7 - name: Install valgrind diff --git a/Gemfile b/Gemfile index 5fd9650c6b..77fdd58607 100644 --- a/Gemfile +++ b/Gemfile @@ -15,16 +15,13 @@ gem "test-unit" platforms :mri, :windows do gem "ffi" gem "irb" - gem "ruby_memcheck" gem "rdoc" + + group :memcheck, optional: true do + gem "ruby_memcheck" + end end gem "onigmo", platforms: :ruby -# Until a nokogiri release includes sparklemotion/nokogiri#3530, aarch64-mingw-ucrt -# source-builds of libxml2 fail in libtool. Pin to main on that platform only. -if RUBY_PLATFORM =~ /aarch64.*mingw/ - gem "nokogiri", github: "sparklemotion/nokogiri", branch: "main" -end - gem "lrama" diff --git a/rakelib/test.rake b/rakelib/test.rake index 4257202bc8..6ed6dac64b 100644 --- a/rakelib/test.rake +++ b/rakelib/test.rake @@ -46,16 +46,17 @@ return if RUBY_ENGINE == "jruby" || RUBY_ENGINE == "truffleruby" # Don't bother trying to configure memcheck on old versions of Ruby. return if RUBY_VERSION < "3.0" -# Only attempt to configure memcheck if the gem is installed. -begin - require "ruby_memcheck" -rescue LoadError - return -end - namespace :test do - RubyMemcheck.config(use_only_ruby_free_at_exit: false) - RubyMemcheck::TestTask.new(valgrind_internal: :compile, &config) + begin + require "ruby_memcheck" + RubyMemcheck.config(use_only_ruby_free_at_exit: false) + RubyMemcheck::TestTask.new(valgrind_internal: :compile, &config) + rescue LoadError + task :valgrind_internal do + puts "\e[31mruby_memcheck gem not available. Try running with BUNDLE_WITH=memcheck\e[0m" + exit 1 + end + end # Hide test:valgrind_internal from rake -T Rake::Task["test:valgrind_internal"].clear_comments