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 | 5 |
6 # Recipe module for Skia Swarming trigger. | 6 # Recipe module for Skia Swarming trigger. |
7 | 7 |
8 | 8 |
9 import json | 9 import json |
10 | 10 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 'scripts', 'slave', 'recipes', 'skia') | 158 'scripts', 'slave', 'recipes', 'skia') |
159 api.skia_swarming.create_isolated_gen_json( | 159 api.skia_swarming.create_isolated_gen_json( |
160 skia_recipes_dir.join('swarm_recipe.isolate'), | 160 skia_recipes_dir.join('swarm_recipe.isolate'), |
161 skia_recipes_dir, | 161 skia_recipes_dir, |
162 'linux', | 162 'linux', |
163 'isolate_recipes', | 163 'isolate_recipes', |
164 {}) | 164 {}) |
165 return api.skia_swarming.batcharchive(['isolate_recipes'])[0][1] | 165 return api.skia_swarming.batcharchive(['isolate_recipes'])[0][1] |
166 | 166 |
167 | 167 |
168 def isolate_gsutil(api): | |
169 """Isolate gsutil from the depot_tools checkout.""" | |
170 skia_recipes_dir = api.path['build'].join( | |
171 'scripts', 'slave', 'recipes', 'skia') | |
172 api.skia_swarming.create_isolated_gen_json( | |
173 skia_recipes_dir.join('gsutil.isolate'), | |
174 skia_recipes_dir, | |
175 'linux', | |
176 'isolate_gsutil', | |
177 {}) | |
178 return api.skia_swarming.batcharchive(['isolate_gsutil'])[0][1] | |
179 | |
180 | |
181 def trigger_task(api, task_name, builder, master, slave, buildnumber, | 168 def trigger_task(api, task_name, builder, master, slave, buildnumber, |
182 builder_spec, got_revision, infrabots_dir, idempotent=False, | 169 builder_spec, got_revision, infrabots_dir, idempotent=False, |
183 store_output=True, extra_isolate_hashes=None, expiration=None, | 170 store_output=True, extra_isolate_hashes=None, expiration=None, |
184 hard_timeout=None, io_timeout=None): | 171 hard_timeout=None, io_timeout=None): |
185 """Trigger the given bot to run as a Swarming task.""" | 172 """Trigger the given bot to run as a Swarming task.""" |
186 # TODO(borenet): We're using Swarming directly to run the recipe through | 173 # TODO(borenet): We're using Swarming directly to run the recipe through |
187 # recipes.py. Once it's possible to track the state of a Buildbucket build, | 174 # recipes.py. Once it's possible to track the state of a Buildbucket build, |
188 # we should switch to use the trigger recipe module instead. | 175 # we should switch to use the trigger recipe module instead. |
189 | 176 |
190 properties = { | 177 properties = { |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 api.gsutil.upload( | 507 api.gsutil.upload( |
521 name='upload line-by-line coverage data', | 508 name='upload line-by-line coverage data', |
522 source=dst_lbl_file, | 509 source=dst_lbl_file, |
523 bucket='skia-infra', | 510 bucket='skia-infra', |
524 dest='/'.join(('coverage-json-v1', gs_json_path, | 511 dest='/'.join(('coverage-json-v1', gs_json_path, |
525 dst_lbl_file_basename)), | 512 dst_lbl_file_basename)), |
526 env={'AWS_CREDENTIAL_FILE': None, 'BOTO_CONFIG': None}, | 513 env={'AWS_CREDENTIAL_FILE': None, 'BOTO_CONFIG': None}, |
527 ) | 514 ) |
528 | 515 |
529 | 516 |
530 def download_asset(api, infrabots_dir, depot_tools_hash, asset): | |
531 """Trigger a swarming task to download and isolate the given asset.""" | |
532 return api.skia_swarming.isolate_and_trigger_task( | |
533 infrabots_dir.join('download_asset.isolate'), | |
534 api.path['slave_build'], | |
535 'download_%s' % asset, | |
536 {'ASSET': asset, 'GSUTIL': '../../../../../depot_tools/gsutil.py'}, | |
537 {'pool': 'Skia', 'os': 'Ubuntu'}, | |
538 extra_isolate_hashes=[depot_tools_hash], | |
539 idempotent=True, | |
540 isolate_blacklist=['.git', 'out', '*.pyc'], | |
541 store_output=False, | |
542 ) | |
543 | |
544 | |
545 def collect_hashes(api, tasks): | |
546 """Collect the isolated hash for each swarming task.""" | |
547 return [ | |
548 api.skia_swarming.collect_swarming_task_isolate_hash(t) for t in tasks] | |
549 | |
550 | |
551 def RunSteps(api): | 517 def RunSteps(api): |
552 got_revision = checkout_steps(api) | 518 got_revision = checkout_steps(api) |
553 builder_spec = api.skia.get_builder_spec(api.path['checkout'], | 519 builder_spec = api.skia.get_builder_spec(api.path['checkout'], |
554 api.properties['buildername']) | 520 api.properties['buildername']) |
555 builder_cfg = builder_spec['builder_cfg'] | 521 builder_cfg = builder_spec['builder_cfg'] |
556 infrabots_dir = api.path['checkout'].join('infra', 'bots') | 522 infrabots_dir = api.path['checkout'].join('infra', 'bots') |
557 | 523 |
558 api.skia_swarming.setup( | 524 api.skia_swarming.setup( |
559 api.path['checkout'].join('infra', 'bots', 'tools', 'luci-go'), | 525 api.path['checkout'].join('infra', 'bots', 'tools', 'luci-go'), |
560 swarming_rev='') | 526 swarming_rev='') |
561 | 527 |
562 # Run gsutil.py to ensure that it's installed. | 528 # Run gsutil.py to ensure that it's installed. |
563 api.gsutil(['help']) | 529 api.gsutil(['help']) |
564 | 530 |
565 recipes_hash = isolate_recipes(api) | 531 recipes_hash = isolate_recipes(api) |
566 extra_hashes = [recipes_hash] | 532 extra_hashes = [recipes_hash] |
567 | 533 |
568 # Some tasks only need depot_tools. | |
569 depot_tools_hash = isolate_gsutil(api) | |
570 | |
571 # Get ready to compile. | |
572 compile_deps = [] | |
573 extra_compile_hashes = [recipes_hash] | |
574 | |
575 # Android bots require an SDK. | 534 # Android bots require an SDK. |
576 if 'Android' in api.properties['buildername']: | 535 if 'Android' in api.properties['buildername']: |
577 if api.path.exists(infrabots_dir.join('assets', 'android_sdk')): | 536 test_data = 'a27a70d73b85191b9e671ff2a44547c3f7cc15ee' |
578 compile_deps.append(download_asset( | 537 hash_file = infrabots_dir.join('android_sdk_hash') |
579 api, infrabots_dir, depot_tools_hash, 'android_sdk')) | 538 # try/except as a temporary measure to prevent breakages for backfills |
580 else: | 539 # and branches. |
581 # TODO(borenet): Remove this legacy method after 7/1/2016. | 540 try: |
582 test_data = 'a27a70d73b85191b9e671ff2a44547c3f7cc15ee' | 541 h = api.skia._readfile(hash_file, |
583 hash_file = infrabots_dir.join('android_sdk_hash') | 542 name='Read android_sdk_hash', |
584 # try/except as a temporary measure to prevent breakages for backfills | 543 test_data=test_data).rstrip() |
585 # and branches. | 544 except api.step.StepFailure: |
586 try: | 545 # Just fall back on the original hash. |
587 h = api.skia._readfile(hash_file, | 546 h = 'a27a70d73b85191b9e671ff2a44547c3f7cc15ee' |
588 name='Read android_sdk_hash', | 547 extra_hashes.append(h) |
589 test_data=test_data).rstrip() | |
590 except api.step.StepFailure: | |
591 # Just fall back on the original hash. | |
592 h = 'a27a70d73b85191b9e671ff2a44547c3f7cc15ee' | |
593 extra_hashes.append(h) | |
594 extra_compile_hashes.append(h) | |
595 | 548 |
596 extra_compile_hashes.extend(collect_hashes(api, compile_deps)) | |
597 | |
598 # Compile. | |
599 do_compile_steps = builder_spec.get('do_compile_steps', True) | 549 do_compile_steps = builder_spec.get('do_compile_steps', True) |
| 550 compile_hash = None |
600 if do_compile_steps: | 551 if do_compile_steps: |
601 extra_hashes.append(compile_steps_swarm( | 552 compile_hash = compile_steps_swarm(api, builder_spec, got_revision, |
602 api, builder_spec, got_revision, infrabots_dir, extra_compile_hashes)) | 553 infrabots_dir, extra_hashes) |
603 | 554 |
604 if builder_cfg['role'] == 'Housekeeper': | 555 if builder_cfg['role'] == 'Housekeeper': |
605 housekeeper_swarm(api, builder_spec, got_revision, infrabots_dir, | 556 housekeeper_swarm(api, builder_spec, got_revision, infrabots_dir, |
606 extra_hashes) | 557 extra_hashes) |
607 return | 558 return |
608 | 559 |
609 # Get ready to test/perf. | |
610 do_test_steps = builder_spec['do_test_steps'] | 560 do_test_steps = builder_spec['do_test_steps'] |
611 do_perf_steps = builder_spec['do_perf_steps'] | 561 do_perf_steps = builder_spec['do_perf_steps'] |
612 | 562 |
613 if not (do_test_steps or do_perf_steps): | 563 if not (do_test_steps or do_perf_steps): |
614 return | 564 return |
615 | 565 |
| 566 if compile_hash: |
| 567 extra_hashes.append(compile_hash) |
| 568 |
616 api.skia.download_skps(api.path['slave_build'].join('tmp'), | 569 api.skia.download_skps(api.path['slave_build'].join('tmp'), |
617 api.path['slave_build'].join('skps'), | 570 api.path['slave_build'].join('skps'), |
618 False) | 571 False) |
619 api.skia.download_images(api.path['slave_build'].join('tmp'), | 572 api.skia.download_images(api.path['slave_build'].join('tmp'), |
620 api.path['slave_build'].join('images'), | 573 api.path['slave_build'].join('images'), |
621 False) | 574 False) |
622 | 575 |
623 test_task = None | 576 test_task = None |
624 perf_task = None | 577 perf_task = None |
625 if do_test_steps: | 578 if do_test_steps: |
626 test_task = test_steps_trigger(api, builder_spec, got_revision, | 579 test_task = test_steps_trigger(api, builder_spec, got_revision, |
627 infrabots_dir, extra_hashes) | 580 infrabots_dir, extra_hashes) |
628 if do_perf_steps: | 581 if do_perf_steps: |
629 perf_task = perf_steps_trigger(api, builder_spec, got_revision, | 582 perf_task = perf_steps_trigger(api, builder_spec, got_revision, |
630 infrabots_dir, extra_hashes) | 583 infrabots_dir, extra_hashes) |
631 is_trybot = builder_cfg['is_trybot'] | 584 is_trybot = builder_cfg['is_trybot'] |
632 if test_task: | 585 if test_task: |
633 test_steps_collect(api, test_task, builder_spec['upload_dm_results'], | 586 test_steps_collect(api, test_task, builder_spec['upload_dm_results'], |
634 got_revision, is_trybot, builder_cfg) | 587 got_revision, is_trybot, builder_cfg) |
635 if perf_task: | 588 if perf_task: |
636 perf_steps_collect(api, perf_task, builder_spec['upload_perf_results'], | 589 perf_steps_collect(api, perf_task, builder_spec['upload_perf_results'], |
637 got_revision, is_trybot) | 590 got_revision, is_trybot) |
638 | 591 |
639 | 592 |
640 def test_for_bot(api, builder, mastername, slavename, testname=None, | 593 def test_for_bot(api, builder, mastername, slavename, testname=None): |
641 legacy_android_sdk=False): | |
642 """Generate a test for the given bot.""" | 594 """Generate a test for the given bot.""" |
643 testname = testname or builder | 595 testname = testname or builder |
644 test = ( | 596 test = ( |
645 api.test(testname) + | 597 api.test(testname) + |
646 api.properties(buildername=builder, | 598 api.properties(buildername=builder, |
647 mastername=mastername, | 599 mastername=mastername, |
648 slavename=slavename, | 600 slavename=slavename, |
649 buildnumber=5, | 601 buildnumber=5, |
650 revision='abc123') + | 602 revision='abc123') + |
651 api.path.exists( | 603 api.path.exists( |
652 api.path['slave_build'].join('skia'), | 604 api.path['slave_build'].join('skia'), |
653 api.path['slave_build'].join('tmp', 'uninteresting_hashes.txt') | 605 api.path['slave_build'].join('tmp', 'uninteresting_hashes.txt') |
654 ) | 606 ) |
655 ) | 607 ) |
656 if 'Trybot' in builder: | 608 if 'Trybot' in builder: |
657 test += api.properties(issue=500, | 609 test += api.properties(issue=500, |
658 patchset=1, | 610 patchset=1, |
659 rietveld='https://codereview.chromium.org') | 611 rietveld='https://codereview.chromium.org') |
660 if 'Android' in builder: | |
661 if not legacy_android_sdk: | |
662 test += api.path.exists(api.path['slave_build'].join( | |
663 'skia', 'infra', 'bots', 'assets', 'android_sdk')) | |
664 test += api.step_data( | |
665 'upload new .isolated file for download_android_sdk', | |
666 stdout=api.raw_io.output('def456 XYZ.isolated')) | |
667 if 'Coverage' not in builder: | 612 if 'Coverage' not in builder: |
668 test += api.step_data( | 613 test += api.step_data( |
669 'upload new .isolated file for compile_skia', | 614 'upload new .isolated file for compile_skia', |
670 stdout=api.raw_io.output('def456 XYZ.isolated')) | 615 stdout=api.raw_io.output('def456 XYZ.isolated')) |
671 if 'Test' in builder: | 616 if 'Test' in builder: |
672 test += api.step_data( | 617 test += api.step_data( |
673 'upload new .isolated file for test_skia', | 618 'upload new .isolated file for test_skia', |
674 stdout=api.raw_io.output('def456 XYZ.isolated')) | 619 stdout=api.raw_io.output('def456 XYZ.isolated')) |
675 if ('Test' in builder and 'Debug' in builder) or 'Perf' in builder or ( | 620 if ('Test' in builder and 'Debug' in builder) or 'Perf' in builder or ( |
676 'Valgrind' in builder and 'Test' in builder): | 621 'Valgrind' in builder and 'Test' in builder): |
(...skipping 30 matching lines...) Expand all Loading... |
707 test += api.properties(test_downloaded_skp_version='999') | 652 test += api.properties(test_downloaded_skp_version='999') |
708 test += api.path.exists( | 653 test += api.path.exists( |
709 api.path['slave_build'].join('skia'), | 654 api.path['slave_build'].join('skia'), |
710 api.path['slave_build'].join('tmp', 'uninteresting_hashes.txt') | 655 api.path['slave_build'].join('tmp', 'uninteresting_hashes.txt') |
711 ) | 656 ) |
712 yield test | 657 yield test |
713 | 658 |
714 builder = 'Build-Ubuntu-GCC-Arm7-Release-Android_Vulkan' | 659 builder = 'Build-Ubuntu-GCC-Arm7-Release-Android_Vulkan' |
715 master = 'client.skia.compile' | 660 master = 'client.skia.compile' |
716 slave = 'skiabot-linux-compile-000' | 661 slave = 'skiabot-linux-compile-000' |
717 test = test_for_bot(api, builder, master, slave, 'legacy_android_sdk', | 662 test = test_for_bot(api, builder, master, slave, 'Missing_android_sdk_hash') |
718 legacy_android_sdk=True) | |
719 test += api.step_data('Read android_sdk_hash', | |
720 stdout=api.raw_io.output('<android_sdk_hash>')) | |
721 yield test | |
722 | |
723 test = test_for_bot(api, builder, master, slave, 'Missing_android_sdk_hash', | |
724 legacy_android_sdk=True) | |
725 test += api.step_data('Read android_sdk_hash', retcode=1) | 663 test += api.step_data('Read android_sdk_hash', retcode=1) |
726 yield test | 664 yield test |
OLD | NEW |