1cb93a386Sopenharmony_ci# Copyright 2016 The Chromium Authors. All rights reserved. 2cb93a386Sopenharmony_ci# Use of this source code is governed by a BSD-style license that can be 3cb93a386Sopenharmony_ci# found in the LICENSE file. 4cb93a386Sopenharmony_ci 5cb93a386Sopenharmony_ci 6cb93a386Sopenharmony_ci# Recipe which runs the Skia infra tests. 7cb93a386Sopenharmony_ci 8cb93a386Sopenharmony_ciPYTHON_VERSION_COMPATIBILITY = "PY2+3" 9cb93a386Sopenharmony_ci 10cb93a386Sopenharmony_ciDEPS = [ 11cb93a386Sopenharmony_ci 'infra', 12cb93a386Sopenharmony_ci 'recipe_engine/context', 13cb93a386Sopenharmony_ci 'recipe_engine/path', 14cb93a386Sopenharmony_ci 'recipe_engine/properties', 15cb93a386Sopenharmony_ci 'recipe_engine/step', 16cb93a386Sopenharmony_ci 'vars', 17cb93a386Sopenharmony_ci] 18cb93a386Sopenharmony_ci 19cb93a386Sopenharmony_ci 20cb93a386Sopenharmony_cidef git_init(api, repo_root, env): 21cb93a386Sopenharmony_ci with api.context(cwd=repo_root, env=env): 22cb93a386Sopenharmony_ci # Some tests assume that they're being run inside a git repo. 23cb93a386Sopenharmony_ci api.step('git init', cmd=['git', 'init']) 24cb93a386Sopenharmony_ci api.step('git add .', cmd=['git', 'add', '.']) 25cb93a386Sopenharmony_ci api.step('git commit', cmd=['git', 'commit', '-a', '-m', 'initial commit']) 26cb93a386Sopenharmony_ci 27cb93a386Sopenharmony_ci 28cb93a386Sopenharmony_cidef RunSteps(api): 29cb93a386Sopenharmony_ci api.vars.setup() 30cb93a386Sopenharmony_ci 31cb93a386Sopenharmony_ci # Run the infra tests. 32cb93a386Sopenharmony_ci repo_name = api.properties['repository'].split('/')[-1] 33cb93a386Sopenharmony_ci if repo_name.endswith('.git'): 34cb93a386Sopenharmony_ci repo_name = repo_name[:-len('.git')] 35cb93a386Sopenharmony_ci repo_root = api.path['start_dir'].join(repo_name) 36cb93a386Sopenharmony_ci infra_tests = repo_root.join('infra', 'bots', 'infra_tests.py') 37cb93a386Sopenharmony_ci 38cb93a386Sopenharmony_ci # Merge the default environment with the Go environment. 39cb93a386Sopenharmony_ci env = {} 40cb93a386Sopenharmony_ci env.update(api.infra.go_env) 41cb93a386Sopenharmony_ci for k, v in api.vars.default_env.items(): 42cb93a386Sopenharmony_ci # The PATH variable gets merged; all others get replaced. 43cb93a386Sopenharmony_ci if k == 'PATH': 44cb93a386Sopenharmony_ci # This works because the value for PATH in go_env and default_env includes 45cb93a386Sopenharmony_ci # the '%(PATH)s' placeholder. 46cb93a386Sopenharmony_ci env[k] = env[k] % {k: v} 47cb93a386Sopenharmony_ci else: 48cb93a386Sopenharmony_ci env[k] = v 49cb93a386Sopenharmony_ci 50cb93a386Sopenharmony_ci git_init(api, repo_root, env) 51cb93a386Sopenharmony_ci if repo_name != 'skia': 52cb93a386Sopenharmony_ci git_init(api, api.path['start_dir'].join('skia'), env) 53cb93a386Sopenharmony_ci 54cb93a386Sopenharmony_ci with api.context(cwd=repo_root, env=env): 55cb93a386Sopenharmony_ci # Unfortunately, the recipe tests are flaky due to file removal on Windows. 56cb93a386Sopenharmony_ci # Run multiple attempts. 57cb93a386Sopenharmony_ci last_exc = None 58cb93a386Sopenharmony_ci for _ in range(3): 59cb93a386Sopenharmony_ci try: 60cb93a386Sopenharmony_ci api.step('infra_tests', cmd=['python', '-u', infra_tests]) 61cb93a386Sopenharmony_ci break 62cb93a386Sopenharmony_ci except api.step.StepFailure as e: # pragma: nocover 63cb93a386Sopenharmony_ci last_exc = e 64cb93a386Sopenharmony_ci else: # pragma: nocover 65cb93a386Sopenharmony_ci raise last_exc 66cb93a386Sopenharmony_ci 67cb93a386Sopenharmony_cidef GenTests(api): 68cb93a386Sopenharmony_ci yield ( 69cb93a386Sopenharmony_ci api.test('infra_tests') + 70cb93a386Sopenharmony_ci api.properties(buildername='Housekeeper-PerCommit-InfraTests_Linux', 71cb93a386Sopenharmony_ci repository='https://skia.googlesource.com/skia.git', 72cb93a386Sopenharmony_ci path_config='kitchen', 73cb93a386Sopenharmony_ci swarm_out_dir='[SWARM_OUT_DIR]') 74cb93a386Sopenharmony_ci ) 75cb93a386Sopenharmony_ci yield ( 76cb93a386Sopenharmony_ci api.test('infra_tests_lottie_ci') + 77cb93a386Sopenharmony_ci api.properties(buildername='Housekeeper-PerCommit-InfraTests_Linux', 78cb93a386Sopenharmony_ci repository='https://skia.googlesource.com/lottie-ci.git', 79cb93a386Sopenharmony_ci path_config='kitchen', 80cb93a386Sopenharmony_ci swarm_out_dir='[SWARM_OUT_DIR]') 81cb93a386Sopenharmony_ci ) 82