Shopify / shipit-engine

Deployment coordination
https://shopify.engineering/introducing-shipit
MIT License
1.42k stars 144 forks source link

Dummy app seeds are missing some host configuration #1268

Closed benoittgt closed 2 years ago

benoittgt commented 2 years ago

Hello

When trying to run ./bootstrap the command breaks on seed action.

rake aborted!
ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
/Users/benoit/code/shipit-engine/app/serializers/shipit/stack_serializer.rb:21:in `html_url'
/Users/benoit/code/shipit-engine/app/models/shipit/hook.rb:131:in `coerce_payload'
/Users/benoit/code/shipit-engine/app/models/shipit/hook.rb:102:in `emit'
/Users/benoit/code/shipit-engine/app/models/shipit/stack.rb:655:in `emit_added_hooks'
/Users/benoit/code/shipit-engine/test/dummy/db/seeds.rb:33:in `block in <module:Shipit>'
/Users/benoit/code/shipit-engine/test/dummy/db/seeds.rb:32:in `times'
/Users/benoit/code/shipit-engine/test/dummy/db/seeds.rb:32:in `each'
/Users/benoit/code/shipit-engine/test/dummy/db/seeds.rb:32:in `map'
/Users/benoit/code/shipit-engine/test/dummy/db/seeds.rb:32:in `<module:Shipit>'
/Users/benoit/code/shipit-engine/test/dummy/db/seeds.rb:12:in `<top (required)>'
/Users/benoit/.rbenv/versions/3.1.1/bin/bundle:25:in `load'
/Users/benoit/.rbenv/versions/3.1.1/bin/bundle:25:in `<main>'
Tasks: TOP => db:seed => app:db:seed

It seems the https://github.com/Shopify/shipit-engine/blob/a0a826555691f0c83cf74667e6df09911ff339e4/test/dummy/config/initializers/0_load_development_secrets.rb#L5 does not have any effect. It is loaded but Rails.secrets is still with a default content {:secret_key_base=>"s3cr3ts3cr3ts3cr3ts3cr3ts3cr3ts3cr3t"}

Thanks 🏓

casperisfine commented 2 years ago

Hum, so the merge works, the problem is that the engine in the initializer is ran before the dummy app initializer:

initializer 'shipit.config', before: 'active_record_encryption.configuration' do |app|

That's a problem we keep hearing about with Rails 7, that we'll have to fix.

I'll try to figure a quick fix.

casperisfine commented 2 years ago

Ok, that should be good now, please try the latest master.

Thanks for the report.

benoittgt commented 2 years ago

Thanks @casperisfine for the quick answer and interesting fix.