blob: 20a35950a82355d7ee01521bdc73a75e06976ba6 [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
Junji Watanabe38b28b02020-04-23 10:23:30 +000013
maruel@chromium.org8b056ba2012-10-16 14:04:49 +000014 def join(*args):
15 return input_api.os_path.join(input_api.PresubmitLocalPath(), *args)
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000016
maruel@chromium.org8b056ba2012-10-16 14:04:49 +000017 output = []
18 sys_path_backup = sys.path
19 try:
20 sys.path = [
Junji Watanabe38b28b02020-04-23 10:23:30 +000021 input_api.PresubmitLocalPath(),
22 join('tests'),
23 join('third_party'),
maruel@chromium.org8b056ba2012-10-16 14:04:49 +000024 ] + sys.path
aludwin0bafa452016-11-24 05:49:09 -080025 black_list = list(input_api.DEFAULT_BLACK_LIST) + [
26 r'.*_pb2\.py$',
ryanmartens691153b2017-02-21 14:01:01 -080027 r'.*_pb2_grpc\.py$',
aludwin0bafa452016-11-24 05:49:09 -080028 ]
Junji Watanabe38b28b02020-04-23 10:23:30 +000029 output.extend(
30 input_api.canned_checks.RunPylint(
31 input_api, output_api, black_list=black_list))
maruel@chromium.org8b056ba2012-10-16 14:04:49 +000032 finally:
33 sys.path = sys_path_backup
34
maruel@chromium.org11f54112013-09-16 23:16:42 +000035 # These tests are touching the live infrastructure. It's a pain if your IP
36 # is not whitelisted so do not run them for now. They should use a local fake
37 # web service instead.
38 blacklist = [
Junji Watanabe38b28b02020-04-23 10:23:30 +000039 r'.*isolateserver_smoke_test\.py$',
40 r'.*isolateserver_load_test\.py$',
maruel@chromium.org11f54112013-09-16 23:16:42 +000041 ]
dnje5eea0f2016-05-17 08:28:18 -070042 unit_tests = input_api.canned_checks.GetUnitTestsRecursively(
Junji Watanabe38b28b02020-04-23 10:23:30 +000043 input_api,
44 output_api,
dnje5eea0f2016-05-17 08:28:18 -070045 input_api.os_path.join(input_api.PresubmitLocalPath()),
46 whitelist=[r'.+_test\.py$'],
47 blacklist=blacklist)
48 output.extend(input_api.RunTests(unit_tests))
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000049 return output
50
51
Marc-Antoine Ruel2673daa2017-10-27 10:38:06 -070052# pylint: disable=unused-argument
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000053def CheckChangeOnUpload(input_api, output_api):
Marc-Antoine Ruel2673daa2017-10-27 10:38:06 -070054 return []
maruel@chromium.orgfb155e92012-09-28 20:36:54 +000055
56
57def CheckChangeOnCommit(input_api, output_api):
maruelea586f32016-04-05 11:11:33 -070058 return CommonChecks(input_api, output_api)