Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Presubmit script for changes affecting extensions docs server | 5 """Presubmit script for changes affecting extensions docs server |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 for more details about the presubmit API built into depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
| 9 """ | 9 """ |
| 10 | 10 |
| 11 # Run build_server so that files needed by tests are copied to the local | 11 # Run build_server so that files needed by tests are copied to the local |
| 12 # third_party directory. | 12 # third_party directory. |
| 13 import os | 13 import os |
| 14 import sys | 14 import sys |
| 15 | 15 |
| 16 WHITELIST = [ r'.+_test.py$' ] | 16 WHITELIST = [ r'.+_test.py$' ] |
| 17 # The integration tests are selectively run from the PRESUBMIT in | 17 # The integration tests are selectively run from the PRESUBMIT in |
| 18 # chrome/common/extensions. | 18 # chrome/common/extensions. Github filesystem support is currently |
| 19 BLACKLIST = [ r'integration_test.py$' ] | 19 # disabled. |
| 20 BLACKLIST = [ r'integration_test.py$', r'.*github.*_test.py$' ] | |
| 20 | 21 |
| 21 def _BuildServer(input_api): | 22 def _BuildServer(input_api): |
| 22 try: | 23 try: |
| 23 sys.path.insert(0, input_api.PresubmitLocalPath()) | 24 sys.path.insert(0, input_api.PresubmitLocalPath()) |
| 24 import build_server | 25 import build_server |
| 25 build_server.main() | 26 build_server.main() |
| 26 finally: | 27 finally: |
| 27 sys.path.pop(0) | 28 sys.path.pop(0) |
| 28 | 29 |
| 29 def _ImportAppYamlHelper(input_api): | |
| 30 try: | |
| 31 sys.path.insert(0, input_api.PresubmitLocalPath()) | |
| 32 from app_yaml_helper import AppYamlHelper | |
| 33 return AppYamlHelper | |
| 34 finally: | |
| 35 sys.path.pop(0) | |
| 36 | |
| 37 def _WarnIfAppYamlHasntChanged(input_api, output_api): | 30 def _WarnIfAppYamlHasntChanged(input_api, output_api): |
| 38 app_yaml_path = os.path.join(input_api.PresubmitLocalPath(), 'app.yaml') | 31 app_yaml_path = os.path.join(input_api.PresubmitLocalPath(), 'app.yaml') |
| 39 if app_yaml_path in input_api.AbsoluteLocalPaths(): | 32 if app_yaml_path in input_api.AbsoluteLocalPaths(): |
| 40 return [] | 33 return [] |
| 41 return [output_api.PresubmitPromptOrNotify(''' | 34 return [output_api.PresubmitPromptOrNotify(''' |
| 42 ************************************************** | 35 ************************************************** |
| 43 CHANGE DETECTED IN SERVER2 WITHOUT APP.YAML UPDATE | 36 CHANGE DETECTED IN SERVER2 WITHOUT APP.YAML UPDATE |
| 44 ************************************************** | 37 ************************************************** |
| 45 Maybe this is ok? Follow this simple guide: | 38 Maybe this is ok? Follow this simple guide: |
| 46 | 39 |
| 47 Q: Does this change any data that might get stored? | 40 Q: Does this change any data that might get stored? |
| 48 * Did you add/remove/update a field to a data source? | 41 * Did you add/remove/update a field to a data source? |
| 49 * Did you add/remove/update some data that gets sent to templates? | 42 * Did you add/remove/update some data that gets sent to templates? |
| 50 * Is this change to support a new feature in the templates? | 43 * Is this change to support a new feature in the templates? |
| 51 * Does this change include changes to templates? | 44 * Does this change include changes to templates? |
| 52 Yes? Bump the middle version and zero out the end version, i.e. 2-5-2 -> 2-6-0. | 45 Yes? Bump the middle version and zero out the end version, i.e. 2-5-2 -> 2-6-0. |
| 53 THIS WILL CAUSE THE CURRENTLY RUNNING SERVER TO STOP UPDATING. | 46 THIS WILL CAUSE THE CURRENTLY RUNNING SERVER TO STOP UPDATING. |
| 54 PUSH THE NEW VERSION ASAP. | 47 PUSH THE NEW VERSION ASAP. |
| 55 No? Continue. | 48 No? Continue. |
| 56 | |
| 57 Q: Is this a non-trivial change to the server? | 49 Q: Is this a non-trivial change to the server? |
| 58 Yes? Bump the end version. | 50 Yes? Bump the end version. |
| 59 Unlike above, the server will *not* stop updating. | 51 Unlike above, the server will *not* stop updating. |
| 60 No? Are you sure? How much do you bet? This can't be rolled back... | 52 No? Are you sure? How much do you bet? This can't be rolled back... |
| 61 | 53 |
| 62 Q: Is this a spelling correction? New test? Better comments? | 54 Q: Is this a spelling correction? New test? Better comments? |
| 63 Yes? Ok fine. Ignore this warning. | 55 Yes? Ok fine. Ignore this warning. |
| 64 No? I guess this presubmit check doesn't work. | 56 No? I guess this presubmit check doesn't work. |
| 65 ''')] | 57 ''')] |
| 66 | 58 |
| 67 def _CheckYamlConsistency(input_api, output_api): | |
| 68 app_yaml_path = os.path.join(input_api.PresubmitLocalPath(), 'app.yaml') | |
| 69 cron_yaml_path = os.path.join(input_api.PresubmitLocalPath(), 'cron.yaml') | |
|
Ken Rockot(use gerrit already)
2015/05/26 00:26:22
There is no more cron.yaml, so...
| |
| 70 if not (app_yaml_path in input_api.AbsoluteLocalPaths() or | |
| 71 cron_yaml_path in input_api.AbsoluteLocalPaths()): | |
| 72 return [] | |
| 73 | |
| 74 AppYamlHelper = _ImportAppYamlHelper(input_api) | |
| 75 app_yaml_version = AppYamlHelper.ExtractVersion( | |
| 76 input_api.ReadFile(app_yaml_path)) | |
| 77 cron_yaml_version = AppYamlHelper.ExtractVersion( | |
| 78 input_api.ReadFile(cron_yaml_path), key='target') | |
| 79 | |
| 80 if app_yaml_version == cron_yaml_version: | |
| 81 return [] | |
| 82 return [output_api.PresubmitError( | |
| 83 'Versions of app.yaml (%s) and cron.yaml (%s) must match' % ( | |
| 84 app_yaml_version, cron_yaml_version))] | |
| 85 | |
| 86 def _RunPresubmit(input_api, output_api): | 59 def _RunPresubmit(input_api, output_api): |
| 87 _BuildServer(input_api) | 60 _BuildServer(input_api) |
| 88 # For now, print any lint errors. When these have been eliminated, | 61 # For now, print any lint errors. When these have been eliminated, |
| 89 # move these into the warning list below. | 62 # move these into the warning list below. |
| 90 # See crbug.com/434363 and crbug.com/461130. | 63 # See crbug.com/434363 and crbug.com/461130. |
| 91 lint_errors = input_api.canned_checks.RunPylint(input_api, output_api) | 64 lint_errors = input_api.canned_checks.RunPylint(input_api, output_api) |
| 92 if lint_errors: | 65 if lint_errors: |
| 93 print(lint_errors) | 66 print(lint_errors) |
| 94 | 67 |
| 95 return ( | 68 return ( |
| 96 _WarnIfAppYamlHasntChanged(input_api, output_api) + | 69 _WarnIfAppYamlHasntChanged(input_api, output_api) + |
| 97 _CheckYamlConsistency(input_api, output_api) + | |
| 98 input_api.canned_checks.RunUnitTestsInDirectory( | 70 input_api.canned_checks.RunUnitTestsInDirectory( |
| 99 input_api, output_api, '.', whitelist=WHITELIST, blacklist=BLACKLIST) | 71 input_api, output_api, '.', whitelist=WHITELIST, blacklist=BLACKLIST) |
| 100 ) | 72 ) |
| 101 | 73 |
| 102 def CheckChangeOnUpload(input_api, output_api): | 74 def CheckChangeOnUpload(input_api, output_api): |
| 103 return _RunPresubmit(input_api, output_api) | 75 return _RunPresubmit(input_api, output_api) |
| 104 | 76 |
| 105 def CheckChangeOnCommit(input_api, output_api): | 77 def CheckChangeOnCommit(input_api, output_api): |
| 106 return _RunPresubmit(input_api, output_api) | 78 return _RunPresubmit(input_api, output_api) |
| OLD | NEW |