Enable Enterprise enrollment on desktop builds.
[chromium-blink-merge.git] / chrome / common / extensions / docs / server2 / PRESUBMIT.py
blob7ac6d9aea5ff30b50d406f82ed800719eb9049ab
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
3 # found in the LICENSE file.
5 """Presubmit script for changes affecting extensions docs server
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl.
9 """
11 # Run build_server so that files needed by tests are copied to the local
12 # third_party directory.
13 import os
14 import sys
16 WHITELIST = [ r'.+_test.py$' ]
17 # The integration tests are selectively run from the PRESUBMIT in
18 # chrome/common/extensions.
19 BLACKLIST = [ r'integration_test.py$' ]
21 def _BuildServer(input_api):
22 try:
23 sys.path.insert(0, input_api.PresubmitLocalPath())
24 import build_server
25 build_server.main()
26 finally:
27 sys.path.pop(0)
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)
37 def _WarnIfAppYamlHasntChanged(input_api, output_api):
38 app_yaml_path = os.path.join(input_api.PresubmitLocalPath(), 'app.yaml')
39 if app_yaml_path in input_api.AbsoluteLocalPaths():
40 return []
41 return [output_api.PresubmitPromptOrNotify('''
42 **************************************************
43 CHANGE DETECTED IN SERVER2 WITHOUT APP.YAML UPDATE
44 **************************************************
45 Maybe this is ok? Follow this simple guide:
47 Q: Does this change any data that might get stored?
48 * Did you add/remove/update a field to a data source?
49 * Did you add/remove/update some data that gets sent to templates?
50 * Is this change to support a new feature in the templates?
51 * 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.
53 THIS WILL CAUSE THE CURRENTLY RUNNING SERVER TO STOP UPDATING.
54 PUSH THE NEW VERSION ASAP.
55 No? Continue.
57 Q: Is this a non-trivial change to the server?
58 Yes? Bump the end version.
59 Unlike above, the server will *not* stop updating.
60 No? Are you sure? How much do you bet? This can't be rolled back...
62 Q: Is this a spelling correction? New test? Better comments?
63 Yes? Ok fine. Ignore this warning.
64 No? I guess this presubmit check doesn't work.
65 ''')]
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')
70 if not (app_yaml_path in input_api.AbsoluteLocalPaths() or
71 cron_yaml_path in input_api.AbsoluteLocalPaths()):
72 return []
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')
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))]
86 def _RunPresubmit(input_api, output_api):
87 _BuildServer(input_api)
88 return (
89 _WarnIfAppYamlHasntChanged(input_api, output_api) +
90 _CheckYamlConsistency(input_api, output_api) +
91 input_api.canned_checks.RunUnitTestsInDirectory(
92 input_api, output_api, '.', whitelist=WHITELIST, blacklist=BLACKLIST)
95 def CheckChangeOnUpload(input_api, output_api):
96 return _RunPresubmit(input_api, output_api)
98 def CheckChangeOnCommit(input_api, output_api):
99 return _RunPresubmit(input_api, output_api)