HTML report: link to summary matrix
[ci.git] / build.py
blobd77ad9fc6fc419ebd2f6e2c81245a6f6068930bb
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('--jobs', default=multiprocessing.cpu_count(), dest='jobs',
99 type=int,
100 metavar='COUNT',
101 help='Number of concurrent jobs.'
103 args.add_argument('--no-colors', default=False, dest='no_colors',
104 action='store_true',
105 help='Disable colorful output'
107 args.add_argument('--debug', default=False, dest='debug',
108 action='store_true',
109 help='Print debugging messages'
112 config = args.parse_args()
113 config.artefact_directory = os.path.abspath(config.artefact_directory)
114 config.build_directory = os.path.abspath(config.build_directory)
115 config.self_path = os.path.dirname(os.path.realpath(sys.argv[0]))
117 printer = ConsolePrinter(config.no_colors)
119 if config.vm_memory_size < 8:
120 printer.print_warning("VM memory size too small, upgrading to 8MB.")
121 config.vm_memory_size = 8
123 scheduler = BuildScheduler(
124 max_workers=config.jobs,
125 build=config.build_directory,
126 artefact=config.artefact_directory,
127 build_id=config.build_id,
128 printer=printer,
129 debug=config.debug
133 # Check-out both HelenOS and coastline repositories
134 scheduler.submit("Checking-out HelenOS",
135 "helenos-checkout",
136 create_checkout_task("helenos", config.helenos_repository))
137 scheduler.submit("Checking-out Coastline",
138 "coastline-checkout",
139 create_checkout_task("coastline", config.coastline_repository))
142 # HelenOS (mainline): get list of profiles (i.e. supported architectures
143 # and platforms) and build all of them
144 scheduler.submit("Determininig available profiles",
145 "helenos-get-profiles",
146 HelenOSGetProfilesTask(config.platforms.split(',')),
147 ["helenos-checkout"])
150 scheduler.submit("Schedule HelenOS builds",
151 "helenos-build",
152 HelenOSScheduleBuildsTask(scheduler),
153 ["helenos-get-profiles"])
157 # Coastline: get list of harbours (i.e. ported software) and build all of them
158 # for all HelenOS builds
159 scheduler.submit("Determining available harbours",
160 "coastline-get-harbours",
161 CoastlineGetHarboursTask(config.harbours.split(',')),
162 ["coastline-checkout"])
164 scheduler.submit("Schedule harbour tarballs fetches",
165 "coastline-fetch",
166 CoastlineScheduleFetchesTask(scheduler),
167 ["coastline-get-harbours" ])
170 scheduler.submit("Schedule Coastline builds",
171 "coastline-build",
172 CoastlineScheduleBuildsTask(scheduler),
174 # Data dependencies
175 "helenos-get-profiles", "coastline-get-harbours",
176 # Task dependencies
177 "helenos-build", "coastline-fetch"
181 extra_builds = HelenOSExtraBuildsManager(scheduler)
184 # Tests
185 scheduler.submit("Determine available test scenarios",
186 "tests-get-list",
187 GetTestListTask(config.self_path, config.tests.split(',')),
190 scheduler.submit("Schedule tests",
191 "tests-schedule",
192 ScheduleTestsTask(scheduler,
193 extra_builds,
194 config.self_path,
195 [ "--memory={}".format(config.vm_memory_size) ]
198 "tests-get-list",
199 "helenos-build",
200 "coastline-build"
205 # Wait for all builds (and everything) to complete before creating
206 # the web page with results.
207 scheduler.barrier()
209 scheduler.close_report()
211 scheduler.submit("Generate HTML report",
212 "html-report",
213 MakeHtmlReportTask(config.self_path, config.rss_url, config.web_resource_path))
216 scheduler.done()