From 5455c36a3a35cee6a3f165eb1e50a3e0c2440298 Mon Sep 17 00:00:00 2001 From: Kosei IDE Date: Tue, 20 Sep 2022 15:29:46 +0000 Subject: [PATCH] Use ruby_memcheck in CI Followed https://github.com/Shopify/ruby_memcheck#setup --- .github/workflows/tests.yaml | 13 +++++++++++++ Gemfile | 4 ++++ Rakefile | 6 ++++++ test/helper.rb | 3 +++ 4 files changed, 26 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 75066ef6f1..735e92bb9f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -176,3 +176,16 @@ jobs: Test outcome: ${{ steps.test.outcome }} # every step must define a `uses` or `run` key run: echo NOOP + + valgrind: + runs-on: ubuntu-latest + env: + PUMA_RUBY_MEMCHECK: true + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + bundler-cache: true + apt-get: valgrind + - run: bundle exec rake test:valgrind diff --git a/Gemfile b/Gemfile index 84bdadbac0..8089840e2f 100644 --- a/Gemfile +++ b/Gemfile @@ -21,6 +21,10 @@ unless ENV['PUMA_NO_RUBOCOP'] || RUBY_PLATFORM.include?('mswin') gem 'rubocop-performance', require: false end +if ENV['PUMA_RUBY_MEMCHECK'] && RUBY_PLATFORM.include?('linux') + gem "ruby_memcheck" +end + if RUBY_VERSION == '2.4.1' gem "stopgap_13632", "~> 1.0", :platforms => ["mri", "mingw", "x64_mingw"] end diff --git a/Rakefile b/Rakefile index 5df4980cf0..829fb92f5f 100644 --- a/Rakefile +++ b/Rakefile @@ -104,6 +104,12 @@ namespace :test do desc "Run all tests" task :all => :test + + if ENV['PUMA_RUBY_MEMCHECK'] && RUBY_PLATFORM.include?('linux') + require 'ruby_memcheck' + RubyMemcheck.config(binary_name: 'puma_http11') + RubyMemcheck::TestTask.new(valgrind: :compile) + end end task :default => [:rubocop, "test:all"] diff --git a/test/helper.rb b/test/helper.rb index 6ecc6b3ad3..c066e97466 100644 --- a/test/helper.rb +++ b/test/helper.rb @@ -188,6 +188,8 @@ def self.run(reporter, options = {}) # :nodoc: def full_name "#{self.class.name}##{name}" end + + at_exit { GC.start } end Minitest.after_run do @@ -205,6 +207,7 @@ def full_name end end end + GC.start end module AggregatedResults