diff options
Diffstat (limited to 'scripts/patchtest-send-results')
-rwxr-xr-x | scripts/patchtest-send-results | 93 |
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 | |||
28 | import argparse | ||
29 | import boto3 | ||
30 | import configparser | ||
31 | import mailbox | ||
32 | import os | ||
33 | import sys | ||
34 | |||
35 | greeting = """Thank you for your submission. Patchtest identified one | ||
36 | or more issues with the patch. Please see the log below for | ||
37 | more information:\n\n---\n""" | ||
38 | |||
39 | suggestions = """\n---\n\nPlease address the issues identified and | ||
40 | submit a new revision of the patch, or alternatively, reply to this | ||
41 | email with an explanation of why the patch format should be accepted. | ||
42 | Note that patchtest may report failures in the merge-on-head test for | ||
43 | patches that are part of a series if they rely on changes from | ||
44 | preceeding entries. | ||
45 | |||
46 | If you believe these results are due to an error in patchtest, please | ||
47 | submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' | ||
48 | category under 'Yocto Project Subprojects'). Thank you!""" | ||
49 | |||
50 | parser = argparse.ArgumentParser(description="Send patchtest results to a submitter for a given patch") | ||
51 | parser.add_argument("-p", "--patch", dest="patch", required=True, help="The patch file to summarize") | ||
52 | args = parser.parse_args() | ||
53 | |||
54 | if not os.path.exists(args.patch): | ||
55 | print(f"Patch '{args.patch}' not found - did you provide the right path?") | ||
56 | sys.exit(1) | ||
57 | elif 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 | |||
61 | result_file = args.patch + ".testresult" | ||
62 | result_basename = os.path.basename(args.patch) | ||
63 | testresult = None | ||
64 | |||
65 | with open(result_file, "r") as f: | ||
66 | testresult = f.read() | ||
67 | |||
68 | reply_contents = greeting + testresult + suggestions | ||
69 | subject_line = f"Patchtest results for {result_basename}" | ||
70 | |||
71 | if "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 | ) | ||
92 | else: | ||
93 | print(f"No failures identified for {args.patch}.") | ||