This project is deprecated...
Our friends at Heroku have used Fourchette and used it as an inspiration for their "Review Apps". We have decided to move from Fourchette ourselves to the "official" way and we strongly encourage you to do so.
Fourchette is your new best friend for having isolated testing environments. It will help you test your @GitHub PRs against a fork of one your @Heroku apps. You will have one Heroku app per PR now. Isn't that amazing? It will make testing way easier and you won't have the (maybe) broken code from other PRs on staging but only the code that requires testing.
IMPORTANT: Please note that forking your Heroku app means it will copy the same addon plans and that you will pay for multiple apps and their addons. Watch out!
Table of content
- How does that work exactly?
- Enable your Fourchette instance
- Enable, disable, update or delete the hook
- Before & after steps; aka callbacks
- Rake tasks
- Async processing note
How does that work exactly?
- A PR is created against your GitHub project
- Fourchette then receives an event via GitHub Hooks:
- It forks an environment making it available to you
- Any new commit against that PR will update the code
- Closing the PR will delete the forked app
- Re-opening the PR will re-create a fork
You have two choices here, the easy path, or the manual path.
This will give you more flexibility to create before and after actions, though you could also do it with the easy path and cloning your repo, etc.
gem install fourchette
fourchette new my-app-name. You can replace "my-app-name" by whatever you want it, this is the name of the directory your Fourchette app will be created in.
cd my-app-name(replace app name, again)
git init && git add . && git commit -m "Initial commit :tada:"
- push to Heroku
- configure the right environment variables (see #configuration)
- Enable your Fourchette instance
export FOURCHETTE_GITHUB_PERSONAL_TOKEN='a token here...'# You can create one here: https://github.com/settings/applications
export FOURCHETTE_HEROKU_API_KEY="API key here"
export FOURCHETTE_HEROKU_APP_TO_FORK='the name of the app to fork from'
export FOURCHETTE_HEROKU_APP_PREFIX="fourchette"# This is basically to namespace your forks. In that example, they would be named "fourchette-pr-1234" where "1234" is the PR number. Beware, the name can't be more than 30 characters total! It will be changed to be lowercase only, so you should probably just use lowercase characters anyways.
IMPORTANT: the GitHub user needs to be an admin of the repo to be able to add, enable or disable the web hook used by Fourchette. You could create it by hand if you prefer.
Enable your Fourchette instance
bundle exec rake fourchette:enable
Enable, disable, update or delete the hook
bundle exec rake -T will tell you the rake tasks available. There are tasks to enable, disable or delete the GitHub hook to your Fourchette instance. There is also one to update the hook. That last one is mostly for development, if your local tunnel URL changed and you want to update the hook's URL.
Before & after steps, aka, callbacks
You need to run steps before and/or after the creation of your new Heroku app? Let's say you want to run mirgations after deploying new code. There is a simple (and primitive) way of doing it. It might not be perfect but will work until there is a cleaner and more flexible way of doing so, if required.
Create a file in your project to override the
Fourchette::Callbacks class and include it after Fourchette.
You just want to override the
after methods of
lib/fourchette/callbacks.rb) to suit your needs. In those methods, you have access to GitHub's hook data via the
@param instance variable.
rake fourchette:console # Brings up a REPL with the code loaded rake fourchette:delete # This deletes the Fourchette hook rake fourchette:disable # This disables Fourchette hook rake fourchette:enable # This enables Fourchette hook rake fourchette:update # This updates the Fourchette hook with the current URL of the app
Async processing note
Fourchette uses Sucker Punch, "a single-process Ruby asynchronous processing library". No need for redis or extra processes. It also mean you can run it for free on Heroku, if this is what you want.
- fork & clone
- You now have the app running on port 9292
Bonus: if you need a tunnel to your local dev machine to work with GitHub hooks, you might want to look at https://ngrok.com/.
If you want the maximum output in your GitHub comments, set this environment variable:
- @jpsirois for the logo!