Closed seanknox closed 9 years ago
Are you sure it is being loaded? Is your Fourchette app code available somewhere or it's closed source?
Also, glad you're excited about it! Who @ CircleCI told you about Fourchette? They're great people and we use & love them too :D
The app was deployed—although I when opened the issue didn't realize that it can take awhile to compile the slug (I'm used to forking as opposed to building).
"Copying database from"
) and didn't see anything. Do callbacks each time run after Heroku completes the build, or only on app creation?re: CircleCI, it was Jonathan Irving!
@seanknox
Yes, it's accurate that we (Rainforest QA) have been running into issues with Heroku's DB transfer API that is used in Fourchette. I didn't have time to fix it properly yet and I don't know when I'll have to.
Callbacks are called before and after any action, you can see it here: https://github.com/rainforestapp/fourchette/blob/78ab379ec20ce226bbedea95d84f633665a1c461/lib/fourchette/pull_request.rb
That said, it might make a lot of sense to have different callbacks for different type of pull request actions.
Hope that helps?
Right, so it looks like callbacks have to be defined in the gem itself? The callbacks defined in the Sinatra app are never triggered.
My fourchette gem callbacks (the default):
class Fourchette::Callbacks
include Fourchette::Logger
def initialize params
@params = params
end
def before_all
logger.info 'Placeholder for before steps...'
end
def after_all
logger.info 'Placeholder for after steps...'
end
end
My callbacks in the Fourchette Sinatra app:
class FourchetteCallbacks
include Fourchette::Logger
def initialize(params)
@params = params
end
def before_all
logger.info 'Placeholder for before steps... (see callbacks.rb to override)'
end
def after_all
logger.info "Copying database from #{source_app_name} to #{new_app_name}..."
pg_backup.copy(source_app_name, new_app_name)
remove_airbrake_api_var
end
private
def heroku
@heroku ||= Fourchette::Heroku.new
end
def remove_airbrake_api_var
# Don't enable Airbrake reporting for QA apps.
heroku.client.remove_config_var(new_app_name, 'AIRBRAKE_API_KEY')
end
def heroku_fork_obj
@heroku_fork ||= Fourchette::Fork.new(@params)
end
def new_app_name
@fork_name ||= heroku_fork.fork_name
end
def source_app_name
ENV.fetch('FOURCHETTE_HEROKU_APP_TO_FORK')
end
def pg_backup
Fourchette::Pgbackups.new
end
end
The Sinatra callbacks are never run—the logs always show 'Placeholder for after steps...'
instead of the output from my custom callbacks.
Are you requiring them? They are not going to be autoloaded. It definitely works with the latest stable Fourchette version as we're using it right now.
Here is how it's setup for us:
Ah, re-reading, you are not overriding the right class. You are creating FourchetteCallbacks
while you should do it on Fourchette::Callbacks
:grinning:
@jipiboily Yep just found that myself! Thanks for the extra eyes.
Glad you've got it sorted out :)
First off: excited to use this in our org—turns out we solved this same problem for our team at almost the same time you did, although yours is better in many ways! :) The @CircleCI folks tipped me off about fourchette.
As alluded to in https://github.com/rainforestapp/fourchette/issues/44, I need to run an after callback to copy the Postgres DB from the source Heroku app to the newly created app. Forking the DB is not an option. Looks like fourchette already does this but it fails (#42)?
In any case, in my app generated with
fourchette my-app-name
, the callbacks don't appear to be running. Here's my callbacks file:I pushed my code to Heroku and opened a PR to cue creation of an app, but the logs show:
Looks like the default after callback in the gem is running. Assuming the callbacks defined in my app should override the gem's, but that doesn't appear to be the case.