Skip to content

Commit

Permalink
ci: use ruby_memcheck to look for leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Dec 10, 2021
1 parent 5cf53bf commit 00fb5ce
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -297,3 +297,26 @@ jobs:
bundle install --local || bundle install
bundle exec rake compile -- --${{matrix.sys}}-system-libraries
bundle exec rake test
memcheck:
continue-on-error: true # this is experimental!
strategy:
fail-fast: false
matrix:
sys: ["disable"]
ruby: ["3.0"]
runs-on: ubuntu-latest
container:
image: ghcr.io/sparklemotion/nokogiri-test:mri-${{matrix.ruby}}
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/cache@v2
if: matrix.sys == 'disable'
with:
path: ports
key: ports-ubuntu-${{hashFiles('dependencies.yml', 'patches/**/*.patch')}}
- run: bundle install --local || bundle install
- run: bundle exec rake compile -- --${{matrix.sys}}-system-libraries
- run: bundle exec rake test:memcheck
1 change: 1 addition & 0 deletions nokogiri.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency("rubocop-performance", "~> 1.11")
spec.add_development_dependency("rubocop-rake", "~> 0.6")
spec.add_development_dependency("rubocop-shopify", "~> 2.3")
spec.add_development_dependency("ruby_memcheck", "~> 1.0")
spec.add_development_dependency("simplecov", "~> 0.20")

spec.extensions << "ext/nokogiri/extconf.rb"
Expand Down
10 changes: 10 additions & 0 deletions rakelib/test.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require "rake/testtask"
require "ruby_memcheck"

#
# much of this was ripped out of hoe-debugging
Expand All @@ -15,6 +16,11 @@ class ValgrindTestTask < Rake::TestTask
"--error-exitcode=#{ERROR_EXITCODE}",
"--gen-suppressions=all",]

RubyMemcheck.config(
binary_name: "nokogiri",
valgrind_generate_suppressions: true,
)

def ruby(*args, **options, &block)
valgrind_options = check_for_suppression_file(VALGRIND_OPTIONS)
command = "ulimit -s unlimited && valgrind #{valgrind_options.join(" ")} #{RUBY} #{args.join(" ")}"
Expand Down Expand Up @@ -96,4 +102,8 @@ namespace "test" do
LldbTestTask.new("lldb") do |t|
nokogiri_test_task_configuration(t)
end

RubyMemcheck::TestTask.new("memcheck") do |t|
nokogiri_test_task_configuration(t)
end
end
4 changes: 4 additions & 0 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
# - "stress" - run tests with GC.stress set to true
# - NOKOGIRI_GC: read more in test/test_memory_leak.rb
#

# make sure we do one final major before the process exits (for valgrind)
at_exit { GC.start(full_mark: true) } unless ::RUBY_PLATFORM == "java"

require "simplecov"
SimpleCov.start do
add_filter "/test/"
Expand Down

0 comments on commit 00fb5ce

Please sign in to comment.