Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restrict minimum Rails version to 6.1, adjust test matrix, and related changes #9

Merged
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
30 changes: 0 additions & 30 deletions .github/workflows/build.yml

This file was deleted.

25 changes: 25 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Lint

on:
pull_request:
push:
branches:
- '**'
tags-ignore:
- 'v*'

jobs:
rubocop:
# Skip running tests for local pull requests (use push event instead), run only for foreign ones
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
name: Standard.rb
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.1"
bundler-cache: true
- name: Lint Ruby code with Standard.rb
run: |
bundle exec rake standard
36 changes: 36 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Tests

on:
pull_request:
push:
branches:
- '**'
tags-ignore:
- 'v*'

jobs:
test:
name: 'Rails ${{ matrix.rails }} × Ruby ${{ matrix.ruby }}'
# Skip running tests for local pull requests (use push event instead), run only for foreign ones
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.owner.login != github.event.pull_request.base.repo.owner.login
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- ruby: "3.1"
rails: "HEAD"
- ruby: "3.0"
rails: "7.0"
- ruby: "2.5"
rails: "6.1"
env:
RAILS_VERSION: ${{ matrix.rails }}
steps:
- uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
- name: Run specs
run: bundle exec rake spec
2 changes: 1 addition & 1 deletion .standard.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# For available configuration options, see:
# https://github.com/testdouble/standard
ruby_version: 2.6
ruby_version: 2.5
14 changes: 14 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ source "https://rubygems.org"

gemspec

# standard: disable Bundler/DuplicatedGem
if (rails_version = ENV["RAILS_VERSION"])
case rails_version
when "HEAD"
git "https://github.com/rails/rails.git" do
gem "rails"
end
else
rails_version = "~> #{rails_version}.0" if rails_version.match?(/^\d+\.\d+$/) # "7.0" => "~> 7.0.0"
gem "rails", rails_version
end
end
# standard: enable Bundler/DuplicatedGem

gem "rake", "~> 13.0"
gem "rspec", "~> 3.0"
gem "rspec-rails", "~> 5.0"
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# IoMonitor

[![Gem Version](https://badge.fury.io/rb/io_monitor.svg)](https://rubygems.org/gems/io_monitor)
[![Tests status](https://github.com/DmitryTsepelev/io_monitor/actions/workflows/test.yml/badge.svg)](https://github.com/DmitryTsepelev/io_monitor/actions/workflows/test.yml)

A gem that helps to detect potential memory bloats.

When your controller loads a lot of data to the memory but returns a small response to the client it might mean that you're using the IO in the non–optimal way. In this case, you'll see the following message in your logs:
Expand All @@ -10,7 +13,10 @@ Completed 200 OK in 349ms (Views: 2.1ms | ActiveRecord: 38.7ms | ActiveRecord Pa

<p align="center">
<a href="https://evilmartians.com/?utm_source=io_monitor">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://evilmartians.com/badges/sponsored-by-evil-martians_v2.0_for-dark-bg@2x.png">
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians_v2.0@2x.png" alt="Sponsored by Evil Martians" width="236" height="54">
</picture>
</a>
</p>

Expand Down
5 changes: 2 additions & 3 deletions io_monitor.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ Gem::Specification.new do |spec|

spec.require_paths = ["lib"]

spec.required_ruby_version = ">= 2.6.0"
spec.required_ruby_version = ">= 2.5.0"

rails_version = ENV["RAILS_VERSION"] || ">= 6.0"
spec.add_dependency "rails", rails_version
spec.add_dependency "rails", ">= 6.1"
spec.add_development_dependency "redis", ">= 4.0"
end
2 changes: 1 addition & 1 deletion lib/io_monitor/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def append_info_to_payload(payload)
data[source] = IoMonitor.aggregator.get(source)
end

data[:response] = payload[:response]&.body&.bytesize || 0
data[:response] = payload[:response].body.bytesize
end
end
end
2 changes: 1 addition & 1 deletion spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Application < Rails::Application
config.root = File.join(__dir__, "..")
config.logger = Logger.new("/dev/null")
config.api_only = true
config.active_record.legacy_connection_handling = false
config.active_record.legacy_connection_handling = false if ActiveRecord::Base.respond_to?(:legacy_connection_handling=)

if Rails::VERSION::MAJOR >= 7
config.active_record.async_query_executor = :global_thread_pool
Expand Down