Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub Action to find Python Syntax Errors #357

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/litmus-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,10 @@ jobs:
run: |
cd buildbot/osuosl/master
BUILDBOT_TEST=1 buildbot checkconfig
python_syntax_errors:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v3
with: # Ignore all ruff rules except Python Syntax Errors
args: "check --ignore=ALL"
6 changes: 3 additions & 3 deletions llvm-lnt/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def new_log():
get('/srv/lnt/install/lnt.log', 'lnt.log', )
new_lines = {line for line in open("lnt.log", 'r').readlines()}
for l in new_lines - lines:
print ' '.join(l.split()[2:]),
print(' '.join(l.split()[2:]), end=' ')


@task
Expand All @@ -92,7 +92,7 @@ def rotate_log():
sudo('rm -rf /srv/lnt/install/gunicorn.error.log')
out = sudo('ps auxxxf | grep "gunicorn: master"')
pid = re.search(r'lnt\s+(?P<pid>\d+)\s+', out).groupdict()['pid']
print pid
print(pid)
sudo('kill -USR1 ' + pid)


Expand All @@ -113,7 +113,7 @@ def kill_zombies():
pid = m.groupdict()['pid']
pids.append(pid)
else:
print ">", line
print(">", line)
for pid in pids:
sudo("kill -9 {}".format(pid))

Expand Down
6 changes: 3 additions & 3 deletions llvm-lnt/kill_zombies.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
pid = m.groupdict()['pid']
pids.append(pid)
else:
print ">", line
print(">", line)

if not pids:
print "No PIDs to kill."
print("No PIDs to kill.")

for pid in pids:
print subprocess.check_output(["kill", "-9", "{}".format(pid)])
print(subprocess.check_output(["kill", "-9", "{}".format(pid)]))
38 changes: 19 additions & 19 deletions llvmbisect/llvmlab/ci.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def find_binary(name):
# Execute the command.
try:
cmd_object.execute(verbose=verbose)
except OSError, e:
except OSError as e:
# Python's exceptions are horribly to read, and this one is
# incredibly common when people don't use the right syntax (or
# misspell something) when writing a predicate. Detect this and
Expand Down Expand Up @@ -277,9 +277,9 @@ def find_binary(name):
data = f.read()
f.close()
if data:
print ("-- command %s (note: suppressed by default, "
"see sandbox dir for log files) --" % (type))
print "--\n%s--\n" % data
print("-- command %s (note: suppressed by default, "
"see sandbox dir for log files) --" % (type))
print("--\n%s--\n" % data)

test_result = cmd_object.result
if not test_result:
Expand Down Expand Up @@ -393,8 +393,8 @@ def action_fetch(name, args):
fatal('current directory is not clean, %r exists' % p)
llvmlab.fetch_build_to_path(builder, build, root_path, builddir_path)

print 'downloaded root: %s' % root_path
print 'extracted path : %s' % builddir_path
print('downloaded root: %s' % root_path)
print('extracted path : %s' % builddir_path)

# Update the symbolic link, if requested.
if not opts.dry_run and opts.update_link:
Expand All @@ -408,7 +408,7 @@ def action_fetch(name, args):

# Create the symbolic link.
os.symlink(os.path.abspath(builddir_path), opts.update_link)
print 'updated link at: %s' % opts.update_link
print('updated link at: %s' % opts.update_link)
return os.path.abspath(builddir_path)


Expand All @@ -428,19 +428,19 @@ def action_ls(name, args):
available_buildnames = llvmlab.fetch_builders()
available_buildnames.sort()
for item in available_buildnames:
print item
print(item)
return available_buildnames

for name in args:
if len(args) > 1:
if name is not args[0]:
print
print '%s:' % name
print()
print('%s:' % name)
available_builds = list(llvmlab.fetch_builds(name))
available_builds.sort()
available_builds.reverse()
for build in available_builds:
print build.tobasename(include_suffix=False)
print(build.tobasename(include_suffix=False))
min_rev = min([x.revision for x in available_builds])
max_rev = max([x.revision for x in available_builds])
note("Summary: found {} builds: r{}-r{}".format(len(available_builds),
Expand Down Expand Up @@ -546,8 +546,8 @@ def predicate(item):
show_command_output=opts.show_command_output or opts.very_verbose)

# Print status.
print '%s: %s' % (('FAIL', 'PASS')[test_result],
item.tobasename(include_suffix=False))
print('%s: %s' % (('FAIL', 'PASS')[test_result],
item.tobasename(include_suffix=False)))

return test_result

Expand All @@ -571,13 +571,13 @@ def predicate(item):
if item is None:
fatal('unable to find any passing build!')

print '%s: first working build' % item.tobasename(include_suffix=False)
print('%s: first working build' % item.tobasename(include_suffix=False))
index = available_builds.index(item)
if index == 0:
print 'no failing builds!?'
print('no failing builds!?')
else:
print '%s: next failing build' % available_builds[index-1].tobasename(
include_suffix=False)
print('%s: next failing build' % available_builds[index-1].tobasename(
include_suffix=False))


def action_exec(name, args):
Expand Down Expand Up @@ -643,8 +643,8 @@ def action_exec(name, args):
opts.sandbox, opts.build_name, build, args, verbose=True,
show_command_output=True)

