From ad84b59224d05a25ae059f157148405673292e3a Mon Sep 17 00:00:00 2001 From: Paul Mucur Date: Fri, 10 May 2024 13:23:11 +0100 Subject: [PATCH] Run ruby_memcheck in CI So we can catch any new memory leaks, run ruby_memcheck as part of the build. Note we skip installing ruby_memcheck for all jobs by default and opt into it explicitly. --- .github/workflows/tests.yml | 17 +++++++++++++++++ Gemfile | 4 ++++ Rakefile | 11 +++++++++++ 3 files changed, 32 insertions(+) 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|