GithubHelp home page GithubHelp logo

fmcorz / mdk Goto Github PK

View Code? Open in Web Editor NEW
85.0 85.0 47.0 1.33 MB

Moodle Development Kit. A collection of tools meant to make developers' lives easier.

License: GNU General Public License v3.0

PHP 8.19% Python 91.06% Shell 0.76%
moodle python

mdk's People

Contributors

abgreeve avatar adpe avatar andrewnicols avatar christianp avatar crazyserver avatar danpoltawski avatar dcai avatar dmonllao avatar fmcorz avatar gormster avatar huongnv13 avatar jethac avatar junpataleta avatar lucaboesch avatar mdjnelson avatar mickhawkins avatar mudrd8mz avatar philippimhof avatar snake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mdk's Issues

mdk behat depends on the cwd

cd [yourmoodledir]/install
mdk behat -r 

The php webserver will be started in the wrong directory and behat will fail.

Make it possible to prompt/confirm tracker operations

Its pretty easy to accidentally use the wrong bug number (miss a digit, etc) and so it'd be good to play a bit safer with the tracker.

My thought is that before actually updating the tracker it could be a simple confirmation like:

"Are you sure you want to update:
MDL-xxxxx Bug summary from tracker
y/n"

Defaulting to y, so you only need to press y. I don't think it'd be tooo slow, but you could make this a config file option (and i'll laugh and point at people who don't use it and update the wrong bugs).

Can't create and install mysql instance in one command.

mdk create -t -i -r dev -v master -s mysql -e mysql
usage: moodle-create.py [-h] [-t] [-i] [-r [run [run ...]]] [-v version]
[-s suffix] [-e engine]
moodle-create.py: error: argument -e/--engine: invalid choice: 'mysql' (choose from 'mysqli', 'pgsql')

mdk create -t -i -r dev -v master -s mysql -e mysqli
Creating instance im_mysql...
Cloning repository...
Checking out branch...
Creating database...
Installing im_mysql...
Moodle 2.4beta+ (Build: 20121123) command line installation program
Error, incorrect value "mysqli" for "dbtype"
Traceback (most recent call last):
File "/home/damyonw/Documents/Moodle/mdk/moodle-create.py", line 99, in
M.install(**kwargs)
File "/home/damyonw/Documents/Moodle/mdk/lib/moodle.py", line 274, in install
raise Exception('Error while running the install, please manually fix the problem.')
Exception: Error while running the install, please manually fix the problem.

Moodle 2.5?

moodle-create.py: error: argument -v/--version: invalid choice: '25' (choose from '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', 'master')

git stash problem with lower version of git.

You came up with a quick fix for this problem:

index 286f89f..303c331 100755
--- a/moodle-backport.py
+++ b/moodle-backport.py
@@ -99,7 +99,7 @@ for v in versions:
debug("Preparing cherry-pick of %s/%s in %s" % (remote, branch, name))

 # Stash
  • stash = M2.git().stash(untracked=True)
  • stash = M2.git().stash()
    if stash[0] != 0:
    debug('Error while trying to stash your changes. Skipping %s.' % M2.get('identifier'))
    debug(stash[2])

git version 1.7.0.4

create JS commandset

Initially for shifter, jshint, and yuidoc:

mdk js [-s|--shift] [-d|--doc [port]] [-l|--lint]

The default should be context dependent:

  • in root: mdk js -s -d
  • in a module directory: mdk -s

When we get YUITest and yeti off the ground, this should extend to:

  • yeti for real device unit testing
  • grover/istanbul for code coverage (may become part of yeti)

This will need to:

  • add an entry to .git/info/excludes for /node_modules; and then all/some of:
    ** npm install shifter (for shifting)
    ** npm install yuidocjs (for docs)
    ** npm install jshint (for linting)
    ** npm install yeti phantomjs (for device testing)

By calling npm install without the -g (global) option, we install the modules into the node_modules directory in the CWD. By doing it in this way, we keep the versions of each tool matching the branch it's used against.

