[ews-build] Add support for API tests in OpenSource EWS
[WebKit-https.git] / Tools / BuildSlaveSupport / ews-build / factories.py
1 # Copyright (C) 2018 Apple Inc. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions
5 # are met:
6 # 1.  Redistributions of source code must retain the above copyright
7 #     notice, this list of conditions and the following disclaimer.
8 # 2.  Redistributions in binary form must reproduce the above copyright
9 #     notice, this list of conditions and the following disclaimer in the
10 #     documentation and/or other materials provided with the distribution.
11 #
12 # THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND
13 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
14 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15 # DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR
16 # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
18 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
19 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
20 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
21 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
23
24 from buildbot.process import factory, properties
25 from buildbot.steps import trigger
26
27 from steps import *
28
29 Property = properties.Property
30
31
32 class Factory(factory.BuildFactory):
33     def __init__(self, platform, configuration=None, architectures=None, buildOnly=True, additionalArguments=None, **kwargs):
34         factory.BuildFactory.__init__(self)
35         self.addStep(ConfigureBuild(platform, configuration, architectures, buildOnly, additionalArguments))
36         self.addStep(CheckOutSource())
37
38
39 class StyleFactory(Factory):
40     def __init__(self, platform, configuration=None, architectures=None, additionalArguments=None, **kwargs):
41         Factory.__init__(self, platform, configuration, architectures, False, additionalArguments)
42         self.addStep(CheckStyle())
43
44
45 class BindingsFactory(Factory):
46     def __init__(self, platform, configuration=None, architectures=None, additionalArguments=None, **kwargs):
47         Factory.__init__(self, platform, configuration, architectures, False, additionalArguments)
48         self.addStep(RunBindingsTests())
49
50
51 class WebKitPerlFactory(Factory):
52     def __init__(self, platform, configuration=None, architectures=None, additionalArguments=None, **kwargs):
53         Factory.__init__(self, platform, configuration, architectures, False, additionalArguments)
54         self.addStep(RunWebKitPerlTests())
55
56
57 class WebKitPyFactory(Factory):
58     def __init__(self, platform, configuration=None, architectures=None, additionalArguments=None, **kwargs):
59         Factory.__init__(self, platform, configuration, architectures, False, additionalArguments)
60         self.addStep(RunWebKitPyTests())
61
62
63 class BuildFactory(Factory):
64     def __init__(self, platform, configuration=None, architectures=None, additionalArguments=None, triggers=None, **kwargs):
65         Factory.__init__(self, platform, configuration, architectures, False, additionalArguments)
66         self.addStep(KillOldProcesses())
67         self.addStep(CleanBuild())
68         self.addStep(CompileWebKit())
69         self.addStep(UnApplyPatchIfRequired())
70         self.addStep(CompileWebKitToT())
71         if triggers:
72             self.addStep(ArchiveBuiltProduct())
73             self.addStep(UploadBuiltProduct())
74             self.addStep(trigger.Trigger(schedulerNames=triggers, set_properties=self.propertiesToPassToTriggers() or {}))
75
76     def propertiesToPassToTriggers(self):
77         return {
78             "ewspatchid": Property("ewspatchid"),
79             "configuration": Property("configuration"),
80             "platform": Property("platform"),
81             "fullPlatform": Property("fullPlatform"),
82             "architecture": Property("architecture"),
83         }
84
85
86 class JSCTestsFactory(Factory):
87     def __init__(self, platform, configuration='release', architectures=None, additionalArguments=None, **kwargs):
88         Factory.__init__(self, platform, configuration, architectures, False, additionalArguments)
89         self.addStep(CompileJSCOnly())
90         self.addStep(UnApplyPatchIfRequired())
91         self.addStep(CompileJSCOnlyToT())
92         self.addStep(RunJavaScriptCoreTests())
93         self.addStep(ReRunJavaScriptCoreTests())
94         self.addStep(UnApplyPatchIfRequired())
95         self.addStep(RunJavaScriptCoreTestsToT())
96
97
98 class APITestsFactory(Factory):
99     def getProduct(self):
100         self.addStep(DownloadBuiltProduct())
101         self.addStep(ExtractBuiltProduct())
102
103     def __init__(self, platform, configuration=None, architectures=None, additionalArguments=None, **kwargs):
104         Factory.__init__(self, platform, configuration, architectures, False, additionalArguments)
105         self.getProduct()
106         self.addStep(RunAPITests())
107
108
109 class GTKFactory(Factory):
110     pass
111
112
113 class iOSFactory(BuildFactory):
114     pass
115
116
117 class iOSSimulatorFactory(BuildFactory):
118     def __init__(self, platform, configuration=None, architectures=None, additionalArguments=None, triggers=None, **kwargs):
119         BuildFactory.__init__(self, platform, configuration, architectures, additionalArguments, triggers)
120         self.addStep(RunWebKitTests())
121
122
123 class MacWK1Factory(BuildFactory):
124     pass
125
126
127 class MacWK2Factory(BuildFactory):
128     pass
129
130
131 class WindowsFactory(Factory):
132     pass
133
134
135 class WinCairoFactory(Factory):
136     pass
137
138
139 class WPEFactory(Factory):
140     pass