Shopify/tapioca

GeneratedAttributeMethods is inconsistently included in the RBI files

adamk9k opened this issue · 2 comments

I’m running into a weird issue. We run tapioca dsl --verify on CI and recently it started to detect uncommitted changes and indeed when running tapioca dsl on the CI it does generate differently than it does on local. To give you an example, the model

class MyModel < ApplicationRecord
  self.primary_key = :id

  self.table_name = "my_table"
end

will generate the following rbi file on local (M1 machine)

class MyModel
  extend CommonRelationMethods
  extend GeneratedRelationMethods

and on CI, which runs on x86 linux I get

 class MyModel
+  include GeneratedAttributeMethods
   extend CommonRelationMethods
   extend GeneratedRelationMethods

Happens for multiple models that were not even modified recently. Tested both on tapioca (0.13.3) and the newest tapioca (0.15.1). We don’t have any compiler options.

CI is Github actions with ubuntu-latest is Ubuntu 24.04 TLS x86 architecture and on local I'm running on an M1 Macbook Air.

Besides the architecture, there is no difference between the two setups, environment variables and Tapioca config file is the same. Any ideas would be appreciated. Thanks!

Make sure that locally database is setup properly and my_table exists. We return early in the compiler if we can't get the table:

return unless constant.table_exists?

If the setup is correct I'd also make sure the table_name assignment is running upon application boot before we trigger the DSL compiler. If not the code would be looking at a my_model table instead of my_table.

Thanks, I have the verify step running after

  RAILS_ENV=test bundle exec rails db:drop
  RAILS_ENV=test bundle exec rails db:create
  RAILS_ENV=test bundle exec rails db:schema:load
  RAILS_ENV=test ./bin/tapioca dsl --verify

So the table should definitely be created.