There are numerous tasks to execute after checking out a Canvas patchset... compile assets, migrate database changes, update plugins, etc. Forgetting to do any one of these may bork your testing, possibly even produce false positives!
Sometimes all you need is the latest master branch of canvas-lms, but you can't quite recall all the database migration and asset compilation tasks.
prepare
takes care of all that for you.
prepare
will:
- Make sure you're in a canvas root directory
- Pull the code changes (either from master or from the patchset you've specified)
- Update Canvas plugins
- Check if your Canvas gem dependencies need updating
- If they do, it will install them for you
- Migrate any database changes to your development db
- Migrate any database changes to your test db
- Install Canvas javascript dependencies if they aren't already installed
- Compile CSS and Javascript
- Make you happy 😃
It can also nuke your Javascript dependencies, force re-install them, and more. See the full feature list below.
We assume the following:
- you've already installed Postgres (postgresapp.com is an excellent option for Mac users)
- postgres is running
- you've already installed Node.js
- you've already installed Yarn
Add a symlink to prepare
in your /usr/local/bin/ directory, like so:
$ cd canvas-lms/script/prepare/
$ ln -s $(pwd)/prepare /usr/local/bin/prepare
You're all set!
This works just like Portals. To checkout a specific patchset, copy its unique ID from gerrit. Then execute:
$ prepare <commit_id>
For example:
$ prepare 89/12345/67
Or, if you just want to checkout master, do this:
$ git checkout master
$ prepare
You might encounter problems with some Ruby dependencies. The "Dependency Installation" section in the public Canvas LMS Github wiki has some useful tips.
Let's say you've branched off master and committed code changes. Now you want to test your changes against the latest Canvas code base on master before you push your code for review.
You can easily git pull --rebase
(provided you've already done
git branch --set-upstream-to=origin/master
), but what if there have been
database, gem, or css changes since you branched?
You can update all those manually. Or you can let prepare
do it for you.
Simply:
$ prepare
It will git pull --rebase
, then update your database, compile css, etc.
(Again, see the "What does it do exactly?" section above for details.)
NOTE: prepare
won't execute git branch --set-upstream-to=origin/master
for
you. It assumes you've already set your branch's upstream to the desired remote
branch.
Current and planned:
- Keeps a log of processes and any errors
- Updates your Canvas codebase, including plugins, gems, and node packages
- Performs database migrations on both development and test databases
- Compiles assets (css and javascript)
- Starts or restarts
powder
if you have it installed and linked to Canvas - Supports
git checkout
- Supports updating your current branch off master
- Supports nuking your Canvas node_modules, i.e.
rm -rf node_modules && npm install
- Supports a fresh installation of Javascript dependencies (useful for new Canvas setups)
- Supports
git cherry-pick
- Supports a "quick" option, i.e. skipping asset compilation entirely
- Run delayed jobs in the background
Much of this code is borrowed from one of Canvas' update scripts. I simply added a couple features and repurposed it for Canvas QA folks who are likely accustomed to the Portals checkout flow.