aboutsummaryrefslogtreecommitdiff
blob: ab80e19a8df8b9ca01566c130245ff2f97bf1a60 (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# Copyright 2024 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

from buildbot.plugins import steps as buildbot_steps
from buildbot.plugins import util
from twisted.internet import defer

from buildbot_gentoo_ci.steps import update_db
from buildbot_gentoo_ci.steps import category
from buildbot_gentoo_ci.steps import package
from buildbot_gentoo_ci.steps import version
from buildbot_gentoo_ci.steps import builders
from buildbot_gentoo_ci.steps import portage
from buildbot_gentoo_ci.steps import logs
from buildbot_gentoo_ci.steps import repos
from buildbot_gentoo_ci.steps import nodes
from buildbot_gentoo_ci.steps import clean

def update_db_check():
    f = util.BuildFactory()
    # FIXME: 1
    # Get base project data from db
    #   return profile_repository, project
    f.addStep(update_db.GetDataGentooCiProject())
    # update the repos
    #f.addStep(update_db.TriggerUpdateRepositorys())
    # Make a for loop and trigger new builders with cpv from git_changes
    #   return cpv, repository, project_data
    f.addStep(update_db.TriggerCheckForCPV())
    return f

# we run repo update in update_db_cpv instead
def update_repo_check():
    f = util.BuildFactory()
    # FIXME: 6
    # Check if needed path is there
    f.addStep(repos.CheckPathRepositoryLocal())
    # update the repos
    # FIXME:
    # use doStepIf so we don't need to do step=profile
    f.addStep(repos.CheckRepository(step='profile'))
    f.addStep(repos.CheckRepository())
    return f

def update_db_cpv():
    f = util.BuildFactory()
    # set needed Propertys
    f.addStep(package.SetupPropertys())
    # update the repositorys listed in project_repository
    f.addStep(repos.UpdateRepos())
    # add repo.conf
    #f.addStep(portage.SetReposConf())
    # if categorys in db
    #   return category_data
    #   add check category path step at end
    # else
    #   add category to db step
    #   return category_data
    f.addStep(category.CheckC())
    # if package in db
    #   return package_data
    # else
    #   add package to db step
    #   return package_data
    f.addStep(package.CheckP())
    # Trigger update_db_v
    f.addStep(package.TriggerCheckForV())
    # update metadata if needed
    f.addStep(package.CheckMetadataPackagePath())
    # clean package db if needed (clean up ebuilds in db)
    f.addStep(package.TriggerCleanPackageDb())
    return f

def update_db_v():
    f = util.BuildFactory()
    # set needed Propertys
    f.addStep(version.SetupPropertys())
    # check path
    f.addStep(version.CheckPath())
    #  if path
    #    if we have a old version
    #       mark that version as old
    #    add new version to db
    #    add version metadata to db
    #    Trigger build_request_check
    #  else
    #    mark version as old
    f.addStep(version.SetupStepsForCheckV())
    return f

def build_request_check():
    f = util.BuildFactory()
    # FIXME: 4
    # get project_data
    # check what tests to do
    # triggger build request
    f.addStep(builders.GetProjectRepositoryData())
    return f

#@defer.inlineCallbacks
def run_build_request():
    f = util.BuildFactory()
    # set needed Propertys
    f.addStep(builders.SetupPropertys())
    # update the repositorys listed in project_repository
    f.addStep(repos.UpdateRepos())
    # Clean and add new /etc/portage
    f.addStep(buildbot_steps.ShellCommand(
                        flunkOnFailure=False,
                        name='Remove portage dir',
                        command=['rm', '-R', 'portage'],
                        workdir='/etc/'
                        ))
    f.addStep(portage.SetPortageSettings())
    # Clean /var/cache/portage/logs and emerge.log
    f.addStep(buildbot_steps.ShellCommand(
                        flunkOnFailure=False,
                        name='Clean emerge.log',
                        command=['rm', 'emerge.log'],
                        workdir='/var/log/'
                        ))
    if buildbot_steps.FileExists(file='logs', workdir='/var/cache/portage/',haltOnFailure = False):
        f.addStep(buildbot_steps.ShellCommand(
                        flunkOnFailure=False,
                        name='Remove logs',
                        command=['rm', '-R', 'logs'],
                        workdir='/var/cache/portage/'
                        ))
    # setup the profile
    #NOTE: pkgcheck do not support it as a dir
    #f.addStep(buildbot_steps.MakeDirectory(dir="make.profile",
    #                            workdir='/etc/portage/'))
    f.addStep(portage.SetMakeProfile())
    # setup repos.conf dir
    #f.addStep(buildbot_steps.MakeDirectory(dir="repos.conf",
    #                            workdir='/etc/portage/'))
    #f.addStep(portage.SetReposConf())
    # setup make.conf
    f.addStep(portage.SetHostConf())
    # setup env
    #f.addStep(portage.SetEnvDefault())
    # setup package.*
    #f.addStep(portage.SetPackageDefault())
    # setup files in /etc if needed
    # run --regen if needed on repo
    # check cpv match
    f.addStep(builders.RunEmerge(step='match'))
    # Setup the needed stages for update, pkgcheck and build
    f.addStep(builders.SetupStepts())
    return f

def parse_build_log():
    f = util.BuildFactory()
    # FIXME: 6
    # set needed Propertys
    f.addStep(logs.SetupPropertys())
    # pers the build log for info qa errors
    f.addStep(logs.SetupParserBuildLoger())
    #f.addStep(logs.ParserBuildLog())
    # pers the log from pkg check
    #f.addStep(logs.ParserPkgCheckLog())
    # Upload the log to the cloud and remove the log
    #f.addStep(logs.Upload())
    # check the sum log if we need to make a issue/bug/pr report
    # set it SUCCESS/FAILURE/WARNINGS
    f.addStep(logs.MakeIssue())
    # add sum log to buildbot log
    f.addStep(logs.Summarylog())
    # pers the emerge info
    f.addStep(logs.ReadEmergeInfoLog())
    # add emerge info to log and db
    f.addStep(logs.setEmergeInfoLog())
    # add package info to log and db
    f.addStep(logs.setPackageInfoLog())
    # make the bugreport
    f.addStep(logs.SetupBugReportSteps())
    # set BuildStatus
    f.addStep(logs.setBuildStatus())
    return f

def run_build_images_request():
    f = util.BuildFactory()
    # set needed Propertys
    f.addStep(nodes.SetupPropertys())
    # set the needed steps for making the image
    f.addStep(nodes.SetupBuildTypeAndSteps())
    return f

def run_clean_db_request():
    f = util.BuildFactory()
    # set needed Propertys
    f.addStep(clean.SetupPropertys())
    return f