aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Granberg <zorry@gentoo.org>2024-03-03 08:53:29 +0100
committerMagnus Granberg <zorry@gentoo.org>2024-03-03 08:53:29 +0100
commitd8186f7796fbd57c68beafeb53978d3a2d20fc23 (patch)
tree001bcc8c71dabf187dfa8f2b8082ae902b0b5a87 /buildbot_gentoo_ci
parentMake emails dict for bugreports (diff)
downloadtinderbox-cluster-d8186f7796fbd57c68beafeb53978d3a2d20fc23.tar.gz
tinderbox-cluster-d8186f7796fbd57c68beafeb53978d3a2d20fc23.tar.bz2
tinderbox-cluster-d8186f7796fbd57c68beafeb53978d3a2d20fc23.zip
Add bugsettings to project
Signed-off-by: Magnus Granberg <zorry@gentoo.org>
Diffstat (limited to 'buildbot_gentoo_ci')
-rw-r--r--buildbot_gentoo_ci/db/model.py13
-rw-r--r--buildbot_gentoo_ci/db/projects.py41
-rw-r--r--buildbot_gentoo_ci/steps/logs.py8
3 files changed, 60 insertions, 2 deletions
diff --git a/buildbot_gentoo_ci/db/model.py b/buildbot_gentoo_ci/db/model.py
index dea3e15..448e67f 100644
--- a/buildbot_gentoo_ci/db/model.py
+++ b/buildbot_gentoo_ci/db/model.py
@@ -152,6 +152,18 @@ class Model(base.DBConnectorComponent):
nullable=False),
)
+ # projects bugs settings
+ projects_bugs = sautils.Table(
+ "projects_bugs", metadata,
+ sa.Column('id', sa.Integer, primary_key=True),
+ sa.Column('project_uuid', sa.String(36),
+ sa.ForeignKey('projects.uuid', ondelete='CASCADE'),
+ nullable=False),
+ sa.Column('enabled', sa.Boolean, default=False),
+ sa.Column('auto_assigne', sa.Boolean, default=False),
+ sa.Column('extra_summery', sa.String(255), nullable=False),
+ )
+
# What repository's use by projects
projects_repositorys = sautils.Table(
"projects_repositorys", metadata,
@@ -167,6 +179,7 @@ class Model(base.DBConnectorComponent):
sa.Column('build', sa.Boolean, default=False),
sa.Column('test', sa.Boolean, default=False),
sa.Column('test_mr', sa.Boolean, default=False),
+ sa.Column('bug', sa.Boolean, default=False),
)
# projects etc/portage settings
diff --git a/buildbot_gentoo_ci/db/projects.py b/buildbot_gentoo_ci/db/projects.py
index 7ffac97..23cabde 100644
--- a/buildbot_gentoo_ci/db/projects.py
+++ b/buildbot_gentoo_ci/db/projects.py
@@ -80,6 +80,21 @@ class ProjectsConnectorComponent(base.DBConnectorComponent):
return res
@defer.inlineCallbacks
+ def getRepositorySettingByProjUuidAndRepoUuid(self, project_uuid, repository_uuid):
+ def thd(conn):
+ tbl = self.db.model.projects_repositorys
+ q = tbl.select()
+ q = q.where(tbl.c.project_uuid == project_uuid)
+ q = q.where(tbl.c.repository_uuid == repository_uuid)
+ res = conn.execute(q)
+ row = res.fetchone()
+ if not row:
+ return None
+ return self._row2dict_projects_repositorys(conn, row)
+ res = yield self.db.pool.do(thd)
+ return res
+
+ @defer.inlineCallbacks
def getRepositorysByProjectUuid(self, uuid, auto=True):
def thd(conn):
tbl = self.db.model.projects_repositorys
@@ -212,6 +227,20 @@ class ProjectsConnectorComponent(base.DBConnectorComponent):
res = yield self.db.pool.do(thd)
return res
+ @defer.inlineCallbacks
+ def getBugsSettingsByProjectUuid(self, uuid):
+ def thd(conn):
+ tbl = self.db.model.projects_bugs
+ q = tbl.select()
+ q = q.where(tbl.c.project_uuid == uuid)
+ res = conn.execute(q)
+ row = res.fetchone()
+ if not row:
+ return None
+ return self._row2dict_projects_bugs(conn, row)
+ res = yield self.db.pool.do(thd)
+ return res
+
def _row2dict(self, conn, row):
return dict(
uuid=row.uuid,
@@ -243,7 +272,8 @@ class ProjectsConnectorComponent(base.DBConnectorComponent):
pkgcheck=pkgcheck,
build=row.build,
test=row.test,
- test_mr=row.test_mr
+ test_mr=row.test_mr,
+ bug=row.bug
)
def _row2dict_projects_workers(self, conn, row):
@@ -312,3 +342,12 @@ class ProjectsConnectorComponent(base.DBConnectorComponent):
status=row.status,
type=row.type
)
+
+ def _row2dict_projects_bugs(self, conn, row):
+ return dict(
+ id=row.id,
+ project_uuid=row.project_uuid,
+ enabled=row.enabled,
+ auto_assigne=row.auto_assigne,
+ extra_summery=row.extra_summery
+ )
diff --git a/buildbot_gentoo_ci/steps/logs.py b/buildbot_gentoo_ci/steps/logs.py
index 34aee29..84f5058 100644
--- a/buildbot_gentoo_ci/steps/logs.py
+++ b/buildbot_gentoo_ci/steps/logs.py
@@ -494,8 +494,14 @@ class SetupBugReportSteps(BuildStep):
def run(self):
self.gentooci = self.master.namedServices['services'].namedServices['gentooci']
bug_config = self.gentooci.config.project['bug_config']
+ bug_settings_data = yield self.gentooci.db.projects.getBugsSettingsByProjectUuid(self.getProperty("project_data")['uuid'])
+ project_repository_settings = yield self.gentooci.db.projects.getRepositorySettingByProjUuidAndRepoUuid(self.getProperty("project_data")['uuid'], self.getProperty('repository_data')['uuid'])
# add bug enable profile and repo
+ make_bugreport = False
if bug_config['enable'] and self.getProperty('status') == 'failed' and self.getProperty('error_dict')['title_found'] and not self.getProperty('bgo'):
+ if bug_settings_data['enable'] and project_repository_settings['bug']:
+ make_bugreport = True
+ if make_bugreport:
aftersteps_list = []
#Post
p = Properties()
@@ -506,7 +512,7 @@ class SetupBugReportSteps(BuildStep):
bug_args['user'] = bug_config['user']
bug_args['passwd'] = yield p.render(util.Secret("bugs_password"))
bug_params = {}
- title = separator.join([bug_config['extra_summery'], self.getProperty('error_dict')['cpv'], self.getProperty('error_dict')['title_nice']])
+ title = separator.join([bug_config['extra_summery'], bug_settings_data['extra_summery'], self.getProperty('error_dict')['cpv'], self.getProperty('error_dict')['title_nice']])
# bug title max 170
if len(title) >= 170:
title = title[:167] + '...'