Debian Codegraph @

pypy/tool/release/force-builds.py

raw symbols SCIP
1 #!/usr/bin/python
2
3 """
4 Force the PyPy buildmaster to run a builds on all builders that produce
5 nightly builds for a particular branch.
6
7 Taken from http://twistedmatrix.com/trac/browser/sandbox/exarkun/force-builds.py
8
9 modified by PyPy team
10 """
11 from __future__ import absolute_import, division, print_function
12
13 import os, sys, subprocess
14 try:
15 from urllib2 import quote
16 except ImportError:
17 from urllib.request import quote
18
19 from twisted.internet import reactor, defer
20 from twisted.python import log
21 from twisted.web import client
22 from twisted.web.error import PageRedirect
23
24 OWN_BUILDERS = [
25 'own-linux-x86-32',
26 'own-linux-x86-64',
27 # 'own-linux-armhf',
28 # 'own-win-x86-32',
29 'own-win-x86-64',
30 'own-linux-s390x',
31 # 'own-macosx-x86-32',
32 'own-linux-aarch64',
33 ]
34 JIT_BUILDERS = [
35 'pypy-c-jit-linux-x86-32',
36 'pypy-c-jit-linux-x86-64',
37 # 'pypy-c-jit-freebsd-9-x86-64',
38 'pypy-c-jit-macos-x86-64',
39 'pypy-c-jit-macos-arm64',
40 # 'pypy-c-jit-win-x86-32',
41 'pypy-c-jit-win-x86-64',
42 'pypy-c-jit-linux-s390x',
43 # 'build-pypy-c-jit-linux-armhf-raspbian',
44 # 'build-pypy-c-jit-linux-armel',
45 'pypy-c-jit-linux-aarch64',
46 ]
47 RPYTHON_BUILDERS = [
48 'rpython-linux-x86-32',
49 'rpython-linux-x86-64',
50 # 'rpython-win-x86-32'
51 'rpython-win-x86-64'
52 ]
53
54 def get_user():
55 if sys.platform == 'win32':
56 return os.environ['USERNAME']
57 else:
58 import pwd
59 return pwd.getpwuid(os.getuid())[0]
60
61 def main(options):
62 #XXX: handle release tags
63 #XXX: handle validity checks
64 lock = defer.DeferredLock()
65 requests = []
66 def ebList(err):
67 if err.check(PageRedirect) is not None:
68 return None
69 log.err(err, "Build force failure")
70
71 if options.minimal:
72 builders = JIT_BUILDERS
73 elif options.branch.startswith('release'):
74 builders = OWN_BUILDERS + JIT_BUILDERS
75 else:
76 builders = RPYTHON_BUILDERS + OWN_BUILDERS + JIT_BUILDERS
77
78 for builder in builders:
79 print('Forcing', builder, '...')
80 url = "http://" + options.server + "/builders/" + builder + "/force"
81 args = [
82 ('username', options.user),
83 ('revision', ''),
84 ('forcescheduler', 'Force Build'),
85 ('branch', options.branch),
86 ('reason', options.reason)]
87 url = url + '?' + '&'.join([k + '=' + quote(v) for (k, v) in args])
88 requests.append(
89 lock.run(client.getPage, url.encode('utf-8'), followRedirect=False).addErrback(ebList))
90
91 d = defer.gatherResults(requests)
92 d.addErrback(log.err)
93 d.addCallback(lambda ign: reactor.stop())
94 reactor.run()
95 print('See http://buildbot.pypy.org/summary after a while')
96
97 if __name__ == '__main__':
98 log.startLogging(sys.stdout)
99 import optparse
100 parser = optparse.OptionParser()
101 parser.add_option("-b", "--branch", help="branch to build", default='')
102 parser.add_option("-s", "--server", help="buildbot server", default="buildbot.pypy.org")
103 parser.add_option("-u", "--user", help="user name to report", default=get_user())
104 parser.add_option("-m", "--minimal", action="store_true", default=False,
105 help="minimal: trigger pypy-c-jit only")
106 parser.add_option("-r", "--reason", help="reason for force",
107 default='Forced by command line script')
108 (options, args) = parser.parse_args()
109 if not options.branch:
110 parser.error("branch option required")
111 try:
112 subprocess.check_call(['hg','id','-r', options.branch])
113 except subprocess.CalledProcessError:
114 print('branch', options.branch, 'could not be found in local repository')
115 sys.exit(-1)
116 if options.branch.startswith('release') and not '-v' in options.branch:
117 print('release branches must be of the form "release.*-v.*')
118 sys.exit(-1)
119 main(options)