Moodle Peer Review tool for MDK

While working at Moodle HQ, I look for ways to get work done in a more efficient way. One of the things we do regularly at moodle is review code, be it externally contributed code, or code written by developers here at HQ. So, I devised a tool to help reviews happen faster.

I created a command for Frédéric Massart's MDK suite of tools called "review".

Over time I hope to add more features to make it more useful. It obviously can't understand your code. But it can check it against our coding guidelines, and run unit tests for you.

MDK review can run codechecker and moodlecheck, displaying only the code style problems that you actually introduced, ignoring pre-existing errors. It can also find the most relevant unit and behat tests for you so that you can run them more frequently during development, or test out a patch you are reviewing without having to wait for the full suite (taking over 10 hours).

Installation

  1. Install mdk, if you haven't already
  2. Go to the directory in which MDK is installed
  3. git remote add xow git@github.com:xow/mdk.git
  4. git fetch xow
  5. git checkout -b feature-review xow/feature-review
  6. Go to your moodle instance. Code away

How to use

To run all the tests that are most relevant to your patch, type:

mdk review -t -r

To just run unit tests or behat acceptance tests, type:

mdk review --behat -r
mdk review --unit -r

If you want to list the relevant tests instead of running them, use a -l flag instead of -r.

To automatically check coding style and documentation, use:

mdk review -s

It will only review lines you wrote.

MDK Review by default determines "your changes" as the difference between your current branch and master. To compare with another branch (such as MOODLE_28_STABLE), use -b or --branch. This is compatible with both the syntax checker and the unit tests.

mdk review -b MOODLE_28_STABLE -r -t

What next for mdk review

I hope to add more features, such as jira integration (so it can see if testing instructions were added and branches were correctly added).

Eventually I hope to get the command into core MDK. MDK already has a mdk precheck command, so I'll need to make sure it's sufficiently different to that. MDK precheck uses a remote server to run codecheckers. So mdk review has the advantage of being run locally (meaning it could be faster) and having testing support.

MDK review's code is quite rough at the moment. I aimed to get something useable as soon as possible, then iterate on that. So there's a bit of work before I (and/or Fred) would be happy putting it out there.

Subscribe

Join my mailing list