diff options
author | 2023-06-26 23:38:57 +0200 | |
---|---|---|
committer | 2023-06-26 23:38:57 +0200 | |
commit | 2639fe0cd81fc82c4f9717daf756013cea6a86ca (patch) | |
tree | 2f8580fffae06734f5674f1f01f57a0b6b377793 | |
parent | Add SetupBugReportSteps for bugreporting (diff) | |
download | tinderbox-cluster-2639fe0cd81fc82c4f9717daf756013cea6a86ca.tar.gz tinderbox-cluster-2639fe0cd81fc82c4f9717daf756013cea6a86ca.tar.bz2 tinderbox-cluster-2639fe0cd81fc82c4f9717daf756013cea6a86ca.zip |
Add bug id to builds data in db
Signed-off-by: Magnus Granberg <zorry@gentoo.org>
-rw-r--r-- | buildbot_gentoo_ci/db/builds.py | 56 | ||||
-rw-r--r-- | buildbot_gentoo_ci/db/model.py | 1 | ||||
-rw-r--r-- | buildbot_gentoo_ci/steps/logs.py | 7 | ||||
-rw-r--r-- | sql/gentoo_ci_schema.sql | 1 |
4 files changed, 61 insertions, 4 deletions
diff --git a/buildbot_gentoo_ci/db/builds.py b/buildbot_gentoo_ci/db/builds.py index 1cf2439..21adcc0 100644 --- a/buildbot_gentoo_ci/db/builds.py +++ b/buildbot_gentoo_ci/db/builds.py @@ -15,7 +15,7 @@ # Copyright Buildbot Team Members # Origins: buildbot.db.* # Modifyed by Gentoo Authors. -# Copyright 2021 Gentoo Authors +# Copyright 2023 Gentoo Authors import uuid import sqlalchemy as sa @@ -44,7 +44,9 @@ class BuildsConnectorComponent(base.DBConnectorComponent): requested=project_build_data['requested'], created_at=created_at, buildbot_build_id=0, - build_id=new_number)) + build_id=new_number, + bug_id=0 + )) except (sa.exc.IntegrityError, sa.exc.ProgrammingError): id = None new_number = None @@ -57,7 +59,6 @@ class BuildsConnectorComponent(base.DBConnectorComponent): def setStatusBuilds(self, id, status): updated_at = int(self.master.reactor.seconds()) def thd(conn, no_recurse=False): - tbl = self.db.model.projects_builds q = tbl.update() q = q.where(tbl.c.id == id) @@ -69,10 +70,57 @@ class BuildsConnectorComponent(base.DBConnectorComponent): def setBuildbotBuildIdBuilds(self, id, buildbot_build_id): updated_at = int(self.master.reactor.seconds()) def thd(conn, no_recurse=False): - tbl = self.db.model.projects_builds q = tbl.update() q = q.where(tbl.c.id == id) conn.execute(q, updated_at=updated_at, buildbot_build_id=buildbot_build_id) yield self.db.pool.do(thd) + + @defer.inlineCallbacks + def setBugIdBuilds(self, id, bug_id): + updated_at = int(self.master.reactor.seconds()) + def thd(conn, no_recurse=False): + tbl = self.db.model.projects_builds + q = tbl.update() + q = q.where(tbl.c.id == id) + conn.execute(q, updated_at=updated_at, bug_id=bug_id) + yield self.db.pool.do(thd) + + @defer.inlineCallbacks + def getBuildsByVersionUuid(self, uuid): + def thd(conn): + tbl = self.db.model.projects_builds + q = tbl.select() + q = q.where(tbl.c.version_uuid == uuid) + res = conn.execute(q) + row = res.fetchone() + return [self._row2dict(conn, row) + for row in conn.execute(q).fetchall()] + res = yield self.db.pool.do(thd) + return res + + @defer.inlineCallbacks + def removeBuild(self, id): + def thd(conn, no_recurse=False): + tbl = self.db.model.projects_builds + q = tbl.delete() + q = q.where(tbl.c.id == id) + conn.execute(q) + yield self.db.pool.do(thd) + + def _row2dict(self, conn, row): + return dict( + id=row.id, + build_id=row.build_id, + project_uuid=row.project_uuid, + version_uuid=row.version_uuid, + buildbot_build_id=row.buildbot_build_id, + bug_id=row.bug_id, + status=row.status, + requested=row.requested, + created_at=row.created_at, + updated_at=row.updated_at, + deleted=row.deleted, + deleted_at=row.deleted_at + ) diff --git a/buildbot_gentoo_ci/db/model.py b/buildbot_gentoo_ci/db/model.py index b80281e..3ae4f92 100644 --- a/buildbot_gentoo_ci/db/model.py +++ b/buildbot_gentoo_ci/db/model.py @@ -243,6 +243,7 @@ class Model(base.DBConnectorComponent): sa.ForeignKey('versions.uuid', ondelete='CASCADE'), nullable=False), sa.Column('buildbot_build_id', sa.Integer), + sa.Column('bug_id', sa.Integer, nullable=False, default=0), sa.Column('status', sa.Enum('failed','completed','in-progress','waiting', 'warning'), nullable=False), sa.Column('requested', sa.Boolean, default=False), sa.Column('created_at', sa.Integer, nullable=True), diff --git a/buildbot_gentoo_ci/steps/logs.py b/buildbot_gentoo_ci/steps/logs.py index ee11166..47112e0 100644 --- a/buildbot_gentoo_ci/steps/logs.py +++ b/buildbot_gentoo_ci/steps/logs.py @@ -529,6 +529,13 @@ class setBuildStatus(BuildStep): def run(self): self.gentooci = self.master.namedServices['services'].namedServices['gentooci'] project_build_data = self.getProperty('project_build_data') + bugid = 0 + if self.getProperty('bgo'): + bugid = self.getProperty('bgo')['id'] + yield self.gentooci.db.builds.setBugIdBuilds( + project_build_data['id'], + bugid + ) yield self.gentooci.db.builds.setStatusBuilds( project_build_data['id'], self.getProperty('status') diff --git a/sql/gentoo_ci_schema.sql b/sql/gentoo_ci_schema.sql index b166150..ee89db8 100644 --- a/sql/gentoo_ci_schema.sql +++ b/sql/gentoo_ci_schema.sql @@ -512,6 +512,7 @@ CREATE TABLE public.projects_builds ( version_uuid character varying(36), build_id integer NOT NULL, buildbot_build_id integer DEFAULT 0, + bug_id integer DEFAULT 0, status public.projects_builds_status, requested boolean, created_at integer, |