Chromium Code Reviews| 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 """A continious builder for build repo which simulates recipes.""" | 4 """A continious builder for build repo which simulates recipes.""" |
|
tandrii(chromium)
2016/06/14 12:22:51
update doc
martiniss
2016/06/14 23:11:33
Done.
| |
| 5 | 5 |
| 6 from recipe_engine.recipe_api import Property | |
| 7 | |
| 6 DEPS = [ | 8 DEPS = [ |
| 7 'depot_tools/bot_update', | 9 'depot_tools/bot_update', |
| 8 'depot_tools/gclient', | 10 'depot_tools/gclient', |
| 9 'recipe_engine/path', | 11 'recipe_engine/path', |
| 10 'recipe_engine/properties', | 12 'recipe_engine/properties', |
| 11 'recipe_engine/python', | 13 'recipe_engine/python', |
| 14 'recipe_engine/step', | |
| 15 'luci_config', | |
| 12 ] | 16 ] |
| 13 | 17 |
| 18 PROPERTIES = { | |
| 19 'project_under_test': Property( | |
| 20 default='build', kind=str, help='luci-config project to run tests for') | |
| 21 } | |
| 14 | 22 |
| 15 def RunSteps(api): | |
| 16 api.gclient.set_config('build') | |
| 17 api.bot_update.ensure_checkout(force=True) | |
| 18 recipes_py = api.path['checkout'].join('scripts', 'slave', 'recipes.py') | |
| 19 api.python('recipe fetch deps', recipes_py, ['fetch']) | |
| 20 # In theory, this should work too. But in practice, this fails to import | |
| 21 # coverage module (http://crbug.com/577049). | |
| 22 # api.python('recipe simulation test', recipes_py, ['simulation_test']) | |
| 23 recipe_simulation_test = api.path['checkout'].join( | |
| 24 'scripts', 'slave', 'unittests', 'recipe_simulation_test.py') | |
| 25 api.python('recipe simulation test', recipe_simulation_test, ['test']) | |
| 26 | 23 |
| 24 def RunSteps(api, project_under_test): | |
| 25 root_dir = api.path['slave_build'] | |
| 26 cache_dir = root_dir.join('_cache_dir') | |
| 27 | |
| 28 # Needed to set up the infra checkout for infra python, which has coverage. | |
|
tandrii(chromium)
2016/06/14 12:22:51
bleh, isn't that slow every time running runhooks
martiniss
2016/06/14 23:11:33
Done in https://codereview.chromium.org/2061263003
| |
| 29 c = api.gclient.make_config('infra', CACHE_DIR=cache_dir) | |
| 30 c.solutions[0].revision = 'origin/master' | |
|
tandrii(chromium)
2016/06/14 12:22:51
and why not a fixed revision? I don't see a need t
| |
| 31 api.bot_update.ensure_checkout( | |
| 32 force=True, gclient_config=c, cwd=root_dir.join('custom_infra')) | |
| 33 | |
| 34 cache_dir = root_dir.join('_cache_dir') | |
|
tandrii(chromium)
2016/06/14 12:22:51
remove line, it's a dup
martiniss
2016/06/14 23:11:34
Done.
| |
| 35 | |
| 36 c = api.gclient.make_config(CACHE_DIR=cache_dir) | |
| 37 soln = c.solutions.add() | |
| 38 soln.name = project_under_test | |
| 39 soln.url = api.luci_config.get_project_metadata( | |
| 40 project_under_test)['repo_url'] | |
| 41 | |
| 42 api.bot_update.ensure_checkout( | |
| 43 force=True, gclient_config=c, | |
| 44 cwd=root_dir) | |
| 45 | |
| 46 # TODO(martiniss): allow recipes.cfg patches to take affect | |
| 47 # This requires getting the refs.cfg from luci_config, reading the local | |
| 48 # patched version, etc. | |
| 49 result = api.luci_config.get_project_config(project_under_test, 'recipes.cfg') | |
| 50 recipes_cfg = api.luci_config.parse_protobuf(result['content'].split('\n')) | |
| 51 path = recipes_cfg['recipes_path'][0].split('/') | |
| 52 | |
| 53 api.step( | |
| 54 'recipe simulation test', [ | |
| 55 root_dir.join('custom_infra', 'ENV', 'bin', 'python'), | |
| 56 root_dir.join(*([project_under_test] + path + ['recipes.py'])), | |
| 57 'simulation_test' | |
| 58 ]) | |
| 27 | 59 |
| 28 def GenTests(api): | 60 def GenTests(api): |
| 29 yield ( | 61 yield ( |
| 30 api.test('normal') + | 62 api.test('normal') + |
| 31 api.properties.generic( | 63 api.properties.generic( |
| 32 mastername='chromium.tools.build', | 64 mastername='chromium.tools.build', |
| 33 buildername='recipe simulation tester', | 65 buildername='recipe simulation tester', |
| 34 revision='deadbeaf', | 66 revision='deadbeaf', |
| 35 ) | 67 project_under_test='build', |
| 68 ) + | |
| 69 api.luci_config.get_projects(('build',)) + | |
| 70 api.luci_config.get_project_config( | |
| 71 'build', 'recipes.cfg', | |
| 72 'recipes_path: "foobar"') | |
| 36 ) | 73 ) |
| OLD | NEW |