When generating documentation, we should link documentation against our own apidocs location (see https://tracker.moodle.org/browse/MDLSITE-2498) and use both the version number and git hash in the project-version option passed to it.

mdk rebase --onto MDL-XXXX

It would be cool to have a mdk rebase command which automated fetch'd the branch from another issue.

For example, on working on Petr's branch I have to go to the issue, work out what his branch is named, then I do:

git fetch git://github.com/skodak/moodle/ w30_MDL-39846_m26_event2
git rebase b504e1231b9e4f4a6475f0cb09409d2c79861df5 --onto FETCH_HEAD

Error when using MDK at home running openSUSE.

Attempting to run mdk create ... I get the following error -

File "/usr/local/mdk/moodle-create.py", line 35, in
Wp = workplace.Workplace()
File "/usr/local/mdk/lib/workplace.py", line 50, in init
self.cache = os.path.abspath(os.path.realpath(os.path.expanduser(C.get('dirs.mdk'))))
File "/usr/lib64/python2.7/posixpath.py", line 252, in expanduser
if not path.startswith('~'):
AttributeError: 'NoneType' object has no attribute 'startswith'

mdk create reporting success when an error occurs

The 'Process complete!' seems like the wrong result of this operation:

mdk create -i -r dev.php
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Creating instance pm...
Fetching cached repository moodle.git...
/usr/bin/git fetch
Cloning repository...
/usr/bin/git clone /Users/danp/.moodle-sdk/moodle.git /Users/danp/moodles/pm/moodle
Checking out branch...
Error creating pm:
  This is not a Git repository
Traceback (most recent call last):
  File "/usr/local/Cellar/moodle-sdk/0.4.2/libexec/moodle-sdk/lib/commands/create.py", line 164, in do
    M = self.Wp.create(**kwargs)
  File "/usr/local/Cellar/moodle-sdk/0.4.2/libexec/moodle-sdk/lib/workplace.py", line 123, in create
    repo.setRemote(C.get('myRemote'), C.get('remotes.mine'))
  File "/usr/local/Cellar/moodle-sdk/0.4.2/libexec/moodle-sdk/lib/git.py", line 255, in setRemote
    if not self.getRemote(remote):
  File "/usr/local/Cellar/moodle-sdk/0.4.2/libexec/moodle-sdk/lib/git.py", line 119, in getRemote
    remotes = self.getRemotes()
  File "/usr/local/Cellar/moodle-sdk/0.4.2/libexec/moodle-sdk/lib/git.py", line 125, in getRemotes
    result = self.execute(cmd)
  File "/usr/local/Cellar/moodle-sdk/0.4.2/libexec/moodle-sdk/lib/git.py", line 90, in execute
    raise Exception('This is not a Git repository')
Exception: This is not a Git repository

Process complete!

(I think the error occurred because the cwd was a directory i'd just removed with mdk remove. Probably it should abort at that point).

More suggestions

mdk selfupdate (so it updates mdk automatically - it would be good if mdk can detect an update)
mdk fix -timetracking (keep track of the time I stay on an issue - save it in a text file)
mdk plugin XXXX (XXX being the git repository, recognize the plugin name and automatically install in the correct directory)
mdk praise XXXX "This is top cool" (because blame is not a positive attitude - send an jabber message / tracker issue comment to thanks someone for their work on the issue XXXX)
mdk jemapelle YYYY (send a jabber message to mark)
mdk beer (redirect you to paypal to send $12 to Fred as it's the price of a beer in Perth)
mdk nothing (because you love to type mdk)

mdk pull, weird results with no patch for master

MDL-38173 has not branch for master and some weird behaviour happened:

$ mdk pull MDL-38173
Retrieving information about MDL-38173 from Moodle Tracker
Not enough information to pull the branch
Stashed your local changes
Pulling branch None from git://github.com/damyon/moodle.git into MDL-38173-master
Popped the stash
Done.

mdk phpunit -u [path] should have more bash autocompletion magic

I only recently discovered the other arguments to mdk phpunit, but having just tried it, I can't use it because it doesn't bash complete the path ๐Ÿ‘ฏ (just discovered that emoticon accidentally ๐ŸŽฑ

e.g., I type:

 phpunit coh <TAB> te <TAB> co <TAB> 

And get

phpunit cohort/tests/cohortlib_test.php

And i'd like to do that with mdk phpunit -u

mdk backport - problem with git cherry-pick

Git cherry-pick origin/master..github/[branch to cherrypick]

Doesn't seem to work on my particular system set up.

adrian@adrian-desktop:~/moodles/stable_master_postgres/moodle$ mdk backport -v 23 -d
Preparing cherry-pick of github/wip-MDL-31776-master in stable_23
Fetching remote origin...
Fetching remote github...
Creating branch wip-MDL-31776-23
Cherry-picking origin/master..github/wip-MDL-31776-master
Error while cherry-picking github/wip-MDL-31776-master in stable_23.
fatal: Cannot find 'origin/master..github/wip-MDL-31776-master'

Done.

git version 1.7.0.4

Rename 'stable' to 'production'

git://git.moodle.org/moodle.git should be named production, as the branch master IS NOT stable, only the stable branches are. The use of the word stable is very confusing.

I challenge you to work out which are talking about remotes and which are branches:
wording.prefixStable: stable_
wording.prefixMaster: master
wording.integration: Integration
wording.master: Master
wording.stable: Stable

Grammar feels incorrect when running mdk create

I don't think the grammar here is quite correct:

mdk create
Creating instance stable_master...
Cloning stable repository into cache...
That's going to take a while...

I think it would be better to say 'This is going to take a while...', 'that' sounds incorrect to me, since its part of the same process.

If I was more intelligent I would be able to back this up with proper grammar rules, but i'm not - it just sounds incorrect.

mdk pull should purge caches

There's rarely a time when you don't want to purge caches after pulling a fix in. I'd argue that we should purge caches as we pull in a patch, but provide a --no-purge | -P option for those times when you don't want to.

$CFG->debug should be set in config.php

The problem is that this developer in particular is forgetful (and I know i'm not the only one) and might forget to run the dev script. Then I submit something for integration with warnings in it and integrators think i'm a time wasting looser.

There also can be problems early in the moodle init process which might prevent the setting from the DB being applied earlier enough for some development tasks.

could not create branch

  1. moodle create
    => permission denied

It's because /var/www is not writable for the current user. So I did a chmod 777 /var/www but it's not super great if you deploy your dev environment in the cloud.

  1. moodle create --version 22
    ...
    Checking out branch...
    Could not create branch MOODLE_22_STABLE tracking upstream/MOODLE_22_STABLE
    Process complete

I confim the stable22 is still in alpha (HEAD). I'm not sure why it fails.

Otherwise it works well so far :)

Equivalent to mdk pull without pulling

If someone has a patch which doesn't merge cleanly it'd still like to review it, so it would be nice if there was a way to checkout their branch without merging.

i.e. checking out the remote branch

First install problems

  • "sudo mdk init" and it resulted with many errors because the folder ~/moodles did not exist (I use folder ~/repositories)
  • "sudo mdk init --help" started initialisation instead of showing the help
  • mdk init did not allow me to leave empty password for mysql and postgres users

Bug: when installing on pgsql

sudo mdk install --engine pgsql
Creating database...
Installing integration_master...
OSError: [Errno 2] No such file or directory

Note:

  • "mdk create" properly worked.
  • before running it I didn't have any database, however after running it the integrationmaster database has been created and it's own by the proper postgres user.

I wonder if this error could be due to the config.php that can not be written. I remember you told me about a debug/verbose mode to see exactly when mdk crashed and what it was doing, how do I enable it?

Prevent backport to update tracker without -p

Which means it updates the tracker with no code in place

mdk backport -v master -t
/usr/bin/git remote -v
/usr/bin/git config --get remote.origin.url
/usr/bin/git symbolic-ref -q HEAD
/usr/bin/git remote -v
/usr/bin/git config --get remote.origin.url
/usr/bin/git remote -v
/usr/bin/git config --get remote.origin.url
Preparing cherry-pick of p25/MDL-39936-25 in pm
/usr/bin/git log -n 30 --format=%H origin/MOODLE_25_STABLE..MDL-39936-25
/usr/bin/git stash save
Fetching remote /Users/danp/moodles/p25/moodle...
/usr/bin/git fetch /Users/danp/moodles/p25/moodle MDL-39936-25
/usr/bin/git show-ref --verify --quiet refs/heads/MDL-39936-master
Creating branch MDL-39936-master
/usr/bin/git branch --track MDL-39936-master origin/master
/usr/bin/git checkout MDL-39936-master
Cherry-picking origin/MOODLE_25_STABLE..MDL-39936-25
/usr/bin/git cherry-pick 2e804059400a3f9c3d967305257eacac727643f6
/usr/bin/git log -n 1 --format=%H origin/master
Setting tracker fields:
    Pull  from Repository: git://github.com/danpoltawski/moodle.git
    Pull Master Branch: MDL-39936-master
    Pull Master Diff URL: https://github.com/danpoltawski/moodle/compare/b6f8a936425f93efc692e9b3afab32ed3228aefd...MDL-39936-master
Instance pm successfully patched!

Branch not properly guessed when updating master

Say your current stable_master is on 2.5, but we just released a new version and so masterBranch is set to 26. Then running mdk update on stable_master will not reset to the master branch but to origin/MOODLE_25_STABLE.

This is seen as a bug from the user, but that is caused by the version.php file still displaying branch = 25. A manual git reset on the master branch will fix the issue.

Not sure how to fix this, or how to prompt the user for the right action.

Cached remote should be a mirror repo

The cached remote should be a mirror repository.
The option of using cache as remote should be removed in favor of this, and the update of the mirror should be done in the background.

The update of the mirrored repo should happen either (pick one):

  • All the time
  • Every x minutes/hours (based on config setting)
  • Only when requested (not fan of this)

make branch options more intelligient

typing the full name for branches can be a bit longwinded.
Given that by default, all integration branches start integration and all stable branches stable, it should be possible to make many commands take both -i or -s and the name. For example:

mdk update -i master
instead of:
mdk update integration_master

Make use of git clone --reference for shared object repository

It's possible that you could speed up remote clones by making use of 'alternate object repository'. This puts the git object repository into a shared directory. It needs more research, but the basics are:

--reference <repository>
           If the reference repository is on the local machine, automatically setup .git/objects/info/alternates to obtain objects from the reference repository. Using an
       already existing repository as an alternate will require fewer objects to be copied from the repository being cloned, reducing network and local storage costs.

           NOTE: see the NOTE for the --shared option.

One thing from using it in the past, is that I don't think that when you pull the new objects necessarily go into the shared repo.

Feature suggestion: automatically install github SSK key

If you run the following code, it will allow you to access your fork of moodle/moodle without prompting you with password or error when you try mdk push.

Get github username

clear
echo "This script adds a new SSH key to you github account so you can push directly from this machine without entering your password once the script has ran. Your login/password will only be used to do SSL curl call - even thought the script is carefully tested to not have any bug, the script contributors or distributors CANNOT be hold reponsible for the script updating/deleting your Github rep and Github account."
read -p "Github username:" githubuser

Do not display the password

stty -echo
read -p "Github password:" githubpassword; echo
stty echo

Retrieve user email address (in order to create SSH key)

GETEMAIL=curl -u "$githubuser:$githubpassword" -i https://api.github.com/user/emails | grep -Po '\[*"([^""]*)"' | tail -1
EMAIL=${GETEMAIL//"/}

Request the user github passphrase

read -p "Enter your Github SSH passphrase - you will be prompt to enter it a second time very soon" githubpassphrase

Create SSH key (by default there is none in Ubuntu)

ssh-keygen -f ~/.ssh/id_rsa -N "$githubpassphrase" -t rsa -C "$EMAIL"

Send SSH key to github

sshkey=cat ~/.ssh/id_rsa.pub
jsonparams="{"title":"mdk ssh key", "key":"$sshkey"}"
curl -X POST -u "$githubuser:$githubpassword" -d "$jsonparams" -i https://api.github.com/user/keys

TODO detect multiple mdk keys and offer to delete previous ones

Don't ask for SSH confirm when adding an host

echo 'StrictHostKeyChecking no' > ~/.ssh/config

SSH attempt to trigger the passphrase request

ssh -T [email protected]

Add debian/ubuntu packaging

For easy install.

I have done a quick first stab at it here:
https://github.com/danpoltawski/mdk/compare/debian-packaging

To test it out:

apt-get install build-essential devscripts debhelper
cd mdk
debuild -us -uc
cd ../
dpkg -i moodle-mdk[blahblah].deb

Some things to make it proper would be:

  • Using the debian libaries for database (I assume that is fine)
  • Sort out config system
  • Could automatically setup the default directories, create /var/www/moodles, etc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.