Skip to content

Parallel rspec#27

Open
apiology wants to merge 193 commits into2026-01-31from
parallel_rspec
Open

Parallel rspec#27
apiology wants to merge 193 commits into2026-01-31from
parallel_rspec

Conversation

@apiology
Copy link
Owner

No description provided.

On my machine, I got a 33% speed-up with these tweaks:

before: Finished in 1 minute 15.88 seconds
after: Finished in 49 seconds
* Fix merge

* Adjust annotations

* Fix typecheck errors

* Fix merge

* Fix merge

* Fix some @sg-ignores

* Fix merge

* Merge branch 'intersection_types' into flow_sensitive_typing_2_0

* Fix RuboCop issue

* Fix type issues

* Fix type issues

* Fix rspec.yml

* Fix rspec.yml

* Add @sg-ignores

* Remove @sg-ignores

* Merge branch 'or_support_in_flow_sensitive_typing' into union_type_enforcement

* Fix spec

* Fix annotations

* Fix RuboCop issues

* Bump RBS versions in rspec test

* Fix version

* Fix version matrix

* Fix version matrix

* Fix version matrix

* Fix version matrix

* Fix version matrix

* Exclude another

* Exclude another

* Add version, fix doc

* init -> config

* Fix rbs-version for Ruby 4.0 in CI workflow

* Clean up ruby-version entries in rspec.yml

Removed deprecated ruby-version entries for RBS.

* Fix RBS version for Ruby 4.0 in workflow

* Fix merge

* Improve signature combination

Use our generated RBS signature from parameters as a key to combine
method signatures from RBS/YARD pins.

This is closer to what RBS does than the current technique of using
the arity alone, and fixes a key degenerate case in Integer#+ revealed
by updated definitions used by recently released RBS gems

* Update annotations

* Drop annotation

* Fix RuboCop issue

* Fix merge

* Don't use solargraph-rspec branch

* Fix merge

* Debug

* Add another use of stdlib dependencies in RBS

* Mock additional call

* Fix annotations

* Update types in rspec undercover

* Debug

* Debug

* Drop incorrect rbs collection use in spec

* Update rubocop todo

* Revert change

* Fix RuboCop issue

* Fix annotations

* Fix annotations

* RuboCop fix

* Use "type arity" to guide signature combination

* Update rubocop todo

* Include return type arity in comparison

* Add dodgy return type

* Fix RuboCop issue

* Add Ruby 4.0 jobs

* Exclude another combo

* Exclude another combo

* Update rules to use report?

* Fix merge

* Fix merge

* Drop dead code

* Bump version to 0.59.0.dev.1

* Rename rule

* Update RuboCop todo file

* Update RuboCop todo file

* Ratchet rubocop TODO file

* Move to skip:

* Mark spec as pending

* Revert spec change

* Drop old workaround

* Fix merge

* Fix typechecking issues

* Revert doc

* Fix spelling

* Fix merge issue

* Exclude the current gemspec from pins brought in from gem

* Check pathname instead

* Add sg-ignore

* Avoid rbs pollution

We were using the sig/shims directory for some internally helpful
shims; unfortunately that exported them during gem installs, causing
castwide#1144

* Test with RBS 4.0.0.dev.5

* Open up in gemspec

* Fix missing spot

* Typecheck using RBS prereleases

* Move point of ignoring cached gems for gem projects

* Fix issues resolving cgi escape functions

* Be more careful marking things as stdlib

* Reclassify rbs gem

* Fix merge

* Add sg-ignore

* Fix merge

* Remove outdated workaround

* Fix @sg-ignore name

* Restore workaround

* Restore workaround

* Merge branch 'flow_sensitive_typing_2_0' into 2025-01-06

* Fix method signature

* Fix annotations

* Add regression test and fix for issue found during future merge

* Add regression test and fix for issue found during future merge

* Fix merge

* Fix merge

* Fix merge

* Fix merge

* Use correct field for self type resolution

Add a regression test and fix for self type resolution issue found on
a future branch

* Fix 'solargraph pin --references ClassName' private method call

* Add error handling

* Fix another location with another test case

* Drop now-unneeded @sg-ignore

* Don't log caching for each dependent library

This causes duplicate logging on standard libraries, many of which are
esoteric (e.g., "cgi-escaping").  The current method as of the
2025-01-06 branch would result in each stdlib library being cached
individually.

* Drop logging entirely

* Fix some types based on future branch feedback

* Provide Gem::Specification to outside interface

* Provide Gem::Specification to outside interface

* Use #to_spec

* Provide Gem::Specification to outside interface

* Fix typechecking error

* Use consistent bundler versions

* Fix type issue

* Fix annotations based on future branch feedback

* Add some @todos

* Fix annotations

* Fix annotations

* Fix annotation

* Add diff::lcs shim

* Improve spec expectations

* Add @sg-ignore

* Fix rspec checks to run on all types of PRs

* Fix merge

* Fix merge

* Fix merge
Fix issue revealed by more aggressive setting of debug logging
This seems to reproduce when not run in order with other specs in file

jobs:
regression:
rails_and_rspec_typechecking:
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm breaking these steps into parallel items for time savings and also clearing up the names a bit

elsif name == GENERIC_TAG_NAME
all_params.first&.name
elsif name == GENERIC_TAG_NAME && !all_params.empty?
all_params.first.name
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a different fix than I merged in after the spec failure, but maintains the type better

# @sg-ignore sensitive typing needs to handle || on nil types
checker = Solargraph::TypeChecker.new(source.filename, api_map: api_map, level: level.to_sym)
checker = Solargraph::TypeChecker.new(source.filename, api_map: api_map, level: level.to_sym,
workspace: workspace)
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid doing more than necessary in specs by allowing a custom small workspace to be used.

"locals=#{locals.map(&:desc)}, " \
"name_pin=#{name_pin}, " \
"name_pin.closure=#{name_pin&.closure.inspect}, " \
"name_pin.binder=#{name_pin&.binder}) => #{out.rooted_tags.inspect}"
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix some issues found with more consistent use of the debug level in specs

''
else
File.absolute_path(directory)
end
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of the directory = '' handling wasn't being done properly, leading to the specs pulling in the solargraph directory's config when it should be the default config

described_class.build_docs(gem_yardoc_path, [], gemspec) # second time
expect(File.exist?(File.join(gem_yardoc_path, 'complete'))).to be true

expect(Open3).to have_received(:capture2e).once
Copy link
Owner Author

@apiology apiology Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speed up this slow spec by mocking expensive things not done by this class itself.

rescue Gem::SystemExitException => e
raise unless e.exit_code == 0
end
end
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move these to the only scope where they are actualy used

end
))
expect(checker.problems.map(&:message)).to eq(['Unresolved call to upcase'])
expect(checker.problems.map(&:message)).to eq(['Unresolved call to upcase on nil'])
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works now!

Solargraph::Shell.new.uncache('yard')
api_map = Solargraph::ApiMap.load_with_cache('.', $stderr)
# if this fails you might not have an rbs collection installed
api_map = Solargraph::ApiMap.load ''
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid caching every gem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant