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
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>
-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
-rw-r--r--sql/gentoo_ci_schema.sql71
4 files changed, 130 insertions, 3 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] + '...'
diff --git a/sql/gentoo_ci_schema.sql b/sql/gentoo_ci_schema.sql
index 1a4284f..133b98a 100644
--- a/sql/gentoo_ci_schema.sql
+++ b/sql/gentoo_ci_schema.sql
@@ -504,6 +504,43 @@ CREATE TABLE public.projects (
ALTER TABLE public.projects OWNER TO buildbot;
--
+-- Name: projects_bugs; Type: TABLE; Schema: public; Owner: buildbot
+--
+
+CREATE TABLE public.projects_bugs (
+ id integer NOT NULL,
+ project_uuid character varying(36),
+ enabled boolean,
+ auto_assigne boolean,
+ extra_summery character varying(255)
+);
+
+
+ALTER TABLE public.projects_bugs OWNER TO buildbot;
+
+--
+-- Name: projects_bugs_id_seq; Type: SEQUENCE; Schema: public; Owner: buildbot
+--
+
+CREATE SEQUENCE public.projects_bugs_id_seq
+ AS integer
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+ALTER TABLE public.projects_bugs_id_seq OWNER TO buildbot;
+
+--
+-- Name: projects_builds_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: buildbot
+--
+
+ALTER SEQUENCE public.projects_bugs_id_seq OWNED BY public.projects_bugs.id;
+
+
+--
-- Name: projects_builds; Type: TABLE; Schema: public; Owner: buildbot
--
@@ -760,7 +797,8 @@ CREATE TABLE public.projects_repositorys (
pkgcheck public.projects_repositorys_pkgcheck,
build boolean,
test boolean,
- test_mr boolean
+ test_mr boolean,
+ bug boolean
);
@@ -1032,6 +1070,13 @@ ALTER TABLE ONLY public.portages_makeconf ALTER COLUMN id SET DEFAULT nextval('p
--
+-- Name: projects_bugs id; Type: DEFAULT; Schema: public; Owner: buildbot
+--
+
+ALTER TABLE ONLY public.projects_bugs ALTER COLUMN id SET DEFAULT nextval('public.projects_bugs_id_seq'::regclass);
+
+
+--
-- Name: projects_builds id; Type: DEFAULT; Schema: public; Owner: buildbot
--
@@ -1207,6 +1252,22 @@ ALTER TABLE ONLY public.portages_makeconf
--
+-- Name: projects_builds projects_bugs_pkey; Type: CONSTRAINT; Schema: public; Owner: buildbot
+--
+
+ALTER TABLE ONLY public.projects_bugs
+ ADD CONSTRAINT projects_bugs_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: projects_builds projects_bugs_unique; Type: CONSTRAINT; Schema: public; Owner: buildbot
+--
+
+ALTER TABLE ONLY public.projects_bugs
+ ADD CONSTRAINT projects_bugs_unique UNIQUE (id);
+
+
+--
-- Name: projects_builds projects_builds_pkey; Type: CONSTRAINT; Schema: public; Owner: buildbot
--
@@ -1559,6 +1620,14 @@ ALTER TABLE ONLY public.projects_portages_package
--
+-- Name: projects_bugs projects_fkey; Type: FK CONSTRAINT; Schema: public; Owner: buildbot
+--
+
+ALTER TABLE ONLY public.projects_bugs
+ ADD CONSTRAINT projects_fkey FOREIGN KEY (project_uuid) REFERENCES public.projects(uuid) NOT VALID;
+
+
+--
-- Name: projects_builds projects_fkey; Type: FK CONSTRAINT; Schema: public; Owner: buildbot
--