print '%s: %s' % (('FAIL', 'PASS')[test_result],
build.tobasename(include_suffix=False))
print('%s: %s' % (('FAIL', 'PASS')[test_result],
build.tobasename(include_suffix=False)))

raise SystemExit(test_result != True)

Expand Down
2 changes: 1 addition & 1 deletion llvmbisect/llvmlab/test_llvmlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class TestLLVMLabCI(unittest.TestCase):

def setUp(self):
self.workdir = tempfile.mkdtemp()
print self.workdir
print(self.workdir)
os.chdir(self.workdir)

def tearDown(self):
Expand Down
4 changes: 2 additions & 2 deletions llvmbisect/llvmlab/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def _write_message(kind, message):
file,line,_,_,_ = inspect.getframeinfo(f)
location = '%s:%d' % (os.path.basename(file), line)

print >>sys.stderr, '%s: %s: %s' % (location, kind, message)
print('%s: %s: %s' % (location, kind, message), file=sys.stderr)

note = lambda message: _write_message('note', message)
warning = lambda message: _write_message('warning', message)
Expand Down Expand Up @@ -205,7 +205,7 @@ def do_work():
# Otherwise, execute the task and push to the output queue.
try:
output = (None, fn(item))
except Exception, e:
except Exception as e:
output = ('error', sys.exc_info())

output_queue.put(output)
Expand Down
21 changes: 11 additions & 10 deletions llvmlab/llvmlab/ci/buildbot/statusclient.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import sys
import time
import traceback
import urllib2
Expand Down Expand Up @@ -26,7 +27,7 @@ class BuilderInfo(object):
def fromdata(data):
version = data['version']
if version != 0:
raise ValueError, "Unknown version"
raise ValueError("Unknown version")

return BuilderInfo(data['name'], data['last_build_number'],
set(data['active_builds']), data['last_poll'])
Expand Down Expand Up @@ -57,7 +58,7 @@ class StatusClient(object):
def fromdata(data):
version = data['version']
if version != 0:
raise ValueError, "Unknown version"
raise ValueError("Unknown version")

sc = StatusClient(data['master_url'], data['builders_poll_rate'],
data['builder_poll_rate'])
Expand Down Expand Up @@ -107,22 +108,22 @@ def get_json_result(self, query_items, arguments=None):
url = self.master_url + path
try:
request = urllib2.urlopen(url)
except urllib2.HTTPError, err:
except urllib2.HTTPError as err:
# Turn 404 into a result missing error.
if err.code == 404:
raise ResultMissing

# Log this failure.
os = StringIO.StringIO()
print >>os, "*** ERROR: failure in 'get_json_result(%r, %r)' ***" %(
query_items, arguments)
print >>os, "URL: %r" % url
print >>os, "\n-- Traceback --"
print("*** ERROR: failure in 'get_json_result(%r, %r)' ***" %(
query_items, arguments), file=os)
print("URL: %r" % url, file=os)
print("\n-- Traceback --", file=os)
traceback.print_exc(file = os)
if self.logger:
self.logger.warning(os.getvalue())
else:
print >>sys.stderr, os.getvalue()
print(os.getvalue(), file=sys.stderr)
raise UnknownFailure
data = request.read()
request.close()
Expand Down Expand Up @@ -290,10 +291,10 @@ def main():
try:
while 1:
for event in sc.pull_events():
print time.time(), event
print(time.time(), event)
time.sleep(.1)
except KeyboardInterrupt:
print "(interrupted, stopping)"
print("(interrupted, stopping)")

# Save the current instance.
file = open(path, "w")
Expand Down
8 changes: 4 additions & 4 deletions llvmlab/llvmlab/ci/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Phase(util.simple_repr_mixin):
def fromdata(data):
version = data['version']
if version != 0:
raise ValueError, "Unknown version"
raise ValueError("Unknown version")

