Note: You are currently viewing documentation for Moodle 3.7. Up-to-date documentation for the latest stable version of Moodle may be available here: Moodle Production Server with GIT.

Moodle Production Server with GIT: Difference between revisions

From MoodleDocs
m (headline)
(finish chapter Develop and change local code)
Line 102: Line 102:
Now we are ready to bring the code to the productive Server. You can pull the code from the remote ISIS repository, but you will have a lot of overhead this way. So we simply rsync the code to the server.
Now we are ready to bring the code to the productive Server. You can pull the code from the remote ISIS repository, but you will have a lot of overhead this way. So we simply rsync the code to the server.


  wendt@bastet:~/isis$ git checkout <span style="color:#ff0000">isis_productive</span>
  <span style="color:#808080">wendt@integ:~/isis$</span> git checkout <span style="color:#ff0000">isis_productive</span>
  Switched to branch '<span style="color:#ff0000">isis_productive</span>'
  Switched to branch '<span style="color:#ff0000">isis_productive</span>'
  <span style="color:#808080">wendt@integ:~/isis$</span> cd ..
  <span style="color:#808080">wendt@integ:~/isis$</span> cd ..
Line 113: Line 113:
== Merge the weekly moodle release ==
== Merge the weekly moodle release ==


soon
Now, having a working Moodle instance running at the Server, we have to merge the weekly Moodle releases, To be on the save side, you can always fork new test branches and test the merging process there, before you apply these to you productive branches. After practising it for 11 weeks everything still merges smoothly without any conflicts.
 
First we get the recent Moodle release in our tracked Moodle-branch.
 
wendt@bastet:~/isis$ git checkout MOODLE_23_STABLE
Switched to branch 'MOODLE_23_STABLE'
wendt@bastet:~/isis$ git pull
  remote: Counting objects: 4304, done.
  remote: Compressing objects: 100% (776/776), done.
  remote: Total 3014 (delta 2310), reused 2841 (delta 2155)
  Receiving objects: 100% (3014/3014), 733.24 KiB | 276 KiB/s, done.
  Resolving deltas: 100% (2310/2310), completed with 532 local objects.
  From git://git.moodle.org/moodle
    a8d6719..9fa159e  MOODLE_21_STABLE -> moodle/MOODLE_21_STABLE
    a8ce907..10c3c37  MOODLE_22_STABLE -> moodle/MOODLE_22_STABLE
    562dbe4..b1c5155  MOODLE_23_STABLE -> moodle/MOODLE_23_STABLE
    ccd90e7..7e8ae12  master    -> moodle/master
  Updating 562dbe4..b1c5155
  Fast-forward
  admin/cli/install.php                            |  14 +-
  admin/renderer.php                                |    2 +-
  admin/tool/customlang/locallib.php                |    2 +-
  .
  .
  .
  version.php                                      |    4 +-
  webservice/lib.php                                |    2 +-
  104 files changed, 2211 insertions(+), 1248 deletions(-)
  create mode 100644 install/lang/ms/admin.php
  create mode 100644 install/lang/ms/install.php
  create mode 100644 install/lang/ms/moodle.php
  delete mode 100644 mod/lesson/importppt.php
  delete mode 100644 mod/lesson/importpptlib.php
  create mode 100644 pix/f/epub.png
wendt@bastet:~/isis$
 
 


== Develop and change local code ==
== Develop and change local code ==


soon
Our developers clone the ISIS remote repository to their local home directories, prepare and test their changes and push the results back to isis_contrib branch of the ISIS remote server.
 
develop1@mylaptop:~$ git clone <nowiki>git://isis.remote.tu-berlin.de/isis.git</nowiki>
Cloning into isis...
remote: Counting objects: 472320, done.
remote: Compressing objects: 100% (112942/112942), done.
remote: Total 472320 (delta 347910), reused 472320 (delta 347910)
Receiving objects: 100% (472320/472320), 199.03 MiB | 23.88 MiB/s, done.
Resolving deltas: 100% (347910/347910), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.
develop1@mylaptop:~$
 
To be aware of changes we track the remote isis_contrib branch to a local branch.
 
