Update FS test (FAT server is already started)
[ci.git] / build.py
blob6d673e5799ce204de53e9b263c095be7183a2e62
1 #!/usr/bin/env python3
4 # Copyright (c) 2017 Vojtech Horky
5 # All rights reserved.
7 # Redistribution and use in source and binary forms, with or without
8 # modification, are permitted provided that the following conditions
9 # are met:
11 # - Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # - Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
16 # - The name of the author may not be used to endorse or promote products
17 # derived from this software without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 import subprocess
32 import os
33 import time
34 import sys
35 import argparse
36 import multiprocessing
37 from hbuild.scheduler import BuildScheduler
38 from hbuild.cvs import *
39 from hbuild.builders.helenos import *
40 from hbuild.builders.coastline import *
41 from hbuild.builders.tests import *
42 from hbuild.web import *
43 from hbuild.output import ConsolePrinter
45 def create_checkout_task(name, url):
46 if url.startswith("wip://"):
47 return RsyncCheckoutTask(name, url[6:])
48 else:
49 return BzrCheckoutTask(name, url)
51 # Command-line options
52 args = argparse.ArgumentParser(description='HelenOS integration build')
53 args.add_argument('--helenos-repository', default='bzr://helenos.org/mainline', dest='helenos_repository',
54 metavar='PATH',
55 help='HelenOS repository path'
57 args.add_argument('--coastline-repository', default='bzr://helenos.org/coastline', dest='coastline_repository',
58 metavar='PATH',
59 help='Coastline repository path'
61 args.add_argument('--build-id', default='0', dest='build_id',
62 metavar='ID',
63 help='Build id (typically sequence number).',
65 args.add_argument('--rss-url', default='', dest='rss_url',
66 metavar='URL_WITH_RSS',
67 help='URL of RSS for latest builds.'
69 args.add_argument('--resource-path', default=None, dest='web_resource_path',
70 metavar='RELATIVE_PATH',
71 help='Path where static web resources are stored (when specified, the resources are NOT copied).'
73 args.add_argument('--build-directory', default=os.path.abspath('tmp'), dest='build_directory',
74 metavar='DIR',
75 help='Where to build (space for temporary files).',
77 args.add_argument('--artefact-directory', default=os.path.abspath('out/'), dest='artefact_directory',
78 metavar='DIR',
79 help='Where to place downloadable files and HTML report.'
81 args.add_argument('--platforms', default='ALL', dest='platforms',
82 metavar='PLATFORM1[,PLATFORM2[,...]',
83 help='Which platforms to build (defaults to all detected ones; can be either machine specific "ia64/ski" or architecture specific "ia64/*").'
85 args.add_argument('--harbours', default='ALL', dest='harbours',
86 metavar='HARBOUR1[,HARBOUR2[,...]',
87 help='Which harbours to build (defaults to all detected ones).'
89 args.add_argument('--tests', default='ALL', dest='tests',
90 metavar='TEST1[,TEST2[,...]]',
91 help='Which tests to run (shell wildcards supported).'
93 args.add_argument('--vm-memory-size', default=256, dest='vm_memory_size',
94 type=int,
95 metavar='RAM_SIZE_IN_MB',
96 help='How much memory to give the virtual machine running the tests.'
98 args.add_argument('--inline-log-lines', default=10, dest='inline_log_lines',
99 type=int,
100 metavar='LINES',
101 help='How many lines of log to show on the web page.'
103 args.add_argument('--archive-format', default='tar.xz', dest='archive_format',
104 choices=['tar.xz', 'tar.gz'],
105 metavar='FORMAT',
106 help='Format of the archives (tar.gz or tar.xz).'
108 args.add_argument('--jobs', default=multiprocessing.cpu_count(), dest='jobs',
109 type=int,
110 metavar='COUNT',
111 help='Number of concurrent jobs.'
113 args.add_argument('--no-colors', default=False, dest='no_colors',
114 action='store_true',
115 help='Disable colorful output'
117 args.add_argument('--debug', default=False, dest='debug',
118 action='store_true',
119 help='Print debugging messages'
122 config = args.parse_args()
123 config.artefact_directory = os.path.abspath(config.artefact_directory)
124 config.build_directory = os.path.abspath(config.build_directory)
125 config.self_path = os.path.dirname(os.path.realpath(sys.argv[0]))
127 printer = ConsolePrinter(config.no_colors)
129 if config.vm_memory_size < 8:
130 printer.print_warning("VM memory size too small, upgrading to 8MB.")
131 config.vm_memory_size = 8
133 scheduler = BuildScheduler(
134 max_workers=config.jobs,
135 build=config.build_directory,
136 artefact=config.artefact_directory,
137 build_id=config.build_id,
138 printer=printer,
139 inline_log_lines=config.inline_log_lines,
140 debug=config.debug
144 # Check-out both HelenOS and coastline repositories
145 scheduler.submit("Checking-out HelenOS",
146 "helenos-checkout",
147 create_checkout_task("helenos", config.helenos_repository))
148 scheduler.submit("Checking-out Coastline",
149 "coastline-checkout",
150 create_checkout_task("coastline", config.coastline_repository))
153 # HelenOS (mainline): get list of profiles (i.e. supported architectures
154 # and platforms) and build all of them
155 scheduler.submit("Determininig available profiles",
156 "helenos-get-profiles",
157 HelenOSGetProfilesTask(config.platforms.split(',')),
158 ["helenos-checkout"])
161 scheduler.submit("Schedule HelenOS builds",
162 "helenos-build",
163 HelenOSScheduleBuildsTask(scheduler),
164 ["helenos-get-profiles"])
168 # Coastline: get list of harbours (i.e. ported software) and build all of them
169 # for all HelenOS builds
170 scheduler.submit("Determining available harbours",
171 "coastline-get-harbours",
172 CoastlineGetHarboursTask(config.harbours.split(',')),
173 ["coastline-checkout"])
175 scheduler.submit("Schedule harbour tarballs fetches",
176 "coastline-fetch",
177 CoastlineScheduleFetchesTask(scheduler),
178 ["coastline-get-harbours" ])
181 scheduler.submit("Schedule Coastline builds",
182 "coastline-build",
183 CoastlineScheduleBuildsTask(scheduler, config.archive_format),
185 # Data dependencies
186 "helenos-get-profiles", "coastline-get-harbours",
187 # Task dependencies
188 "helenos-build", "coastline-fetch"
192 extra_builds = HelenOSExtraBuildsManager(scheduler)
195 # Tests
196 scheduler.submit("Determine available test scenarios",
197 "tests-get-list",
198 GetTestListTask(config.self_path, config.tests.split(',')),
201 scheduler.submit("Schedule tests",
202 "tests-schedule",
203 ScheduleTestsTask(scheduler,
204 extra_builds,
205 config.self_path,
206 [ "--memory={}".format(config.vm_memory_size) ]
209 "tests-get-list",
210 "helenos-build",
211 "coastline-build"
216 # Wait for all builds (and everything) to complete before creating
217 # the web page with results.
218 scheduler.barrier()
220 scheduler.close_report()
222 scheduler.submit("Generate HTML report",
223 "html-report",
224 MakeHtmlReportTask(config.self_path, config.rss_url, config.web_resource_path))
227 scheduler.done()