greenriver / hmis-warehouse

The Open Path HMIS Warehouse (Warehouse) project was initiated by the City of Boston's Department of Neighborhood Development office to coordinate data across various HMIS installations and supply de-duplicated client information to the Boston CAS (https://github.com/greenriver/boston-cas).
http://openpath.host
GNU General Public License v3.0
30 stars 14 forks source link

individual rspec test performance improvement #4769

Closed ttoomey closed 3 days ago

ttoomey commented 4 days ago

Please squash merge this PR

Description

The goal is to reduce the time required to run an individual test. On my local env, this was around 25 seconds. With these changes, the time goes to around 3 seconds.

changes:

example:

#untracked/simple_spec_2.rb 
require 'rails_helper'

RSpec.describe 'hello world test', type: :model do
  it "is okay" do
    puts 'testing here'
    expect(1).to eq(1)
  end
end
/app $ time rspec untracked/simple_spec_2.rb 
Running via Spring preloader in process 30502
testing here
.

Finished in 1.82 seconds (files took 0.45802 seconds to load)
1 example, 0 failures

real    0m 2.75s
user    0m 0.22s
sys     0m 0.03s

Type of change

Checklist before requesting review

ttoomey commented 3 days ago

Do you have a sense of how much time overall this shaves off? It looks like this is most useful when running a handful of tests locally, which is also a big win.

It shouldn't impact overall CI run time. It's really just to allow rapid iteration on a single test. Once spring is started, the time to run one test is about 3 seconds (in my env).

martha commented 1 day ago

I rely pretty heavily on the Rubymine graphical debugger for running rspec tests, and this has broken something for me, but after spending about 1.5hr trying to debug it, I think I'm in over my head. I'll leave it for now and try to come back to it later. :(

ttoomey commented 1 day ago

I rely pretty heavily on the Rubymine graphical debugger for running rspec tests, and this has broken something for me, but after spending about 1.5hr trying to debug it, I think I'm in over my head. I'll leave it for now and try to come back to it later. :(

Sorry @martha! Happy to pair on this if it would be helpful