Build system

Build system

How it works

 * Script(refresh.rb) listen for messages from github hooks setted to commit
 * When such message recieved - script extracts branch name, and call scripts for adding platform build task and webside building
 * If branch name is master - only platform is builded, tested and deployed
 * If branch name is web-devel - only webside is builded, tested and deployed
 * For other branches platform and webside building and unittesting are performed
 * For all branches after this stuff report are sended to the mail-list
 * Also one time at day simmilar scripts are called - they clean DB and reinstall webside and platform

Scripts
./build_platform.sh branch_name If branch name is devel then platform is fully deployed and tested, if branch name is web-devel nothing happens. Otherwise platform is just builded and unittested. After all steps mail report is sended.
 * build_platform.sh* script allow to build, test and deploy platform. It should called like this:

build_webside.sh script allow to build, test and deploy webside. It should called like this: ./build_webside.sh branch_name If branch name is web-devel then webside is fully deployed and tested, if branch name is \devel nothing happens. Otherwise webside is just builded and unittested. After all steps mail report is sended.

clean_db.sh script stops webside, stops platform, delete DB and install backuped version of platform. This script hasnt any parameters.

midnight_deploy.sh script reinstall webside and call *clean_db.sh* script. After this report is sended to the mail list.

refresh.rb script recieve messages about commit, parse it and call *build_platform.sh* and *build_webside.sh*.

test_platform.sh script implement tests for platform.

add_deb_build_task.sh script add new build task

check_deb_build_tasks.sh perform all tasks sequentaly

Platform build
Because platfrom building is a long (~10 min.) operation and collisions may appears when two different branches are building in the same time, build tasks queueing was implemented.

When information about new commit is recieved by refresh.rb, new build task are added by calling add_deb_build_task.sh script. Build task is a text file with name the same as branch. All tasks are stored in special folder (deb_build_tasks). If task already exist in a queue, then add_deb_build_task.sh just updates modification time of task.

check_deb_build_tasks.sh script are runned periodicaly using cron (period = 3 min.) and builds all tasks sequentaly. This script work by next algorithm:
 * 1) Existance of build_platform.sh or clean_db.sh processes are checked. If processes exist then check_deb_build_tasks.sh terminates work.
 * 2) In other case queue are formed from task folder using FIFO rule (first tasks - oldest tasks, last tasks - newest tasks)
 * 3) For all tasks next procedure performed:
 * 4) Script sends letter with header [Geo2tag-commits] Starting platform build at branch branch (n in queue) and body (contains branch names in queue), where n is a current amount of tasks in queue.
 * 5) Script removes task from queue
 * 6) Script calls build_platform.sh script for task`s branch

build_platform.sh script performes building for all branches (except web-devel) and deploy with testing for master branch. When all actions for branch are finished and it is oblivious, was build failed or not, script sends letter to the mailing list.

For all branches except master, subject of the letter looks this:

[Geo2tag-commits] (status) geo2tag-platform branch_name : build and test reports

or in case of master:

[Geo2tag-commits] (status) geo2tag-platform master: integration reports

where status = {success,fail}. If status = fail then letter body contains possible reason of error and log file name with detailed problem reasons.