develop1@mylaptop:~$ cd isis/
develop1@mylaptop:~/isis$ git branch -av
  remotes/origin/isis_contrib    562dbe4 weekly release 2.3.2+
  remotes/origin/isis_productive 562dbe4 weekly release 2.3.2+
  remotes/origin/isis_rebase    562dbe4 weekly release 2.3.2+
develop1@mylaptop:~/isis$ git branch --track isis_contrib remotes/origin/isis_contrib
Branch isis_contrib set up to track remote branch isis_contrib from origin.
develop1@mylaptop:~/isis$
 
Lets fork a branch, where we put and test our code changes.
 
develop1@mylaptop:~/isis$ git checkout isis_contrib
Switched to branch 'isis_contrib'
develop1@mylaptop:~/isis$ git checkout -b isis_my_code1
Switched to a new branch 'isis_my_code1'
develop1@mylaptop:~/isis$
 
Make code changes.
 
develop1@mylaptop:~/isis$ emacs theme/base/style/pagelayout.css
develop1@mylaptop:~/isis$
 
After commiting it, we can push it to the ISIS remote server. Of course there 1000 ways of using git to develop and change code and to push it to remote repositories. This is just one and your a free to use, whatever you are used to.
 
develop1@mylaptop:~/isis$ git commit -a -m "base theme updated"
[isis_my_code1 b5ec6cc] base theme updated
  1 files changed, 1 insertions(+), 1 deletions(-)
develop1@mylaptop:~/isis$ git push origin isis_my_code1:isis_contrib
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 511 bytes, done.
Total 6 (delta 5), reused 0 (delta 0)
To <nowiki>git://isis.remote.tu-berlin.de/isis.git</nowiki>
    562dbe4..b5ec6cc  isis_my_code1 -> isis_contrib
develop1@mylaptop:~/isis$
 
 


== Integrate code changes to productive ==
== Integrate code changes to productive ==


soon
coming soon


== Rebase on new Moodle version ==
== Rebase on new Moodle version ==


soon
coming soon


[[Category:Git]]
[[Category:Git]]
[[Category:Developer]]
[[Category:Developer]]

Revision as of 18:05, 18 October 2012

GIT Repository scheme

This is the description of how we maintain our Moodle2 code at TU Berlin. Our Moodle has ca. 30000 active user with average 2000 online user 24/7. We have a lot of code changes and plugins, so it's essential for us to maintain the code as automated as possible.

Our Moodle is called ISIS. So further on everything what is named ISIS belongs to us, everything what is called MOODLE belongs to moodle.org.

We use several GIT-repositories. The scheme with branches looks like this

ISIS GIT schema.png

The main purpose for the ISIS remote repository is for backups. One can imagine a scenario without this remote server only with local repositories involved. If you use gitolite for your remote repository, it's even more comfortable to keep the code clean, because you are able the restrict access to branches for developer and integration manager individually.

The puzzle about the isis_rebase branch will be explained, when we come to a new moodle release.

Install the repositories

We start with the original moodle code. For orientation we suggest to read the very useful description Git_for_Administrators first. Instead of the advise there we won't clone the moodle.org-repository in the first place. We start over with creating an empty repository at the ISIS Integration server.


wendt@integ:~$ mkdir isis
wendt@integ:~$ cd isis/
wendt@integ:~/isis$ git init
Initialized empty Git repository in /home/wendt/isis/.git/
wendt@integ:~/isis$ 


Now we add moodle.org as remote repository.

wendt@integ:~/isis$ git remote add moodle git://git.moodle.org/moodle.git
wendt@integ:~/isis$ git fetch moodle
remote: Counting objects: 597378, done.
remote: Compressing objects: 100% (141938/141938), done.
remote: Total 597378 (delta 442383), reused 597378 (delta 442383)
Receiving objects: 100% (597378/597378), 223.38 MiB | 11.16 MiB/s, done.
Resolving deltas: 100% (442383/442383), done.
From git://git.moodle.org/moodle
 * [new branch]      MOODLE_13_STABLE -> moodle/MOODLE_13_STABLE
 * [new branch]      MOODLE_22_STABLE -> moodle/MOODLE_22_STABLE
.
.
.
 * [new branch]      MOODLE_23_STABLE -> moodle/MOODLE_23_STABLE
 * [new branch]      master     -> moodle/master
 * [new tag]         v1.3.5     -> v1.3.5
.
.
. 
 * [new tag]         v2.3.2     -> v2.3.2
wendt@integ:~/isis$ 


Next we create a local branch of the moodle 2.3 code.

wendt@integ:~/isis$ git branch --track MOODLE_23_STABLE remotes/moodle/MOODLE_23_STABLE
Branch MOODLE_23_STABLE set up to track remote branch MOODLE_23_STABLE from moodle.
wendt@integ:~/isis$ git checkout MOODLE_23_STABLE
Switched to branch 'MOODLE_23_STABLE'
wendt@integ:~/isis$

From this we fork our initial ISIS code.

wendt@integ:~/isis$ git checkout -b isis_contrib
Switched to a new branch 'isis_contrib'
wendt@integ:~/isis$ 


At this point we expect an empty ISIS remote repository, where we can initially push the ISIS code. First we add it as a remote repository to our local git-repository. then we push the isis_contrib branch into the different branches of the remote repository.


wendt@integ:~/isis$ git remote add isis git://isis.remote.tu-berlin.de/isis.git
wendt@integ:~/isis$ git push isis isis_contrib:isis_contrib
Counting objects: 472320, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (117914/117914), done.
Writing objects: 100% (472320/472320), 199.01 MiB | 17.92 MiB/s, done.
Total 472320 (delta 347911), reused 464510 (delta 342938)
To git://isis.remote.tu-berlin.de/isis.git
 * [new branch]      isis_contrib -> isis_contrib
wendt@integ:~/isis$ git push isis isis_contrib:isis_productive
Total 0 (delta 0), reused 0 (delta 0)
To git://isis.remote.tu-berlin.de/isis.git
 * [new branch]      isis_contrib -> isis_productive
wendt@integ:~/isis$ git push isis isis_contrib:isis_rebase
Total 0 (delta 0), reused 0 (delta 0)
To git://isis.remote.tu-berlin.de/isis.git
 * [new branch]      isis_contrib -> isis_rebase
wendt@integ:~/isis$ 

To stay in sync with the remote ISIS repository we track the remote branches to local ones now.

wendt@integ:~/isis$ git branch --track isis_productive remotes/isis/isis_productive
Branch isis_productive set up to track remote branch isis_productive from isis.
wendt@integ:~/isis$ git branch --track isis_rebase  remotes/isis/isis_rebase
Branch isis_rebase set up to track remote branch isis_rebase from isis.
wendt@integ:~/isis$ git checkout isis_contrib
Already on 'isis_contrib'
wendt@integ:~/isis$ git branch --set-upstream remotes/isis/isis_contrib
Branch remotes/isis/isis_contrib set up to track local branch isis_contrib.
wendt@integ:~/isis$ 

Now we are ready to bring the code to the productive Server. You can pull the code from the remote ISIS repository, but you will have a lot of overhead this way. So we simply rsync the code to the server.

wendt@integ:~/isis$ git checkout isis_productive
Switched to branch 'isis_productive'
wendt@integ:~/isis$ cd ..
wendt@integ:~$ rsync -a --delete --exclude=config.php --exclude=.htaccess --exclude=.git/ isis admin@www.isis.tu-berlin.de:/var/www/
admin@www.isis.tu-berlin.de's password: 
wendt@integ:~$ 

This rsync command will reappear later updating the production code as well. At this point you can start using your moodle and follow the install procedure of moodle.

Merge the weekly moodle release

Now, having a working Moodle instance running at the Server, we have to merge the weekly Moodle releases, To be on the save side, you can always fork new test branches and test the merging process there, before you apply these to you productive branches. After practising it for 11 weeks everything still merges smoothly without any conflicts.

First we get the recent Moodle release in our tracked Moodle-branch.