return Phase(data['name'], data['number'],
data['phase_builder'], data['builder_names'],
Expand Down Expand Up @@ -45,7 +45,7 @@ class Builder(util.simple_repr_mixin):
def fromdata(data):
version = data['version']
if version != 0:
raise ValueError, "Unknown version"
raise ValueError("Unknown version")

return Builder(data['name'])

Expand All @@ -67,7 +67,7 @@ class PublishedBuild(util.simple_repr_mixin):
def fromdata(data):
version = data['version']
if version != 0:
raise ValueError, "Unknown version"
raise ValueError("Unknown version")

return PublishedBuild(data['product'], data['os'],
data['arch'], data['archive_name'])
Expand Down Expand Up @@ -99,7 +99,7 @@ class Config(util.simple_repr_mixin):
def fromdata(data):
version = data['version']
if version != 0:
raise ValueError, "Unknown version"
raise ValueError("Unknown version")

return Config([Phases.fromdata(item)
for item in data['phases']],
Expand Down
4 changes: 2 additions & 2 deletions llvmlab/llvmlab/ci/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class BuildStatus(util.simple_repr_mixin):
def fromdata(data):
version = data['version']
if version not in (0, 1):
raise ValueError, "Unknown version"
raise ValueError("Unknown version")

if version == 0:
slave = None
Expand Down Expand Up @@ -144,7 +144,7 @@ class Status(util.simple_repr_mixin):
def fromdata(data):
version = data['version']
if version != 0:
raise ValueError, "Unknown version"
raise ValueError("Unknown version")

sc = data.get('statusclient')
if sc:
Expand Down
4 changes: 2 additions & 2 deletions llvmlab/llvmlab/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Data(util.simple_repr_mixin):
def fromdata(data):
version = data['version']
if version != 0:
raise ValueError, "Unknown version"
raise ValueError("Unknown version")

users = [user.User.fromdata(u)
for u in data['users']]
Expand All @@ -33,7 +33,7 @@ def __init__(self, users, machines):

def set_admin_user(self, user):
if user.id in self.users:
raise ValueError, "database contains admin user %r" % user.id
raise ValueError("database contains admin user %r" % user.id)

self.admin_user = user
self.users[user.id] = user
2 changes: 1 addition & 1 deletion llvmlab/llvmlab/llvmlabtool/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def split_name_and_email(str):
if (str.count('<') != 1 or
str.count('>') != 1 or
not str.endswith('>')):
raise ValueError,"Don't know how to parse: %r" % (str,)
raise ValueError("Don't know how to parse: %r" % (str,))

lhs,rhs = str[:-1].split("<")
return lhs.strip(), rhs.strip()
Expand Down
2 changes: 1 addition & 1 deletion llvmlab/llvmlab/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Machine(util.simple_repr_mixin):
def fromdata(data):
version = data['version']
if version != 0:
raise ValueError, "Unknown version"
raise ValueError("Unknown version")

return Machine(data['id'], data['hostname'], data['admin'])

Expand Down
2 changes: 1 addition & 1 deletion llvmlab/llvmlab/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class User(util.simple_repr_mixin):
def fromdata(data):
version = data['version']
if version != 0:
raise ValueError, "Unknown version"
raise ValueError("Unknown version")

return User(data['id'], data['passhash'],
data['name'], data['email'],
Expand Down
16 changes: 8 additions & 8 deletions zorg/jenkins/jobs/delete_old_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
new_jobs.add(os.path.basename(g))

if len(new_jobs) == 0:
print "No new jobs?!?"
print("No new jobs?!?")
sys.exit(1)

query = subprocess.check_output(['util/query.sh', 'api/xml?tree=jobs[name,description]'], )
Expand All @@ -29,23 +29,23 @@
if '$$job generated from ' in description:
existing_jobs.add(name.strip())
if len(existing_jobs) == 0:
print "No existing jobs?!?"
print("No existing jobs?!?")
sys.exit(1)

# We should have already uploaded all the new jobs
missing = new_jobs - existing_jobs
if len(missing) > 0:
print "Missing jobs?!?"
print("Missing jobs?!?")
sys.exit(1)

to_delete = existing_jobs - new_jobs
if len(to_delete) > 0:
print ""
print ""
print "Will delete the following jobs:"
print("")
print("")
print("Will delete the following jobs:")
for jobname in to_delete:
print " %s" % jobname
print "You have 5 seconds to abort"
print(" %s" % jobname)
print("You have 5 seconds to abort")
time.sleep(5)
for jobname in to_delete:
subprocess.check_call(['util/delete_job.sh', jobname])
Loading