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

Move gem RBI generation to server add-on #2174

Closed
wants to merge 20 commits into from

Conversation

andyw8
Copy link
Contributor

@andyw8 andyw8 commented Jan 29, 2025

As discussed internally, move this behaviour to the server add-on for consistency with the DSL add-on, and so that we can benefit by using fork.

  • verify on CodeDB
code-db andyw8/experiemtn % ls -alT sorbet/rbi/gems/[email protected]
-rw-r--r--@ 1 andyw8  staff  62404 Feb  7 12:07:47 2025 sorbet/rbi/gems/[email protected]
code-db andyw8/experiemtn % ls -alT Gemfile.lock                         
-rw-r--r--@ 1 andyw8  staff  21834 Feb  7 12:07:34 2025 Gemfile.lock

(13 seconds)

  • verify on Core

@andyw8 andyw8 mentioned this pull request Jan 29, 2025
@andyw8 andyw8 added the enhancement New feature or request label Jan 30, 2025
@andyw8 andyw8 force-pushed the andyw8/move-gem-rbi-gen-to-server branch 2 times, most recently from ce44c9a to ea38d97 Compare January 31, 2025 21:23
@andyw8 andyw8 changed the title WIP: Move gem RBI gen to server Move gem RBI generation to server add-on Jan 31, 2025
@andyw8 andyw8 marked this pull request as ready for review February 3, 2025 18:18
@andyw8 andyw8 requested a review from a team as a code owner February 3, 2025 18:18
Copy link
Member

@vinistock vinistock left a comment

Choose a reason for hiding this comment

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

This is missing the plumbing to invoke

@andyw8 andyw8 marked this pull request as draft February 6, 2025 16:32
@andyw8 andyw8 force-pushed the andyw8/move-gem-rbi-gen-to-server branch from a00daf4 to a2538f9 Compare February 6, 2025 18:25
@andyw8 andyw8 force-pushed the andyw8/move-gem-rbi-gen-to-server branch from 95e7e13 to 0773913 Compare February 6, 2025 20:31
check = ::RubyLsp::Tapioca::RunGemRbiCheck.new(@project.absolute_path)
check.run
check.run { |gem| gem_list.concat(gem) }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(This would be easier to verify if we had Mocha)

@andyw8 andyw8 force-pushed the andyw8/move-gem-rbi-gen-to-server branch from 0773913 to c4fdf4f Compare February 6, 2025 20:40
@andyw8 andyw8 marked this pull request as ready for review February 7, 2025 17:41
attr_reader :stdout
attr_reader :stderr
attr_reader :status
attr_reader :log
Copy link
Contributor Author

@andyw8 andyw8 Feb 7, 2025

Choose a reason for hiding this comment

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

(Renamed from stdout)

The only place we read the logs now is the test, so it may be better to remove this.

Copy link
Contributor

Choose a reason for hiding this comment

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

The logs in this file are useful no? Why don't we send them to the editor?

@@ -6,29 +6,28 @@

module RubyLsp
module Tapioca
class RunGemRbiCheck
class GemRbiCheck
Copy link
Contributor Author

@andyw8 andyw8 Feb 7, 2025

Choose a reason for hiding this comment

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

(renamed as per Kaan's suggestion but we're open to other ideas)

@@ -57,10 +57,11 @@ class RunGemRbiCheckSpec < SpecWithProject
@project.require_mock_gem(foo)
@project.bundle_install!

check = ::RubyLsp::Tapioca::RunGemRbiCheck.new(@project.absolute_path)
check.run
gems_for_tapioca_command = []
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we had Mocha we could write this as something like check.expects(:run).yields(["foo"])

attr_reader :stdout
attr_reader :stderr
attr_reader :status
attr_reader :log
Copy link
Contributor

Choose a reason for hiding this comment

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

The logs in this file are useful no? Why don't we send them to the editor?

type: Constant::MessageType::WARNING,
) unless gem_rbi_check.stderr.empty?
gem_rbi_check = GemRbiCheck.new(T.must(@global_state).workspace_path)
gem_rbi_check.run do |gems|
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about this?

Suggested change
gem_rbi_check.run do |gems|
gem_generate.with_modified_gems do |gems|

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about on_gems_modified? I think with is more typically used as a 'wrapper'.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, I think gem_generate better aligns with existing Tapioca commands too, let's make that change as well. Both for local variable and the class.

gem_rbi_check.stderr,
type: Constant::MessageType::WARNING,
) unless gem_rbi_check.stderr.empty?
logger_callback = lambda do |message|
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Named it to avoid confusion with the built-in Logger.

@andyw8
Copy link
Contributor Author

andyw8 commented Feb 10, 2025

Abandoning due to Bundler-related challenges, see https://github.com/Shopify/team-ruby-dx/issues/1372

@andyw8 andyw8 closed this Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants