... | ... |
@@ -38,8 +38,7 @@ $(DOCKER_BIN): $(DOCKER_DIR) |
38 | 38 |
|
39 | 39 |
$(DOCKER_DIR): |
40 | 40 |
@mkdir -p $(dir $@) |
41 |
- @rm -f $@ |
|
42 |
- @ln -sf $(CURDIR)/ $@ |
|
41 |
+ @if [ -h $@ ]; then rm -f $@; ln -sf $(CURDIR)/ $@; fi |
|
43 | 42 |
@(cd $(DOCKER_MAIN); go get $(GO_OPTIONS)) |
44 | 43 |
|
45 | 44 |
whichrelease: |
... | ... |
@@ -75,4 +74,7 @@ fmt: |
75 | 75 |
@gofmt -s -l -w . |
76 | 76 |
|
77 | 77 |
hack: |
78 |
- cd $(CURDIR)/buildbot && vagrant up |
|
78 |
+ cd $(CURDIR)/hack && vagrant up |
|
79 |
+ |
|
80 |
+ssh-dev: |
|
81 |
+ cd $(CURDIR)/hack && vagrant ssh |
79 | 82 |
deleted file mode 100644 |
... | ... |
@@ -1,18 +0,0 @@ |
1 |
-[program:buildmaster] |
|
2 |
-command=su vagrant -c "buildbot start master" |
|
3 |
-directory=/data/buildbot |
|
4 |
-chown= root:root |
|
5 |
-redirect_stderr=true |
|
6 |
-stdout_logfile=/var/log/supervisor/buildbot-master.log |
|
7 |
-stderr_logfile=/var/log/supervisor/buildbot-master.log |
|
8 |
- |
|
9 |
-[program:buildworker] |
|
10 |
-command=buildslave start slave |
|
11 |
-directory=/data/buildbot |
|
12 |
-chown= root:root |
|
13 |
-redirect_stderr=true |
|
14 |
-stdout_logfile=/var/log/supervisor/buildbot-slave.log |
|
15 |
-stderr_logfile=/var/log/supervisor/buildbot-slave.log |
|
16 |
- |
|
17 |
-[group:buildbot] |
|
18 |
-programs=buildmaster,buildworker |
19 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,46 +0,0 @@ |
1 |
-import os |
|
2 |
-from buildbot.buildslave import BuildSlave |
|
3 |
-from buildbot.schedulers.forcesched import ForceScheduler |
|
4 |
-from buildbot.config import BuilderConfig |
|
5 |
-from buildbot.process.factory import BuildFactory |
|
6 |
-from buildbot.steps.shell import ShellCommand |
|
7 |
-from buildbot.status import html |
|
8 |
-from buildbot.status.web import authz, auth |
|
9 |
- |
|
10 |
-PORT_WEB = 8010 # Buildbot webserver port |
|
11 |
-PORT_MASTER = 9989 # Port where buildbot master listen buildworkers |
|
12 |
-TEST_USER = 'buildbot' # Credential to authenticate build triggers |
|
13 |
-TEST_PWD = 'docker' # Credential to authenticate build triggers |
|
14 |
-BUILDER_NAME = 'docker' |
|
15 |
-BUILDPASSWORD = 'pass-docker' # Credential to authenticate buildworkers |
|
16 |
-DOCKER_PATH = '/data/docker' |
|
17 |
- |
|
18 |
- |
|
19 |
-c = BuildmasterConfig = {} |
|
20 |
- |
|
21 |
-c['title'] = "Docker" |
|
22 |
-c['titleURL'] = "waterfall" |
|
23 |
-c['buildbotURL'] = "http://localhost:{0}/".format(PORT_WEB) |
|
24 |
-c['db'] = {'db_url':"sqlite:///state.sqlite"} |
|
25 |
-c['slaves'] = [BuildSlave('buildworker', BUILDPASSWORD)] |
|
26 |
-c['slavePortnum'] = PORT_MASTER |
|
27 |
- |
|
28 |
-c['schedulers'] = [ForceScheduler(name='trigger',builderNames=[BUILDER_NAME])] |
|
29 |
- |
|
30 |
-# Docker test command |
|
31 |
-test_cmd = """( |
|
32 |
- cd {0}/..; rm -rf docker-tmp; git clone docker docker-tmp; |
|
33 |
- cd docker-tmp; make test; exit_status=$?; |
|
34 |
- cd ..; rm -rf docker-tmp; exit $exit_status)""".format(DOCKER_PATH) |
|
35 |
- |
|
36 |
-# Builder |
|
37 |
-factory = BuildFactory() |
|
38 |
-factory.addStep(ShellCommand(description='Docker',logEnviron=False, |
|
39 |
- usePTY=True,command=test_cmd)) |
|
40 |
-c['builders'] = [BuilderConfig(name=BUILDER_NAME,slavenames=['buildworker'], |
|
41 |
- factory=factory)] |
|
42 |
- |
|
43 |
-# Status |
|
44 |
-authz_cfg=authz.Authz(auth=auth.BasicAuth([(TEST_USER,TEST_PWD)]), |
|
45 |
- forceBuild='auth') |
|
46 |
-c['status'] = [html.WebStatus(http_port=PORT_WEB, authz=authz_cfg)] |
47 | 1 |
deleted file mode 100755 |
... | ... |
@@ -1,21 +0,0 @@ |
1 |
-#!/usr/bin/env python |
|
2 |
- |
|
3 |
-'''Trigger buildbot docker test build |
|
4 |
- |
|
5 |
- post-commit git hook designed to automatically trigger buildbot on |
|
6 |
- the provided vagrant docker VM.''' |
|
7 |
- |
|
8 |
-import requests |
|
9 |
- |
|
10 |
-USERNAME = 'buildbot' |
|
11 |
-PASSWORD = 'docker' |
|
12 |
-BASE_URL = 'http://localhost:8010' |
|
13 |
-path = lambda s: BASE_URL + '/' + s |
|
14 |
- |
|
15 |
-try: |
|
16 |
- session = requests.session() |
|
17 |
- session.post(path('login'),data={'username':USERNAME,'passwd':PASSWORD}) |
|
18 |
- session.post(path('builders/docker/force'), |
|
19 |
- data={'forcescheduler':'trigger','reason':'Test commit'}) |
|
20 |
-except: |
|
21 |
- pass |
0 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,36 @@ |
0 |
+# -*- mode: ruby -*- |
|
1 |
+# vi: set ft=ruby : |
|
2 |
+ |
|
3 |
+BOX_NAME = "ubuntu" |
|
4 |
+BOX_URI = "http://files.vagrantup.com/precise64.box" |
|
5 |
+PPA_KEY = "E61D797F63561DC6" |
|
6 |
+VM_IP = "192.168.33.21" |
|
7 |
+USER = "vagrant" |
|
8 |
+GOPATH = "/data/docker" |
|
9 |
+DOCKER_PATH = "#{GOPATH}/src/github.com/dotcloud/docker" |
|
10 |
+CFG_PATH = "#{DOCKER_PATH}/hack/environment" |
|
11 |
+BUILDBOT_PATH = "/data/buildbot" |
|
12 |
+ |
|
13 |
+Vagrant::Config.run do |config| |
|
14 |
+ # Setup virtual machine box |
|
15 |
+ config.vm.box = BOX_NAME |
|
16 |
+ config.vm.box_url = BOX_URI |
|
17 |
+ config.vm.share_folder "v-data", DOCKER_PATH, "#{File.dirname(__FILE__)}/.." |
|
18 |
+ config.vm.network :hostonly, VM_IP |
|
19 |
+ # Stop if deployment has been done |
|
20 |
+ config.vm.provision :shell, :inline => "[ ! -f /usr/bin/git ]" |
|
21 |
+ # Touch for makefile |
|
22 |
+ pkg_cmd = "touch #{DOCKER_PATH}; " |
|
23 |
+ # Install docker dependencies |
|
24 |
+ pkg_cmd << "export DEBIAN_FRONTEND=noninteractive; apt-get -qq update; " \ |
|
25 |
+ "apt-get install -q -y lxc bsdtar git golang make; " \ |
|
26 |
+ "chown -R #{USER}.#{USER} #{GOPATH}; " \ |
|
27 |
+ "install -m 0664 #{CFG_PATH}/bash_profile /home/#{USER}/.bash_profile" |
|
28 |
+ config.vm.provision :shell, :inline => pkg_cmd |
|
29 |
+ # Deploy buildbot CI |
|
30 |
+ pkg_cmd = "apt-get install -q -y python-dev python-pip supervisor; " \ |
|
31 |
+ "pip install -r #{CFG_PATH}/requirements.txt; " \ |
|
32 |
+ "chown #{USER}.#{USER} /data; cd /data; " \ |
|
33 |
+ "#{CFG_PATH}/setup.sh #{USER} #{GOPATH} #{DOCKER_PATH} #{CFG_PATH} #{BUILDBOT_PATH}" |
|
34 |
+ config.vm.provision :shell, :inline => pkg_cmd |
|
35 |
+end |
0 | 36 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,20 @@ |
0 |
+Buildbot |
|
1 |
+======== |
|
2 |
+ |
|
3 |
+Buildbot is a continuous integration system designed to automate the |
|
4 |
+build/test cycle. By automatically rebuilding and testing the tree each time |
|
5 |
+something has changed, build problems are pinpointed quickly, before other |
|
6 |
+developers are inconvenienced by the failure. |
|
7 |
+ |
|
8 |
+When running 'make hack' at the docker root directory, it spawns a virtual |
|
9 |
+machine in the background running a buildbot instance and adds a git |
|
10 |
+post-commit hook that automatically run docker tests for you. |
|
11 |
+ |
|
12 |
+You can check your buildbot instance at http://192.168.33.21:8010/waterfall |
|
13 |
+ |
|
14 |
+ |
|
15 |
+Buildbot dependencies |
|
16 |
+--------------------- |
|
17 |
+ |
|
18 |
+vagrant, virtualbox packages and python package requests |
|
19 |
+ |
0 | 20 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,19 @@ |
0 |
+# ~/.bash_profile : executed by the command interpreter for login shells. |
|
1 |
+ |
|
2 |
+# if running bash |
|
3 |
+if [ -n "$BASH_VERSION" ]; then |
|
4 |
+ # include .bashrc if it exists |
|
5 |
+ if [ -f "$HOME/.bashrc" ]; then |
|
6 |
+ . "$HOME/.bashrc" |
|
7 |
+ fi |
|
8 |
+fi |
|
9 |
+ |
|
10 |
+# set PATH so it includes user's private bin if it exists |
|
11 |
+[ -d "$HOME/bin" ] && PATH="$HOME/bin:$PATH" |
|
12 |
+ |
|
13 |
+docker=/data/docker/src/github.com/dotcloud/docker |
|
14 |
+[ -d $docker ] && cd $docker |
|
15 |
+ |
|
16 |
+export GOPATH=/data/docker |
|
17 |
+export PATH=$PATH:$GOPATH/bin |
|
18 |
+ |
0 | 19 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,18 @@ |
0 |
+[program:buildmaster] |
|
1 |
+command=su vagrant -c "buildbot start master" |
|
2 |
+directory=/data/buildbot |
|
3 |
+chown= root:root |
|
4 |
+redirect_stderr=true |
|
5 |
+stdout_logfile=/var/log/supervisor/buildbot-master.log |
|
6 |
+stderr_logfile=/var/log/supervisor/buildbot-master.log |
|
7 |
+ |
|
8 |
+[program:buildworker] |
|
9 |
+command=buildslave start slave |
|
10 |
+directory=/data/buildbot |
|
11 |
+chown= root:root |
|
12 |
+redirect_stderr=true |
|
13 |
+stdout_logfile=/var/log/supervisor/buildbot-slave.log |
|
14 |
+stderr_logfile=/var/log/supervisor/buildbot-slave.log |
|
15 |
+ |
|
16 |
+[group:buildbot] |
|
17 |
+programs=buildmaster,buildworker |
0 | 18 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,43 @@ |
0 |
+import os |
|
1 |
+from buildbot.buildslave import BuildSlave |
|
2 |
+from buildbot.schedulers.forcesched import ForceScheduler |
|
3 |
+from buildbot.config import BuilderConfig |
|
4 |
+from buildbot.process.factory import BuildFactory |
|
5 |
+from buildbot.steps.shell import ShellCommand |
|
6 |
+from buildbot.status import html |
|
7 |
+from buildbot.status.web import authz, auth |
|
8 |
+ |
|
9 |
+PORT_WEB = 8010 # Buildbot webserver port |
|
10 |
+PORT_MASTER = 9989 # Port where buildbot master listen buildworkers |
|
11 |
+TEST_USER = 'buildbot' # Credential to authenticate build triggers |
|
12 |
+TEST_PWD = 'docker' # Credential to authenticate build triggers |
|
13 |
+BUILDER_NAME = 'docker' |
|
14 |
+BUILDPASSWORD = 'pass-docker' # Credential to authenticate buildworkers |
|
15 |
+GOPATH = '/data/docker' |
|
16 |
+DOCKER_PATH = '{0}/src/github.com/dotcloud/docker'.format(GOPATH) |
|
17 |
+ |
|
18 |
+c = BuildmasterConfig = {} |
|
19 |
+ |
|
20 |
+c['title'] = "Docker" |
|
21 |
+c['titleURL'] = "waterfall" |
|
22 |
+c['buildbotURL'] = "http://localhost:{0}/".format(PORT_WEB) |
|
23 |
+c['db'] = {'db_url':"sqlite:///state.sqlite"} |
|
24 |
+c['slaves'] = [BuildSlave('buildworker', BUILDPASSWORD)] |
|
25 |
+c['slavePortnum'] = PORT_MASTER |
|
26 |
+ |
|
27 |
+c['schedulers'] = [ForceScheduler(name='trigger',builderNames=[BUILDER_NAME])] |
|
28 |
+ |
|
29 |
+# Docker test command |
|
30 |
+test_cmd = "GOPATH={0} make -C {1} test".format(GOPATH,DOCKER_PATH) |
|
31 |
+ |
|
32 |
+# Builder |
|
33 |
+factory = BuildFactory() |
|
34 |
+factory.addStep(ShellCommand(description='Docker',logEnviron=False, |
|
35 |
+ usePTY=True,command=test_cmd)) |
|
36 |
+c['builders'] = [BuilderConfig(name=BUILDER_NAME,slavenames=['buildworker'], |
|
37 |
+ factory=factory)] |
|
38 |
+ |
|
39 |
+# Status |
|
40 |
+authz_cfg=authz.Authz(auth=auth.BasicAuth([(TEST_USER,TEST_PWD)]), |
|
41 |
+ forceBuild='auth') |
|
42 |
+c['status'] = [html.WebStatus(http_port=PORT_WEB, authz=authz_cfg)] |
0 | 43 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,21 @@ |
0 |
+#!/usr/bin/env python |
|
1 |
+ |
|
2 |
+'''Trigger buildbot docker test build |
|
3 |
+ |
|
4 |
+ post-commit git hook designed to automatically trigger buildbot on |
|
5 |
+ the provided vagrant docker VM.''' |
|
6 |
+ |
|
7 |
+import requests |
|
8 |
+ |
|
9 |
+USERNAME = 'buildbot' |
|
10 |
+PASSWORD = 'docker' |
|
11 |
+BASE_URL = 'http://localhost:8010' |
|
12 |
+path = lambda s: BASE_URL + '/' + s |
|
13 |
+ |
|
14 |
+try: |
|
15 |
+ session = requests.session() |
|
16 |
+ session.post(path('login'),data={'username':USERNAME,'passwd':PASSWORD}) |
|
17 |
+ session.post(path('builders/docker/force'), |
|
18 |
+ data={'forcescheduler':'trigger','reason':'Test commit'}) |
|
19 |
+except: |
|
20 |
+ pass |
0 | 6 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,45 @@ |
0 |
+#!/bin/bash |
|
1 |
+ |
|
2 |
+# Setup of buildbot configuration. Package installation is being done by |
|
3 |
+# Vagrantfile |
|
4 |
+# Dependencies: buildbot, buildbot-slave, supervisor |
|
5 |
+ |
|
6 |
+USER=$1 |
|
7 |
+GOPATH=$2 |
|
8 |
+DOCKER_PATH=$3 |
|
9 |
+CFG_PATH=$4 |
|
10 |
+BUILDBOT_PATH=$5 |
|
11 |
+SLAVE_NAME="buildworker" |
|
12 |
+SLAVE_SOCKET="localhost:9989" |
|
13 |
+BUILDBOT_PWD="pass-docker" |
|
14 |
+IP=$(sed -nE 's/VM_IP = "(.+)"/\1/p' ${DOCKER_PATH}/hack/Vagrantfile) |
|
15 |
+export PATH="/bin:sbin:/usr/bin:/usr/sbin:/usr/local/bin" |
|
16 |
+ |
|
17 |
+function run { su $USER -c "$1"; } |
|
18 |
+ |
|
19 |
+# Exit if buildbot has already been installed |
|
20 |
+[ -d "$BUILDBOT_PATH" ] && exit 0 |
|
21 |
+ |
|
22 |
+# Setup buildbot |
|
23 |
+run "mkdir -p $BUILDBOT_PATH" |
|
24 |
+cd $BUILDBOT_PATH |
|
25 |
+run "buildbot create-master master" |
|
26 |
+run "cp $CFG_PATH/master.cfg master" |
|
27 |
+run "sed -i 's/localhost/$IP/' master/master.cfg" |
|
28 |
+run "sed -i -E 's#(GOPATH = ).+#\1\"$GOPATH\"#' master/master.cfg" |
|
29 |
+run "sed -i -E 's#(DOCKER_PATH = ).+#\1\"$DOCKER_PATH\"#' master/master.cfg" |
|
30 |
+run "buildslave create-slave slave $SLAVE_SOCKET $SLAVE_NAME $BUILDBOT_PWD" |
|
31 |
+ |
|
32 |
+# Allow buildbot subprocesses (docker tests) to properly run in containers, |
|
33 |
+# in particular with docker -u |
|
34 |
+run "sed -i 's/^umask = None/umask = 000/' slave/buildbot.tac" |
|
35 |
+ |
|
36 |
+# Setup supervisor |
|
37 |
+cp $CFG_PATH/buildbot.conf /etc/supervisor/conf.d/buildbot.conf |
|
38 |
+sed -i -E "s/^chmod=0700.+/chmod=0770\nchown=root:$USER/" /etc/supervisor/supervisord.conf |
|
39 |
+kill -HUP $(pgrep -f "/usr/bin/python /usr/bin/supervisord") |
|
40 |
+ |
|
41 |
+# Add git hook |
|
42 |
+cp $CFG_PATH/post-commit $DOCKER_PATH/.git/hooks |
|
43 |
+sed -i "s/localhost/$IP/" $DOCKER_PATH/.git/hooks/post-commit |
|
44 |
+ |