diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c06b01c..7f28ced 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -452,3 +452,20 @@ jobs: path: pkg - run: apk add bash libstdc++ gcompat - run: ./scripts/test-gem-install + + ruby-memcheck: + runs-on: "ubuntu-latest" + env: + BUNDLE_WITH: memcheck + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v4 + with: + path: ports/archives + key: archives-ubuntu-${{ hashFiles('ext/re2/extconf.rb') }} + - uses: ruby/setup-ruby-pkgs@v1 + with: + ruby-version: "3.3" + apt-get: valgrind + bundler-cache: true + - run: bundle exec rake spec:valgrind diff --git a/Gemfile b/Gemfile index aaa7f6f..f15724c 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,7 @@ source "https://rubygems.org" gemspec gem "rake", "> 12.3.2" + +group :memcheck, optional: true do + gem "ruby_memcheck" +end diff --git a/Rakefile b/Rakefile index 918589e..2ec6560 100644 --- a/Rakefile +++ b/Rakefile @@ -46,6 +46,17 @@ end RSpec::Core::RakeTask.new(:spec) +begin + require 'ruby_memcheck' + require 'ruby_memcheck/rspec/rake_task' + + namespace :spec do + RubyMemcheck::RSpec::RakeTask.new(valgrind: :compile) + end +rescue LoadError + # Only define the spec:valgrind task if ruby_memcheck is installed +end + namespace :gem do cross_platforms.each do |platform|