tapioca icon indicating copy to clipboard operation
tapioca copied to clipboard

`tapioca dsl --verify` succeeds when it should fail

Open bdewater-thatch opened this issue 1 year ago • 4 comments

We run Tapioca verify commands in CI, but with some regularity notice that RBI changes are missed for DSLs when we run the dsl generation locally. Our ci.yml step on GitHub actions (Linux):

- name: Ensure RBI files are up-to-date
  run: |
    bin/tapioca gems --verify
    bin/tapioca dsl --verify

output:

Run bin/tapioca gems --verify
  bin/tapioca gems --verify
  bin/tapioca dsl --verify
  shell: /usr/bin/bash -e {0}
  env:
    ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: ***
    ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: ***
    ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: ***
    DISABLE_AWS_SECRETS: true
    CACHE_KEY: ***
Checking for out-of-date RBIs...

Nothing to do, all RBIs are up-to-date.
Loading DSL extension classes... Done
Loading Rails application... Done
Loading DSL compiler classes... Done
Checking for out-of-date RBIs...

Nothing to do, all RBIs are up-to-date.

Locally running bin/tapioca dsl --verify on a macOS machine does show me the error I was expecting to see:

bdewater@thatch-bart thatch % bin/tapioca dsl --verify
Loading DSL extension classes... Done
Loading Rails application... Done
Loading DSL compiler classes... Done
Checking for out-of-date RBIs...


RBI files are out-of-date. In your development environment, please run:
  `bin/tapioca dsl`
Once it is complete, be sure to commit and push any changes
If you don't observe any changes after running the command locally, ensure your database is in a good
state e.g. run `bin/rails db:reset`

Reason:
  File(s) added:
  - sorbet/rbi/dsl/anonymized_view_component.rbi
  File(s) changed:
  - sorbet/rbi/dsl/employee_mailer.rbi
  - sorbet/rbi/dsl/member_mailer.rbi

The diff of anonymized_view_component.rbi:

diff --git sorbet/rbi/dsl/anonymized_view_component.rbi sorbet/rbi/dsl/anonymized_view_component.rbi
new file mode 100644
index 00000000..83d94d59
--- /dev/null
+++ sorbet/rbi/dsl/anonymized_view_component.rbi
@@ -0,0 +1,10 @@
+# typed: true
+
+# DO NOT EDIT MANUALLY
+# This is an autogenerated file for dynamic methods in `AnonymizedViewComponent`.
+# Please instead update this file by running `bin/tapioca dsl AnonymizedViewComponent`.
+
+class AnonymizedViewComponent
+  include GeneratedUrlHelpersModule
+  include GeneratedPathHelpersModule
+end

The diff of the mailers show a method being moved:

diff --git sorbet/rbi/dsl/employee_mailer.rbi sorbet/rbi/dsl/employee_mailer.rbi
index 6d4b96a3..a7afa834 100644
--- sorbet/rbi/dsl/employee_mailer.rbi
+++ sorbet/rbi/dsl/employee_mailer.rbi
@@ -47,8 +47,5 @@ class EmployeeMailer
 
     sig { params(opt_in_required: T::Boolean).returns(::ActionMailer::MessageDelivery) }
     def qme_email(opt_in_required: T.unsafe(nil)); end
-
-    sig { returns(::ActionMailer::MessageDelivery) }
-    def tax_forms_available; end
   end
 end
diff --git sorbet/rbi/dsl/member_mailer.rbi sorbet/rbi/dsl/member_mailer.rbi
index d3e03791..f0e6dc4d 100644
--- sorbet/rbi/dsl/member_mailer.rbi
+++ sorbet/rbi/dsl/member_mailer.rbi
@@ -14,5 +14,8 @@ class MemberMailer
 
     sig { returns(::ActionMailer::MessageDelivery) }
     def plan_selection_confirmation_email; end
+
+    sig { returns(::ActionMailer::MessageDelivery) }
+    def tax_forms_available; end
   end
 end

As a workaround I can change our CI step to the following:

- name: Ensure RBI files are up-to-date
  run: |
    bin/tapioca gems
    bin/tapioca dsl
    git add -N .
    git diff --exit-code

git add -N . is to make sure new ViewComponent RBI is picked up by git diff as well, otherwise only the mailer change would show up.

... but I'd love to understand how to further debug this case and get this bug fixed.

bdewater-thatch avatar Feb 01 '24 17:02 bdewater-thatch