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
|
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
from twisted.internet import defer
from buildbot.plugins import util
from buildbot_gentoo_ci.config import buildfactorys
def getWorkersLocal(worker_type, workers):
worker_list = []
for worker in workers:
if worker['type'] == worker_type and worker['enable'] is True:
worker_list.append(worker['name'])
return worker_list
def getWorkers(worker_type, workers):
worker_list = []
for worker in workers:
if worker['type'] == worker_type and worker['enable'] is True:
worker_list.append(worker['uuid'])
return worker_list
# check if we have same package_data
@defer.inlineCallbacks
def checkPackageData(master, builder, req1, req2):
canBeCollapsed = yield buildrequest.BuildRequest.canBeCollapsed(master, req1, req2)
selfBuildset , otherBuildset = yield defer.gatherResults([
master.data.get(('buildsets', req1['buildsetid'])),
master.data.get(('buildsets', req2['buildsetid']))
])
print(f"TestCollapsed")
print(f"canBeCollapsed: {canBeCollapsed}")
print(f"selfBuildset: {selfBuildset}")
print(f"otherBuildset: {otherBuildset}")
if canBeCollapsed and selfBuildset['parent_buildid'] != None and \
otherBuildset['parent_buildid'] != None:
return True
else:
return False
@defer.inlineCallbacks
def CanWorkerBuildProject(builder, wfb, request):
gentooci = builder.master.namedServices['services'].namedServices['gentooci']
project_build_data = request.properties['project_build_data']
project_workers = yield gentooci.db.projects.getWorkersByProjectUuid(project_build_data['project_uuid'])
print(project_workers)
print(wfb)
for worker in project_workers:
if wfb.worker.workername == worker['worker_uuid']:
print('Find a worker: YES')
return True
print('Find a worker: NO')
return False
# Use same worker as update_cpv_data was done by so we have same git commit
def CanWorkerUpdateV(builder, wfb, request):
print(request.properties['cp_worker'])
print(wfb)
if wfb.worker.workername == request.properties['cp_worker']:
print('Find a worker: YES')
return True
print('Find a worker: NO')
return False
def gentoo_builders(worker_data):
b = []
b.append(util.BuilderConfig(
name='update_db_check',
workername=getWorkersLocal('local', worker_data['local'])[0],
workerbuilddir='builds',
collapseRequests=False,
factory=buildfactorys.update_db_check()
)
)
b.append(util.BuilderConfig(
name='update_repo_check',
workername=getWorkersLocal('local', worker_data['local'])[1],
workerbuilddir='builds',
collapseRequests=True,
factory=buildfactorys.update_repo_check()
)
)
# update cpv in db and call build_request_data
#FIXME: look so we don't run parallel with diffrent worker
# (builders.UpdateRepos step)
b.append(util.BuilderConfig(
name='update_cpv_data',
workernames=getWorkers('log', worker_data['docker'])[0],
workerbuilddir='builds',
collapseRequests=False,
factory=buildfactorys.update_db_cpv()
)
)
# Use multiplay workers
b.append(util.BuilderConfig(
name='update_v_data',
workername=getWorkers('log', worker_data['docker'])[0],
workerbuilddir='builds',
collapseRequests=False,
canStartBuild=CanWorkerUpdateV,
factory=buildfactorys.update_db_v()
)
)
# Use multiplay workers
b.append(util.BuilderConfig(
name='build_request_data',
workernames=getWorkersLocal('local', worker_data['local']),
collapseRequests=False,
factory=buildfactorys.build_request_check()
)
)
# Use multiplay workers
b.append(util.BuilderConfig(
name='run_build_request',
workernames=getWorkers('build', worker_data['docker']),
canStartBuild=CanWorkerBuildProject,
collapseRequests=False,
factory=buildfactorys.run_build_request()
)
)
# Use multiplay workers
b.append(util.BuilderConfig(
name='parse_build_log',
workernames=getWorkers('log', worker_data['docker'])[1:],
collapseRequests=False,
factory=buildfactorys.parse_build_log()
)
)
# For node workers
b.append(util.BuilderConfig(
name='run_build_images_request',
workernames=getWorkers('node', worker_data['node']),
#FIXME: support more the one node
#canStartBuild=CanWorkerBuildProject,
collapseRequests=False,
factory=buildfactorys.run_build_images_request()
)
)
# Use multiplay workers
b.append(util.BuilderConfig(
name='run_clean_db_request',
workernames=getWorkersLocal('local', worker_data['local']),
# look builder so we only do one time
# look=
# if we allready runnin with same package_data properties then skip/collapse
#collapseRequests=checkPackageData,
factory=buildfactorys.run_clean_db_request()
)
)
return b
|