Skip to content

Commit 638b809

Browse files
authored
Merge pull request #293 from Shopify/add-ruby-memcheck
Add ruby memcheck to use valgrind in CI
2 parents fd78071 + 56af3ef commit 638b809

File tree

4 files changed

+44
-1
lines changed

4 files changed

+44
-1
lines changed

.github/workflows/main.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,28 @@ jobs:
2222

2323
- name: Run Ruby tests
2424
run: bundle exec rake
25+
26+
memcheck:
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- name: Install valgrind from source
31+
run: |
32+
sudo apt-get install -y libc6-dbg
33+
wget https://sourceware.org/pub/valgrind/valgrind-3.20.0.tar.bz2
34+
tar xvf valgrind-3.20.0.tar.bz2
35+
cd valgrind-3.20.0
36+
./configure
37+
make
38+
sudo make install
39+
40+
- uses: actions/checkout@v2
41+
42+
- name: Set up Ruby
43+
uses: ruby/setup-ruby@v1
44+
with:
45+
ruby-version: head
46+
bundler-cache: true
47+
48+
- name: Run Ruby tests with valgrind
49+
run: bundle exec rake test:valgrind

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ ruby ">= 3.1.0"
77
gem "rake"
88
gem "rake-compiler"
99
gem "test-unit"
10+
gem "ruby_memcheck"

Gemfile.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
GEM
22
remote: https://rubygems.org/
33
specs:
4+
mini_portile2 (2.8.1)
5+
nokogiri (1.14.2)
6+
mini_portile2 (~> 2.8.0)
7+
racc (~> 1.4)
48
power_assert (2.0.1)
9+
racc (1.6.2)
510
rake (13.0.6)
611
rake-compiler (1.2.0)
712
rake
13+
ruby_memcheck (1.2.0)
14+
nokogiri
815
test-unit (3.5.3)
916
power_assert
1017

@@ -14,6 +21,7 @@ PLATFORMS
1421
DEPENDENCIES
1522
rake
1623
rake-compiler
24+
ruby_memcheck
1725
test-unit
1826

1927
RUBY VERSION

Rakefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
require "rake/extensiontask"
44
require "rake/testtask"
55
require "rake/clean"
6+
require "ruby_memcheck"
7+
8+
RubyMemcheck.config(binary_name: "yarp")
69

710
task compile: :make
811

@@ -13,12 +16,18 @@ Rake::ExtensionTask.new(:compile) do |ext|
1316
ext.gem_spec = Gem::Specification.load("yarp.gemspec")
1417
end
1518

16-
Rake::TestTask.new(test: :compile) do |t|
19+
test_config = lambda do |t|
1720
t.libs << "test"
1821
t.libs << "lib"
1922
t.test_files = FileList["test/**/*_test.rb"]
2023
end
2124

25+
Rake::TestTask.new(test: :compile, &test_config)
26+
27+
namespace :test do
28+
RubyMemcheck::TestTask.new(valgrind: :compile, &test_config)
29+
end
30+
2231
task default: :test
2332

2433
TEMPLATES = [

0 commit comments

Comments
 (0)