wendt@bastet:~/isis$ git checkout MOODLE_23_STABLE 
Switched to branch 'MOODLE_23_STABLE'
wendt@bastet:~/isis$ git pull 
 remote: Counting objects: 4304, done.
 remote: Compressing objects: 100% (776/776), done.
 remote: Total 3014 (delta 2310), reused 2841 (delta 2155)
 Receiving objects: 100% (3014/3014), 733.24 KiB | 276 KiB/s, done.
 Resolving deltas: 100% (2310/2310), completed with 532 local objects.
 From git://git.moodle.org/moodle
   a8d6719..9fa159e  MOODLE_21_STABLE -> moodle/MOODLE_21_STABLE
   a8ce907..10c3c37  MOODLE_22_STABLE -> moodle/MOODLE_22_STABLE
   562dbe4..b1c5155  MOODLE_23_STABLE -> moodle/MOODLE_23_STABLE
   ccd90e7..7e8ae12  master     -> moodle/master
 Updating 562dbe4..b1c5155
 Fast-forward
  admin/cli/install.php                             |   14 +-
  admin/renderer.php                                |    2 +-
  admin/tool/customlang/locallib.php                |    2 +-
 .
 .
 .
  version.php                                       |    4 +-
  webservice/lib.php                                |    2 +-
 104 files changed, 2211 insertions(+), 1248 deletions(-)
 create mode 100644 install/lang/ms/admin.php
 create mode 100644 install/lang/ms/install.php
 create mode 100644 install/lang/ms/moodle.php
 delete mode 100644 mod/lesson/importppt.php
 delete mode 100644 mod/lesson/importpptlib.php
 create mode 100644 pix/f/epub.png
wendt@bastet:~/isis$ 


Develop and change local code

Our developers clone the ISIS remote repository to their local home directories, prepare and test their changes and push the results back to isis_contrib branch of the ISIS remote server.

develop1@mylaptop:~$ git clone git://isis.remote.tu-berlin.de/isis.git
Cloning into isis...
remote: Counting objects: 472320, done.
remote: Compressing objects: 100% (112942/112942), done.
remote: Total 472320 (delta 347910), reused 472320 (delta 347910)
Receiving objects: 100% (472320/472320), 199.03 MiB | 23.88 MiB/s, done.
Resolving deltas: 100% (347910/347910), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.
develop1@mylaptop:~$ 

To be aware of changes we track the remote isis_contrib branch to a local branch.

develop1@mylaptop:~$ cd isis/
develop1@mylaptop:~/isis$ git branch -av
  remotes/origin/isis_contrib    562dbe4 weekly release 2.3.2+
  remotes/origin/isis_productive 562dbe4 weekly release 2.3.2+
  remotes/origin/isis_rebase     562dbe4 weekly release 2.3.2+
develop1@mylaptop:~/isis$ git branch --track isis_contrib remotes/origin/isis_contrib 
Branch isis_contrib set up to track remote branch isis_contrib from origin.
develop1@mylaptop:~/isis$ 

Lets fork a branch, where we put and test our code changes.

develop1@mylaptop:~/isis$ git checkout isis_contrib 
Switched to branch 'isis_contrib'
develop1@mylaptop:~/isis$ git checkout -b isis_my_code1
Switched to a new branch 'isis_my_code1'
develop1@mylaptop:~/isis$ 

Make code changes.

develop1@mylaptop:~/isis$ emacs theme/base/style/pagelayout.css 
develop1@mylaptop:~/isis$ 

After commiting it, we can push it to the ISIS remote server. Of course there 1000 ways of using git to develop and change code and to push it to remote repositories. This is just one and your a free to use, whatever you are used to.

develop1@mylaptop:~/isis$ git commit -a -m "base theme updated"
[isis_my_code1 b5ec6cc] base theme updated
 1 files changed, 1 insertions(+), 1 deletions(-)
develop1@mylaptop:~/isis$ git push origin isis_my_code1:isis_contrib 
Counting objects: 11, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 511 bytes, done.
Total 6 (delta 5), reused 0 (delta 0)
To git://isis.remote.tu-berlin.de/isis.git
   562dbe4..b5ec6cc  isis_my_code1 -> isis_contrib
develop1@mylaptop:~/isis$


Integrate code changes to productive

coming soon

Rebase on new Moodle version

coming soon