| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 from recipe_engine.types import freeze | 5 from recipe_engine.types import freeze |
| 6 | 6 |
| 7 DEPS = [ | 7 DEPS = [ |
| 8 'chromium_tests', | 8 'chromium_checkout', |
| 9 'depot_tools/bot_update', | 9 'depot_tools/bot_update', |
| 10 'depot_tools/gclient', | 10 'depot_tools/gclient', |
| 11 'depot_tools/git', | 11 'depot_tools/git', |
| 12 'depot_tools/tryserver', |
| 12 'recipe_engine/path', | 13 'recipe_engine/path', |
| 13 'recipe_engine/properties', | 14 'recipe_engine/properties', |
| 14 'recipe_engine/python', | 15 'recipe_engine/python', |
| 15 'recipe_engine/raw_io', | 16 'recipe_engine/raw_io', |
| 16 'recipe_engine/shutil', | 17 'recipe_engine/shutil', |
| 17 'recipe_engine/step', | 18 'recipe_engine/step', |
| 18 ] | 19 ] |
| 19 | 20 |
| 20 MASTERS = freeze({ | 21 MASTERS = freeze({ |
| 21 'chromium.fyi': { | 22 'chromium.fyi': { |
| 22 'buildername': 'Chromium DevTools Linux', | 23 'buildername': 'Chromium DevTools Linux', |
| 23 'testname': 'devtools_fyi', | 24 'testname': 'devtools_fyi', |
| 24 }, | 25 }, |
| 25 }) | 26 }) |
| 26 | 27 |
| 28 AFFECTED_PATHS = ( |
| 29 'third_party/WebKit/Source/devtools', |
| 30 ) |
| 31 |
| 32 def should_skip_checks(api): |
| 33 if not api.tryserver.is_tryserver: |
| 34 return False |
| 35 return all( |
| 36 not filename.startswith(AFFECTED_PATHS) |
| 37 for filename in api.chromium_checkout.get_files_affected_by_patch()) |
| 38 |
| 27 def RunSteps(api): | 39 def RunSteps(api): |
| 28 api.gclient.set_config('chromium') | 40 api.gclient.set_config('chromium') |
| 29 api.bot_update.ensure_checkout(force=True) | 41 api.bot_update.ensure_checkout(force=True) |
| 30 | 42 |
| 31 has_devtools_file = False | 43 if should_skip_checks(api): |
| 32 files = api.chromium_tests.get_files_affected_by_patch() | |
| 33 for f in files: | |
| 34 if f.startswith('third_party/WebKit/Source/devtools'): | |
| 35 has_devtools_file = True | |
| 36 | |
| 37 if not has_devtools_file: | |
| 38 api.step('skip checks', ['echo', 'no devtools file in patch']) | 44 api.step('skip checks', ['echo', 'no devtools file in patch']) |
| 39 return | 45 return |
| 40 | 46 |
| 41 def get_devtools_path(*sub_paths): | 47 def get_devtools_path(*sub_paths): |
| 42 devtools_sub_path = ('third_party', 'WebKit', 'Source', 'devtools') | 48 devtools_sub_path = ('third_party', 'WebKit', 'Source', 'devtools') |
| 43 joined_path = devtools_sub_path + sub_paths | 49 joined_path = devtools_sub_path + sub_paths |
| 44 return api.path['checkout'].join(*joined_path) | 50 return api.path['checkout'].join(*joined_path) |
| 45 | 51 |
| 46 devtools_path = get_devtools_path() | 52 devtools_path = get_devtools_path() |
| 47 npm_path = get_devtools_path('scripts', 'buildbot', 'npm.py') | 53 node_path = get_devtools_path('scripts', 'buildbot', 'node.py') |
| 48 npm_modules_checkout_path = get_devtools_path('npm_modules') | 54 npm_modules_checkout_path = get_devtools_path('npm_modules') |
| 49 node_modules_src_path = get_devtools_path( | 55 eslint_path = get_devtools_path( |
| 50 'npm_modules', 'devtools', 'node_modules') | 56 'npm_modules', 'node_modules', '.bin', 'eslint') |
| 51 node_modules_dest_path = get_devtools_path('node_modules') | |
| 52 | 57 |
| 53 api.python('install node.js and npm', npm_path, ['--version']) | 58 api.python('install node.js and npm', node_path, ['--version']) |
| 54 | 59 |
| 55 # TODO(chenwilliam): instead of checkout here, add it as DEPS | 60 # TODO(chenwilliam): instead of checkout here, add it as DEPS |
| 56 api.git.checkout( | 61 api.git.checkout( |
| 57 url='https://chromium.googlesource.com/deps/third_party/npm_modules', | 62 url='https://chromium.googlesource.com/deps/third_party/npm_modules', |
| 58 # TODO(chenwilliam): pin this ref to a specific commit | 63 ref='8451e3a3fae09eaa18ddeed0c069a8e2f0e3541c', |
| 59 ref='master', | |
| 60 dir_path=npm_modules_checkout_path) | 64 dir_path=npm_modules_checkout_path) |
| 61 | 65 |
| 62 # Moving the node_modules folder within the npm_modules git checkout | 66 eslint_args = [ |
| 63 # because npm expects a certain directory layout | 67 eslint_path, '-c', 'front_end/.eslintrc.js', |
| 64 # this is a naive approach to ensure we're using the latest npm_modules | 68 '--ignore-path', 'front_end/.eslintignore', 'front_end' |
| 65 api.shutil.rmtree(node_modules_dest_path) | 69 ] |
| 66 api.shutil.copytree( | 70 api.python('run eslint', node_path, eslint_args, cwd=devtools_path) |
| 67 'copy npm modules', node_modules_src_path, node_modules_dest_path) | |
| 68 | 71 |
| 69 api.python('run eslint', npm_path, ['run', 'lint'], cwd=devtools_path) | 72 |
| 73 def tryserver_properties(api, mastername, config): |
| 74 return api.properties.generic( |
| 75 buildername=config['buildername'], |
| 76 mastername=mastername, |
| 77 rietveld='https://rietveld.example.com', |
| 78 issue=1, |
| 79 patchset=2, |
| 80 ) |
| 70 | 81 |
| 71 def GenTests(api): | 82 def GenTests(api): |
| 72 for mastername, config in MASTERS.iteritems(): | 83 for mastername, config in MASTERS.iteritems(): |
| 73 yield ( | 84 yield ( |
| 74 api.test(config['testname'] + '_no_devtools_file') + | 85 api.test(config['testname'] + '_main') + |
| 75 api.properties.generic( | 86 api.properties.generic( |
| 76 buildername=config['buildername'], | 87 buildername=config['buildername'], |
| 77 mastername=mastername, | 88 mastername=mastername, |
| 78 ) | 89 ) |
| 79 ) | 90 ) |
| 80 yield ( | 91 yield ( |
| 81 api.test(config['testname'] + '_with_devtools_file') + | 92 api.test(config['testname'] + '_tryserver_no_devtools') + |
| 82 api.properties.generic( | 93 tryserver_properties(api, mastername, config) |
| 83 buildername=config['buildername'], | 94 ) |
| 84 mastername=mastername, | 95 yield ( |
| 85 ) + | 96 api.test(config['testname'] + '_tryserver_with_devtools') + |
| 97 tryserver_properties(api, mastername, config) + |
| 86 api.override_step_data( | 98 api.override_step_data( |
| 87 'git diff to analyze patch', | 99 'git diff to analyze patch', |
| 88 api.raw_io.stream_output( | 100 api.raw_io.stream_output( |
| 89 'third_party/WebKit/Source/devtools/fake.js\n') | 101 'third_party/WebKit/Source/devtools/fake.js\n') |
| 90 ) | 102 ) |
| 91 ) | 103 ) |
| OLD | NEW |