maruel | ea586f3 | 2016-04-05 11:11:33 -0700 | [diff] [blame] | 1 | # Copyright 2012 The LUCI Authors. All rights reserved. |
maruel | f1f5e2a | 2016-05-25 17:10:39 -0700 | [diff] [blame] | 2 | # 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.org | fb155e9 | 2012-09-28 20:36:54 +0000 | [diff] [blame] | 4 | |
| 5 | """Top-level presubmit script for swarm_client. |
| 6 | |
| 7 | See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for |
| 8 | details on the presubmit API built into gcl. |
| 9 | """ |
| 10 | |
Vadim Shtayura | b3b0bad | 2022-10-27 17:50:40 +0000 | [diff] [blame] | 11 | USE_PYTHON3 = True |
| 12 | |
| 13 | |
maruel@chromium.org | fb155e9 | 2012-09-28 20:36:54 +0000 | [diff] [blame] | 14 | def CommonChecks(input_api, output_api): |
maruel@chromium.org | 8b056ba | 2012-10-16 14:04:49 +0000 | [diff] [blame] | 15 | import sys |
Junji Watanabe | 38b28b0 | 2020-04-23 10:23:30 +0000 | [diff] [blame] | 16 | |
maruel@chromium.org | 8b056ba | 2012-10-16 14:04:49 +0000 | [diff] [blame] | 17 | def join(*args): |
| 18 | return input_api.os_path.join(input_api.PresubmitLocalPath(), *args) |
maruel@chromium.org | fb155e9 | 2012-09-28 20:36:54 +0000 | [diff] [blame] | 19 | |
maruel@chromium.org | 8b056ba | 2012-10-16 14:04:49 +0000 | [diff] [blame] | 20 | output = [] |
| 21 | sys_path_backup = sys.path |
| 22 | try: |
| 23 | sys.path = [ |
Junji Watanabe | 38b28b0 | 2020-04-23 10:23:30 +0000 | [diff] [blame] | 24 | input_api.PresubmitLocalPath(), |
| 25 | join('tests'), |
| 26 | join('third_party'), |
maruel@chromium.org | 8b056ba | 2012-10-16 14:04:49 +0000 | [diff] [blame] | 27 | ] + sys.path |
Junji Watanabe | 3ac618a | 2020-08-11 06:14:01 +0000 | [diff] [blame] | 28 | files_to_skip = list(input_api.DEFAULT_FILES_TO_SKIP) + [ |
aludwin | 0bafa45 | 2016-11-24 05:49:09 -0800 | [diff] [blame] | 29 | r'.*_pb2\.py$', |
| 30 | ] |
Junji Watanabe | 38b28b0 | 2020-04-23 10:23:30 +0000 | [diff] [blame] | 31 | output.extend( |
Junji Watanabe | ab2102a | 2022-01-12 01:44:04 +0000 | [diff] [blame] | 32 | input_api.canned_checks.RunPylint(input_api, |
| 33 | output_api, |
| 34 | files_to_skip=files_to_skip, |
Vadim Shtayura | b3b0bad | 2022-10-27 17:50:40 +0000 | [diff] [blame] | 35 | pylintrc=join('../', 'pylintrc'))) |
maruel@chromium.org | 8b056ba | 2012-10-16 14:04:49 +0000 | [diff] [blame] | 36 | finally: |
| 37 | sys.path = sys_path_backup |
| 38 | |
maruel@chromium.org | fb155e9 | 2012-09-28 20:36:54 +0000 | [diff] [blame] | 39 | return output |
| 40 | |
| 41 | |
Marc-Antoine Ruel | 2673daa | 2017-10-27 10:38:06 -0700 | [diff] [blame] | 42 | # pylint: disable=unused-argument |
maruel@chromium.org | fb155e9 | 2012-09-28 20:36:54 +0000 | [diff] [blame] | 43 | def CheckChangeOnUpload(input_api, output_api): |
Marc-Antoine Ruel | 2673daa | 2017-10-27 10:38:06 -0700 | [diff] [blame] | 44 | return [] |
maruel@chromium.org | fb155e9 | 2012-09-28 20:36:54 +0000 | [diff] [blame] | 45 | |
| 46 | |
| 47 | def CheckChangeOnCommit(input_api, output_api): |
maruel | ea586f3 | 2016-04-05 11:11:33 -0700 | [diff] [blame] | 48 | return CommonChecks(input_api, output_api) |