|
| 1 | +# Copyright (c) 2017-2018 Red Hat, Inc. All rights reserved. This copyrighted |
| 2 | +# material is made available to anyone wishing to use, modify, copy, or |
| 3 | +# redistribute it subject to the terms and conditions of the GNU General |
| 4 | +# Public License v.2 or later. |
| 5 | +# |
| 6 | +# This program is distributed in the hope that it will be useful, but WITHOUT |
| 7 | +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 8 | +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 9 | +# details. |
| 10 | +# |
| 11 | +# You should have received a copy of the GNU General Public License |
| 12 | +# along with this program; if not, write to the Free Software Foundation, Inc., |
| 13 | +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 14 | + |
| 15 | + |
| 16 | +class DirectBuild(object): |
| 17 | + """Direct test build""" |
| 18 | + |
| 19 | + def __init__(self, baserepo=None, ref=None, baseconfig=None, |
| 20 | + message_id=None, subject=None, emails=set(), |
| 21 | + patch_url_list=[], makeopts=None): |
| 22 | + """ |
| 23 | + Initialize a direct test build. |
| 24 | +
|
| 25 | + Args: |
| 26 | + baserepo: Baseline Git repo URL. |
| 27 | + ref: Baseline Git reference to test. |
| 28 | + baseconfig: Kernel configuration URL. |
| 29 | + message_id: Value of the "Message-Id" header of the e-mail |
| 30 | + message representing the patchset, or None if |
| 31 | + unknown. |
| 32 | + subject: Subject of the message representing the patchset, |
| 33 | + or None if unknown. |
| 34 | + emails: Set of e-mail addresses involved with the patchset |
| 35 | + to send notifications to. |
| 36 | + patch_url_list: List of URLs pointing to patches to apply. |
| 37 | + makeopts: String of extra arguments to pass to the build's |
| 38 | + make invocation. |
| 39 | + """ |
| 40 | + |
| 41 | + |
| 42 | +class Direct(object): |
| 43 | + """Direct test build scheduler""" |
| 44 | + |
| 45 | + def __init__(self): |
| 46 | + """ |
| 47 | + Initialize a Jenkins interface. |
| 48 | + """ |
| 49 | + self. |
| 50 | + |
| 51 | + def get_base_commitdate(self, buildid): |
| 52 | + """ |
| 53 | + Get base commit's committer date of the specified completed build. |
| 54 | + Wait for the build to complete, if it hasn't yet. |
| 55 | +
|
| 56 | + Args: |
| 57 | + buildid: Jenkins build ID. |
| 58 | +
|
| 59 | + Return: |
| 60 | + The epoch timestamp string of the committer date. |
| 61 | + """ |
| 62 | + |
| 63 | + def get_base_hash(self, buildid): |
| 64 | + """ |
| 65 | + Get base commit's hash of the specified completed build. |
| 66 | + Wait for the build to complete, if it hasn't yet. |
| 67 | +
|
| 68 | + Args: |
| 69 | + buildid: Jenkins build ID. |
| 70 | +
|
| 71 | + Return: |
| 72 | + The base commit's hash string. |
| 73 | + """ |
| 74 | + |
| 75 | + def get_patch_url_list(self, buildid): |
| 76 | + """ |
| 77 | + Get the list of Patchwork patch URLs for the specified completed |
| 78 | + build. Wait for the build to complete, if it hasn't yet. |
| 79 | +
|
| 80 | + Args: |
| 81 | + buildid: Jenkins build ID. |
| 82 | +
|
| 83 | + Return: |
| 84 | + The list of Patchwork patch URLs. |
| 85 | + """ |
| 86 | + |
| 87 | + def get_result_url(self, buildid): |
| 88 | + """ |
| 89 | + Get the URL of the web representation of the specified build. |
| 90 | +
|
| 91 | + Args: |
| 92 | + buildid: Jenkins build ID. |
| 93 | +
|
| 94 | + Result: |
| 95 | + The URL of the build result. |
| 96 | + """ |
| 97 | + |
| 98 | + def get_result(self, buildid): |
| 99 | + """ |
| 100 | + Get result code (sktm.misc.tresult) for the specified build. |
| 101 | + Wait for the build to complete, if it hasn't yet. |
| 102 | +
|
| 103 | + Args: |
| 104 | + buildid: Jenkins build ID. |
| 105 | +
|
| 106 | + Result: |
| 107 | + The build result code (sktm.misc.tresult). |
| 108 | + """ |
| 109 | + |
| 110 | + def build(self, baserepo=None, ref=None, baseconfig=None, |
| 111 | + message_id=None, subject=None, emails=set(), patch_url_list=[], |
| 112 | + makeopts=None): |
| 113 | + """ |
| 114 | + Submit a build of a patchset. |
| 115 | +
|
| 116 | + Args: |
| 117 | + baserepo: Baseline Git repo URL. |
| 118 | + ref: Baseline Git reference to test. |
| 119 | + baseconfig: Kernel configuration URL. |
| 120 | + message_id: Value of the "Message-Id" header of the e-mail |
| 121 | + message representing the patchset, or None if |
| 122 | + unknown. |
| 123 | + subject: Subject of the message representing the patchset, |
| 124 | + or None if unknown. |
| 125 | + emails: Set of e-mail addresses involved with the patchset |
| 126 | + to send notifications to. |
| 127 | + patch_url_list: List of URLs pointing to patches to apply. |
| 128 | + makeopts: String of extra arguments to pass to the build's |
| 129 | + make invocation. |
| 130 | +
|
| 131 | + Returns: |
| 132 | + Submitted build number. |
| 133 | + """ |
| 134 | + job = DirectJob(baserepo=baserepo, ref=ref, |
| 135 | + baseconfig=baseconfig, |
| 136 | + message_id=message_id, subject=subject, emails=emails, |
| 137 | + patch_url_list=patch_url_list, |
| 138 | + makeopts=makeopts) |
| 139 | + pid = job.get_pid() |
| 140 | + self.job_map[pid] = job |
| 141 | + return pid |
| 142 | + |
| 143 | + def is_build_complete(self, buildid): |
| 144 | + """ |
| 145 | + Check if a project build is still running. |
| 146 | +
|
| 147 | + Args: |
| 148 | + buildid: Jenkins build ID to get the status of. |
| 149 | +
|
| 150 | + Return: |
| 151 | + True if the build is still running. |
| 152 | + """ |
0 commit comments