blob: 1c17f660a03c3453727f130da8e5e1a51dc4fcff [file] [log] [blame]
maruelea586f32016-04-05 11:11:33 -07001# Copyright 2012 The LUCI Authors. All rights reserved.
maruelf1f5e2a2016-05-25 17:10:39 -07002# Use of this source code is governed under the Apache License, Version 2.0
3# that can be found in the LICENSE file.
maruel@chromium.orgfb155e92012-09-28 20:36:54 +00004
5"""Top-level presubmit script for swarm_client.
6
7See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
8details on the presubmit API built into gcl.
9"""
10
11def CommonChecks(input_api, output_api):
maruel@chromium.org8b056ba2012-10-16 14:04:49 +000012 import sys
13 def join(*args):
14 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args)
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000015
maruel@chromium.org8b056ba2012-10-16 14:04:49 +000016 output = []
17 sys_path_backup = sys.path
18 try:
19 sys.path = [
maruel@chromium.org86681e92013-07-25 13:34:09 +000020 input_api.PresubmitLocalPath(),
Marc-Antoine Ruel5906fcd2013-11-08 21:02:24 -050021 join('tests'),
Marc-Antoine Ruel3525b332013-11-12 13:51:20 -050022 join('third_party'),
maruel@chromium.org8b056ba2012-10-16 14:04:49 +000023 ] + sys.path
aludwin0bafa452016-11-24 05:49:09 -080024 black_list = list(input_api.DEFAULT_BLACK_LIST) + [
25 r'.*_pb2\.py$',
ryanmartens691153b2017-02-21 14:01:01 -080026 r'.*_pb2_grpc\.py$',
aludwin0bafa452016-11-24 05:49:09 -080027 ]
28 output.extend(input_api.canned_checks.RunPylint(
29 input_api, output_api,
30 black_list=black_list))
maruel@chromium.org8b056ba2012-10-16 14:04:49 +000031 finally:
32 sys.path = sys_path_backup
33
maruel@chromium.org11f54112013-09-16 23:16:42 +000034 # These tests are touching the live infrastructure. It's a pain if your IP
35 # is not whitelisted so do not run them for now. They should use a local fake
36 # web service instead.
37 blacklist = [
38 r'.*isolateserver_smoke_test\.py$',
dnje5eea0f2016-05-17 08:28:18 -070039 r'.*isolateserver_load_test\.py$',
maruel@chromium.org11f54112013-09-16 23:16:42 +000040 r'.*swarming_smoke_test\.py$',
41 ]
dnje5eea0f2016-05-17 08:28:18 -070042 unit_tests = input_api.canned_checks.GetUnitTestsRecursively(
43 input_api, output_api,
44 input_api.os_path.join(input_api.PresubmitLocalPath()),
45 whitelist=[r'.+_test\.py$'],
46 blacklist=blacklist)
47 output.extend(input_api.RunTests(unit_tests))
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000048 return output
49
50
Marc-Antoine Ruel2673daa2017-10-27 10:38:06 -070051# pylint: disable=unused-argument
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000052def CheckChangeOnUpload(input_api, output_api):
Marc-Antoine Ruel2673daa2017-10-27 10:38:06 -070053 return []
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000054
55
56def CheckChangeOnCommit(input_api, output_api):
maruelea586f32016-04-05 11:11:33 -070057 return CommonChecks(input_api, output_api)