---
hooks/post-koji-build/watch-koji-builds.py | 51 +++++++++++++++------------
1 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/hooks/post-koji-build/watch-koji-builds.py
b/hooks/post-koji-build/watch-koji-builds.py
index ae12471..62aa0e6 100755
--- a/hooks/post-koji-build/watch-koji-builds.py
+++ b/hooks/post-koji-build/watch-koji-builds.py
@@ -18,6 +18,7 @@ import xmlrpclib
import subprocess
import optparse
from autoqa import koji_utils
+from autoqa.repoinfo import repoinfo
# Directory where we cache info between runs
cachedir = '/var/cache/autoqa/watch-koji-builds'
@@ -31,21 +32,14 @@ except OSError, e:
# alternately: read from e.g. /etc/autoqa/autoqa.conf
kojiserver = 'http://koji.fedoraproject.org/kojihub'
-# Set of tags to look for
-taglist = set(('dist-f10-updates-candidate',
- 'dist-f11-updates-candidate',
- 'dist-f12-updates-candidate',
- 'dist-f13-updates-candidate',
- 'dist-f14-updates-candidate',
-))
-archlist = ('i686', 'x86_64', 'noarch')
-
-
def get_prevtime():
- try:
+ '''Returns the prevtime to use when looking for new builds. Value will
be
+ either 1) the mtime of the cachefile, or 2) if no cachefile is found, current
+ time - 3 hours.'''
+ try:
return os.stat(cachefile)[8] # mtime
except:
- return 0
+ return time.time() - 10800
def load_untagged():
'''Load the list of untagged builds seen by previous runs'''
@@ -64,6 +58,7 @@ def save_list(pkglist):
out.close()
def new_builds_since(session, taglist, prevtime):
+
untagged_builds = []
tagged_builds = {}
for tag in taglist:
@@ -79,8 +74,9 @@ def new_builds_since(session, taglist, prevtime):
elif not session.build_failed(nvr):
# No tag yet but the build is still OK - check again later
untagged_builds.append(nvr)
- #print "untagged: %s" % " ".join(untagged_builds)
- #print "tagged: %s" % " ".join(tagged_builds)
+ if opts.verbose:
+ print "untagged: %s" % " ".join(untagged_builds)
+ print "tagged: %s" % " ".join(tagged_builds)
return (tagged_builds, untagged_builds)
if __name__ == '__main__':
@@ -90,17 +86,22 @@ if __name__ == '__main__':
tags for new builds and kick off tests when new builds/packages are found.')
parser.add_option('--dryrun', '--dry-run',
action='store_true',
help='Do not actually execute commands, just show what would be done')
+ parser.add_option('-p', '--prevtime', action='store',
+ type='float', default=get_prevtime(),
+ help='How far back to look for new builds (seconds since last epoch)')
parser.add_option('--verbose', action='store_true',
help='Print extra information')
(opts, args) = parser.parse_args()
- # load prevtime from some saved timestamp
- prevtime = get_prevtime()
- if not prevtime:
- print "No previous run - checking builds in the past 3 hours"
- prevtime = time.time() - 10800
+ # Using repoinfo, establish the set of tags to look for
+ taglist = set()
+ for repo in repoinfo.repos():
+ taglist.add(repoinfo.get(repo, 'tag'))
+
if opts.verbose:
- print "Looking up builds since %s" % time.ctime(prevtime)
+ print "Looking up builds since %s (%s)" % (opts.prevtime,
time.ctime(opts.prevtime))
+ print "Looking for builds with tags %s" % " ".join(taglist)
+
# Set up the koji connection
kojiopts = {} # Possible items: user, password, debug_xmlrpc, debug..
session = koji_utils.SimpleKojiClientSession(kojiserver, kojiopts)
@@ -109,7 +110,7 @@ tags for new builds and kick off tests when new builds/packages are
found.')
try:
session.ensure_connection()
(tagged_builds, untagged_builds) = new_builds_since(session,
- taglist, prevtime)
+ taglist, opts.prevtime)
if not opts.dryrun:
save_list(untagged_builds)
for tag, builds in tagged_builds.items():
@@ -119,12 +120,16 @@ tags for new builds and kick off tests when new builds/packages are
found.')
harnesscall = ['autoqa', 'post-koji-build',
'--name', b['name'],
'--kojitag', tag]
+
# Invoke autoqa with an --arch arg for each arch we care about
- testarches = set(arches).intersection(archlist)
+ repoarches = set(repoinfo.getrepo_by_tag(tag).get("arches"))
+ testarches = set(repoarches).intersection(arches)
+
# NOTE HACK: autoqa doesn't handle 'noarch', use
'x86_64'
- if 'noarch' in testarches:
+ if 'noarch' in arches:
testarches.discard('noarch')
testarches.add('x86_64')
+
for arch in testarches:
harnesscall += ['--arch', arch]
if b['epoch']:
--
1.7.0.1