Skip to content

Commit

Permalink
Run ruby_memcheck in CI
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mudge committed May 10, 2024
1 parent f3e094c commit ad84b59
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ source "https://rubygems.org"
gemspec

gem "rake", "> 12.3.2"

group :memcheck, optional: true do
gem "ruby_memcheck"
end
11 changes: 11 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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|

Expand Down

0 comments on commit ad84b59

Please sign in to comment.