summaryrefslogtreecommitdiffstats
path: root/scripts/patchtest-send-results
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/patchtest-send-results')
-rwxr-xr-xscripts/patchtest-send-results93
1 files changed, 93 insertions, 0 deletions
diff --git a/scripts/patchtest-send-results b/scripts/patchtest-send-results
new file mode 100755
index 0000000000..2a2c57a10e
--- /dev/null
+++ b/scripts/patchtest-send-results
@@ -0,0 +1,93 @@
1#!/usr/bin/env python3
2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4#
5# patchtest: execute all unittest test cases discovered for a single patch
6# Note that this script is currently under development and has been
7# hard-coded with default values for testing purposes. This script
8# should not be used without changing the default recipient, at minimum.
9#
10# Copyright (C) 2023 BayLibre Inc.
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License version 2 as
14# published by the Free Software Foundation.
15#
16# This program is distributed in the hope that it will be useful,
17# but WITHOUT ANY WARRANTY; without even the implied warranty of
18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19# GNU General Public License for more details.
20#
21# You should have received a copy of the GNU General Public License along
22# with this program; if not, write to the Free Software Foundation, Inc.,
23# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24#
25# Author: Trevor Gamblin <tgamblin@baylibre.com>
26#
27
28import argparse
29import boto3
30import configparser
31import mailbox
32import os
33import sys
34
35greeting = """Thank you for your submission. Patchtest identified one
36or more issues with the patch. Please see the log below for
37more information:\n\n---\n"""
38
39suggestions = """\n---\n\nPlease address the issues identified and
40submit a new revision of the patch, or alternatively, reply to this
41email with an explanation of why the patch format should be accepted.
42Note that patchtest may report failures in the merge-on-head test for
43patches that are part of a series if they rely on changes from
44preceeding entries.
45
46If you believe these results are due to an error in patchtest, please
47submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest'
48category under 'Yocto Project Subprojects'). Thank you!"""
49
50parser = argparse.ArgumentParser(description="Send patchtest results to a submitter for a given patch")
51parser.add_argument("-p", "--patch", dest="patch", required=True, help="The patch file to summarize")
52args = parser.parse_args()
53
54if not os.path.exists(args.patch):
55 print(f"Patch '{args.patch}' not found - did you provide the right path?")
56 sys.exit(1)
57elif not os.path.exists(args.patch + ".testresult"):
58 print(f"Found patch '{args.patch}' but '{args.patch}.testresult' was not present. Have you run patchtest on the patch?")
59 sys.exit(1)
60
61result_file = args.patch + ".testresult"
62result_basename = os.path.basename(args.patch)
63testresult = None
64
65with open(result_file, "r") as f:
66 testresult = f.read()
67
68reply_contents = greeting + testresult + suggestions
69subject_line = f"Patchtest results for {result_basename}"
70
71if "FAIL" in testresult:
72 ses_client = boto3.client('ses', region_name='us-west-2')
73 response = ses_client.send_email(
74 Source='patchtest@automation.yoctoproject.org',
75 Destination={
76 'ToAddresses': ['test-list@lists.yoctoproject.org'],
77 },
78 ReplyToAddresses=['test-list@lists.yoctoproject.org'],
79 Message={
80 'Subject': {
81 'Data': subject_line,
82 'Charset': 'utf-8'
83 },
84 'Body': {
85 'Text': {
86 'Data': reply_contents,
87 'Charset': 'utf-8'
88 }
89 }
90 }
91 )
92else:
93 print(f"No failures identified for {args.patch}.")