User:Frédéric Massart
Moodle Development Kit
Every developer creates simple tools to avoid repeating cumbersome and/or boring tasks, and that is precisely why MDK has been created: to pack all those useful tools in a portable way accross systems. Initially developed in Bash, the project moved to Python to avoid dealing with inconsistencies between Unix platforms, and eventually to support Windows.
Key aspect
The most important aspect of MDK is that it works with Moodle instances. An instance of Moodle is a directory in which you have checked out a particular version and are using a specific database engine. This means that if you want to be working on Moodle 2.3 and 2.4 using both MySQL and PostgreSQL, you will have 4 directories. This choice was made because it is the safest, the clearest, and the most straightforward!
Typical workflows using MDK
To realise what MDK does for you, here are a few common tasks. Let us assume you are are working on the bug MDL-12345 for Moodle 2.4, using PostgreSQL.
Installing a new instance
mdk create -i -v 24 -e pgsql
This is equivalent to doing:
mkdir /dir/to/stable_24/moodle mkdir /dir/to/stable_24/moodledata ln -s /dir/to/stable_24/moodle /var/www/stable_24 git clone git://git.moodle.org/moodle.git /dir/to/moodle cd /dir/to/moodle php admin/cli/install.php --wwwroot="http://localhost/stable_24" --dataroot=/dir/to/stable_24/moodledata --dbtype=pgsql --dbname=stable24 --dbuser=root --dbpass=root --dbhost=localhost --fullname="Stable 24 PostgreSQL" --shortname=stable_24 --adminuser=admin --adminpass=test --allow-unstable --agree-license --non-interactive vim config.php # To add $CFG->sessioncookiepath = '/stable_24/';
Fixing an issue
mdk fix 12345 # Commiting your patch mdk push -t
This is equivalent to doing:
git branch --track MDL-12345-24 origin/MOODLE_24_STABLE git checkout MDL-12345-24 # Commiting your patch git push github MDL-12345-24 # Editing the tracker issue to add # - Git repository URL # - Git branch for 2.4 # - Git compare URL for 2.4
Peer reviewing a patch
Here you want to pull a patch from the tracker issue into a new testing branch, and then run the PHPUnit tests.
mdk pull 12345 -t mdk phpunit -r
This is equivalent to doing:
cd /dir/to/stable_24/moodle git branch --tracker MDL-12345-24-test MOODLE_24_STABLE git checkout MDL-12345-24-test git pull git://github.org/Someone/moodle.git MDL-12345-24 # And now the PHPUnit part mkdir /dir/to/stable_24/moodledata_phpu vim config.php # To add # - $CFG->phpunit_dataroot = '/dir/to/stable_24/moodledata_phpu'; # - $CFG->phpunit_prefix = 'phpu_'; php admin/tool/phpunit/cli/init.php phpunit
Upgrading the instances
mdk upgrade -u --all
This is equivalent to doing:
# For each instance of Moodle... cd /dir/to/stable_24/moodle git checkout MOODLE_24_STABLE git fetch origin git reset --hard origin/MOODLE_24_STABLE php admin/cli/upgrade.php --non-interactive --allow-unstable
Features
For a complete list of the commands MDK has to offer, read through the README file. For more details about each possible command, simply run them with the flag '--help'.
Installation
Debian/Ubuntu
sudo apt-add-repository ppa:2x1cq-fred-7nqa6/ppa sudo apt-get update sudo apt-get install moodle-sdk sudo mdk init # The next line prevents your from logging out and in again. sudo su `whoami`
Mac OS
brew tap danpoltawski/homebrew-mdk brew install moodle-sdk sudo mdk init
Installing MDK on Mac requires Homebrew, to install it use the following command.
ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
Windows
MDK has not been tested on Windows yet, but it should work, possibly after a few minor bug fixes.
Manual
Please follow the instructions from the README file.