All Projects → PigCI → Pig Ci Rails

PigCI / Pig Ci Rails

Licence: mit
Monitor your Ruby Applications metrics (Memory, SQL Requests & Request Time) as part of your test suite.

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Pig Ci Rails

rspec-json matchers
A collection of RSpec matchers for testing JSON data.
Stars: ✭ 23 (-56.6%)
Mutual labels:  gem, rspec
graphql-rails logger
Display GraphQL queries in a more readable format
Stars: ✭ 102 (+92.45%)
Mutual labels:  gem, ruby-on-rails
souls
SOULs 🔥 Build Serverless Apps faster like Rails. Powered by Ruby GraphQL, RBS/Steep, Active Record, RSpec, RuboCop, and Google Cloud.
Stars: ✭ 327 (+516.98%)
Mutual labels:  rspec, ruby-on-rails
active record-updated at
Touch `updated_at` by default with calls to `update_all` and `update_column(s)`
Stars: ✭ 27 (-49.06%)
Mutual labels:  gem, ruby-on-rails
yo-ruby
🌈 ✨ A super awesome Ruby wrapper of the Yo API.
Stars: ✭ 15 (-71.7%)
Mutual labels:  gem, rspec
exception hunter
Crash reporting engine to hunt down bugs 🐞
Stars: ✭ 78 (+47.17%)
Mutual labels:  gem, ruby-on-rails
rails cursor pagination
Add cursor pagination to your ActiveRecord backed application
Stars: ✭ 21 (-60.38%)
Mutual labels:  gem, ruby-on-rails
Rails new
A thoughtfully designed template for building modern Rails apps. Get started in minutes instead of hours 🔥🚀
Stars: ✭ 151 (+184.91%)
Mutual labels:  ruby-on-rails, rspec
LocalSupport
A directory of local support services and volunteer opportunities
Stars: ✭ 60 (+13.21%)
Mutual labels:  rspec, ruby-on-rails
rspec n
A ruby gem that runs RSpec N times.
Stars: ✭ 37 (-30.19%)
Mutual labels:  gem, rspec
lockup
Lockup Gem
Stars: ✭ 111 (+109.43%)
Mutual labels:  gem, ruby-on-rails
Devise masquerade
Extension for devise, enable login as functionality. Add link to the masquerade_path(resource) and use it.
Stars: ✭ 380 (+616.98%)
Mutual labels:  ruby-on-rails, gem
full-stack-web-developer
🔥 Roadmap to become a Full Stack Web Developer. What? Why? How?
Stars: ✭ 76 (+43.4%)
Mutual labels:  rspec, ruby-on-rails
i18n lazy scope
Use lazy lookup with custom i18n scopes.
Stars: ✭ 11 (-79.25%)
Mutual labels:  gem, ruby-on-rails
Still life
Rails upgrade's best friend
Stars: ✭ 213 (+301.89%)
Mutual labels:  ruby-on-rails, rspec
modular routes
Dedicated controllers for each of your Rails route actions.
Stars: ✭ 45 (-15.09%)
Mutual labels:  gem, ruby-on-rails
Rails Testing Toolbox
🔧 Tools to help Rails developers test
Stars: ✭ 110 (+107.55%)
Mutual labels:  ruby-on-rails, rspec
Websiteone
A website for Agile Ventures
Stars: ✭ 132 (+149.06%)
Mutual labels:  ruby-on-rails, rspec
filtered
Filters ActiveRecord queries in a nice way
Stars: ✭ 28 (-47.17%)
Mutual labels:  gem, ruby-on-rails
Everydayrails Rspec 2017
Sample source for the 2017 edition of Everyday Rails Testing with RSpec.
Stars: ✭ 280 (+428.3%)
Mutual labels:  ruby-on-rails, rspec

Gem Version RSpec Linters Codacy Badge Maintainability Test Coverage Dependabot Status

PigCI

Sample Output of PigCI in TravisCI

Monitor your Ruby Applications metrics (Memory, SQL Requests & Request Time) as part of your test suite. If your app exceeds an acceptable threshold it'll fail the test suite.

Installation

Add this line to your application's Gemfile:

group :test do
  gem 'pig-ci-rails'
end

And then execute:

bundle

Or install it yourself as:

gem install pig-ci-rails

Usage

On it's own

# In spec/rails_helper.rb
require 'pig_ci'
PigCI.start

Configuring thresholds

Configuring the thresholds will allow your test suite to fail in CI. You will need to configure the thresholds depending on your application.

# In spec/rails_helper.rb
require 'pig_ci'
PigCI.start do |config|
  # Maximum memory in megabytes
  config.thresholds.memory = 350

  # Maximum time per a HTTP request
  config.thresholds.request_time = 250

  # Maximum database calls per a request
  config.thresholds.database_request = 35
end if RSpec.configuration.files_to_run.count > 1

Configuring other options

This gems was setup to be configured by passing a block to the PigCI.start method, e.g:

# In spec/rails_helper.rb
require 'pig_ci'
PigCI.start do |config|
  config.option = 'new_value'

  # E.g. disable terminal summary output
  config.generate_terminal_summary = false

  # Rails caches repeated SQL queries, you might want to omit these from your report.
  config.ignore_cached_queries = true
end # if RSpec.configuration.files_to_run.count > 1

You can see the full configuration options lib/pig_ci.rb.

Skipping individual tests

If you have a scenario where you'd like PigCI to not log a specific test, you can add the RSpec metadata pig_ci: true. For example:

RSpec.describe "Comments", type: :request do
  # This test block will be not be tracked.
  describe "GET #index", pig_ci: false do
    it do
      get comments_path
      expect(response).to be_successful
    end
  end
end

Framework support

Currently this gem only supports Ruby on Rails tested via RSpec.

Metric notes

Minor fluctuations in memory usage and request time are to be expected and are nothing to worry about. Though any large spike is a signal of something worth investigating.

Memory

By default, this gem will tell Rails to eager load your application on startup. This aims to help identify leaks, over just pure bulk.

You can disable this functionality by setting your configuration to be:

require 'pig_ci'
PigCI.start do |config|
  config.during_setup_eager_load_application = false
end

Request Time

Often the first request test will be slow, as rails is loading a full environment & rendering assets. To mitigate this issue, this gem will make a blank request to your application before your test suite starts & compiling assets.

You can disable this functionality by setting your configuration to be:

require 'pig_ci'
PigCI.start do |config|
  config.during_setup_make_blank_application_request = false
  config.during_setup_precompile_assets = false
end

Authors

  • This gem was made by @MikeRogers0.
  • It was originally inspired by oink, after it was used to monitor acceptance tests and it spotted a memory leak. It seemed like something that would be useful to have as part of CI.
  • The HTML output was inspired by simplecov.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

TODO

Features I'd like to add at some point:

  • Add a conditional to only save metrics when all tests pass. So if a test suite is failing, it won't affect future stats.
  • HTML output to include branch - Right now they're just timestamps which makes filtering hard.
  • https://rubydoc.info/gems/yard/file/docs/GettingStarted.md - Document the gem so it's easier for people to jump on.
  • Support ActionCable (when requests have no key).

Contributing

Bug reports and pull requests are welcome on GitHub at PigCI/pig-ci-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Code of Conduct

Everyone interacting in the PigCI project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].