Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/valgrind.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Memcheck

on: [push, pull_request]

permissions:
contents: read

jobs:
test:
name: ${{matrix.ruby}} on ${{matrix.os}}
runs-on: ${{matrix.os}}-latest
continue-on-error: ${{matrix.experimental}}

strategy:
matrix:
os:
- ubuntu

ruby:
- "3.2"
- "3.3"
- "3.4"
- "4.0"

experimental: [false]

include:
- os: ubuntu
ruby: head
experimental: true

steps:
- uses: actions/checkout@v6
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{matrix.ruby}}
bundler-cache: true
- name: Install Valgrind
run: sudo apt-get install -y valgrind
- name: Run tests
timeout-minutes: 10
run: bundle exec rake spec:valgrind
23 changes: 5 additions & 18 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,11 @@ namespace :build do
end
end

# adapted from http://flavoriffic.blogspot.com/2009/06/easily-valgrind-gdb-your-ruby-c.html
def specs_command
require "find"
files = []
Find.find("spec") do |f|
files << f if File.basename(f) =~ /.*spec.*\.rb$/
end
cmdline = "#{RUBY} -I.:lib:ext:spec \
-e '%w[#{files.join(' ')}].each { |f| require f }'"
end

namespace :spec do
desc "run specs with valgrind"
task :valgrind => :compile do
system "valgrind --num-callers=15 \
--partial-loads-ok=yes --undef-value-errors=no \
--tool=memcheck --leak-check=yes --track-fds=yes \
--show-reachable=yes #{specs_command}"
if RUBY_PLATFORM.include?('linux')
require 'ruby_memcheck'
require 'ruby_memcheck/rspec/rake_task'
namespace :spec do
RubyMemcheck::RSpec::RakeTask.new(valgrind: :compile)
end
end

Expand Down
4 changes: 4 additions & 0 deletions gems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@
gem "bake-gem"
gem "bake-modernize"
end

group :development, :test do
gem 'ruby_memcheck', '~> 3.0' if RUBY_PLATFORM.include?('linux')
end
Loading