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
|
# Copyright 2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
from buildbot.plugins import schedulers, util
@util.renderer
def builderUpdateDbNames(props):
builders = set()
for f in props.files:
if f.endswith('.ebuild'):
builders.add('update_db_check')
return list(builders)
@util.renderer
def getGitChanges(props):
k = props.changes[0]
change_data = {}
print(k)
change_data['cpvs'] = []
for v in k['files']:
if v.endswith('.ebuild'):
c = v.split('/')[0]
p = v.split('/')[1]
pv = v.split('/')[2][:-7]
cpv = c + '/' + pv
change_data['cp'] = c + '/' + p
change_data['cpvs'].append(cpv)
if k['repository'].endswith('.git'):
for v in k['repository'].split('/'):
if v.endswith('.git'):
# on gitlab we use gentoo-ci as fork of gentoo
if v[:-4] == 'gentoo-ci':
change_data['repository'] = 'gentoo'
else:
change_data['repository'] = v[:-4]
change_data['author'] = k['author']
change_data['committer'] = k['committer']
change_data['comments'] = k['comments']
change_data['revision'] = k['revision']
change_data['timestamp'] = k['when_timestamp']
change_data['branch'] = k['branch']
change_data['project'] = k['project']
return change_data
def bb_branch_fn(branch):
# check branch
print(f"Branch: {branch}")
if branch.endswith('-mr') or branch.endswith('-pr') or branch == 'master':
return True
return False
def bb_category_fn(category):
# check event
print(f"Category: {category}")
if category == 'push' or category == 'merge_request':
return True
return False
def gentoo_schedulers():
scheduler_update_db = schedulers.SingleBranchScheduler(
name='scheduler_update_db',
treeStableTimer=0,
properties = dict(
change_data = getGitChanges
),
builderNames = builderUpdateDbNames,
change_filter=util.ChangeFilter(branch_fn=bb_branch_fn, category_fn=bb_category_fn),
)
create_images = schedulers.ForceScheduler(
name="create_images",
buttonName="Create images",
label="My nice create images form",
builderNames=['run_build_images_request'],
# A completely customized property list. The name of the
# property is the name of the parameter
properties=[
util.StringParameter(name="project_uuid",
label="Project uuid",
default="e89c2c1a-46e0-4ded-81dd-c51afeb7fcfd", size=36),
])
update_cpv_data = schedulers.Triggerable(name="update_cpv_data",
builderNames=["update_cpv_data"])
update_repo_check = schedulers.Triggerable(name="update_repo_check",
builderNames=["update_repo_check"])
update_v_data = schedulers.Triggerable(name="update_v_data",
builderNames=["update_v_data"])
build_request_data = schedulers.Triggerable(name="build_request_data",
builderNames=["build_request_data"])
run_build_request = schedulers.Triggerable(name="run_build_request",
builderNames=["run_build_request"])
parse_build_log = schedulers.Triggerable(name="parse_build_log",
builderNames=["parse_build_log"])
run_build_images_request = schedulers.Triggerable(name="run_build_images_request",
builderNames=["run_build_images_request"])
run_clean_db_request = schedulers.Triggerable(name="run_clean_db_request",
builderNames=["run_clean_db_request"])
s = []
s.append(create_images)
s.append(scheduler_update_db)
s.append(update_repo_check)
s.append(update_cpv_data)
s.append(update_v_data)
s.append(build_request_data)
s.append(run_build_request)
s.append(parse_build_log)
s.append(run_clean_db_request)
return s
|