1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
import json
from buildbot.process.factory import BuildFactory
from buildbot.steps.source.git import Git
from buildbot.steps.shell import ShellCommand
from buildbot.config import BuilderConfig
from buildbot.locks import MasterLock
from buildbot.steps.transfer import DirectoryUpload
class PullCommand(ShellCommand):
def setBuild(self, build):
ShellCommand.setBuild(self, build)
revisions = {}
for source in build.getAllSourceStamps():
if source.revision:
revisions[source.codebase] = source.revision
command = ["./osbuild", "pull"]
if revisions:
revisions_json = json.dumps(revisions)
command.extend(["--revisions", revisions_json])
self.setCommand(command)
def create_factory(config, env={}, full=False, upload_docs=False):
log_path = "build/logs/main.log"
factory = BuildFactory()
factory.addStep(Git(repourl=config["repo"],
codebase="sugar-build",
branch=config.get("branch", "master")))
factory.addStep(ShellCommand(command=["./osbuild", "check-config"],
description="checking config",
descriptionDone="check config",
haltOnFailure=True,
env=env))
if config.get("check_system", True):
command = ["./osbuild", "check-system", "--update", "--remove"]
factory.addStep(ShellCommand(command=command,
description="checking system",
descriptionDone="check system",
warnOnFailure=True,
logfiles={"log": log_path},
env=env))
factory.addStep(PullCommand(description="pulling",
descriptionDone="pull",
haltOnFailure=True,
logfiles={"log": log_path},
env=env))
command = ["./osbuild", "build"]
if full:
command.append("--clean-all")
factory.addStep(ShellCommand(command=command,
description="building",
descriptionDone="build",
haltOnFailure=True,
logfiles={"log": log_path},
env=env))
factory.addStep(ShellCommand(command=["./osbuild", "check"],
description="checking",
descriptionDone="check",
haltOnFailure=True,
logfiles={"log": log_path,
"sugar": "build/logs/sugar.log"},
env=env))
factory.addStep(ShellCommand(command=["./osbuild", "docs"],
description="docs",
descriptionDone="docs",
haltOnFailure=True,
logfiles={"log": log_path},
env=env))
if upload_docs:
docs_url = "http://shell.sugarlabs.org/~buildbot/docs/index.md.html"
factory.addStep(DirectoryUpload(slavesrc="build/out/docs",
masterdest="~/public_html/docs",
url=docs_url))
return factory
def setup(c, config):
c["builders"] = []
locks = {}
for name, info in config["slaves"].items():
lock_name = info.get("lock", None)
if lock_name and lock_name not in locks:
locks[lock_name] = MasterLock(lock_name)
env = {"SUGAR_BUILDBOT": name,
"PYTHONUNBUFFERED": "yes"}
factory = create_factory(config, env=env,
upload_docs=info.get("upload_docs", False))
builder = BuilderConfig(name="%s-quick" % name,
slavenames=[name],
factory=factory,
category="quick",
locks=[locks[lock_name].access("exclusive")])
c["builders"].append(builder)
factory = create_factory(config, env=env, full=True)
builder = BuilderConfig(name="%s-full" % name,
slavenames=[name],
factory=factory,
category="full",
locks=[locks[lock_name].access("exclusive")])
c["builders"].append(builder)
|