xref: /aosp_15_r20/external/skia/infra/bots/recipes/test_canvaskit.py (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1# Copyright 2018 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.
4
5# Recipe which runs the Canvaskit tests using docker
6
7PYTHON_VERSION_COMPATIBILITY = "PY3"
8
9DEPS = [
10  'checkout',
11  'docker',
12  'env',
13  'flavor',
14  'infra',
15  'recipe_engine/file',
16  'recipe_engine/path',
17  'recipe_engine/properties',
18  'recipe_engine/step',
19  'gold_upload',
20  'run',
21  'vars',
22]
23
24
25DOCKER_IMAGE = 'gcr.io/skia-public/gold-karma-chrome-tests:87.0.4280.88_v2'
26INNER_KARMA_SCRIPT = 'skia/infra/canvaskit/test_canvaskit.sh'
27
28def RunSteps(api):
29  api.vars.setup()
30  api.flavor.setup('dm')
31  checkout_root = api.path.start_dir
32  out_dir = api.vars.swarming_out_dir
33
34  # The karma script is configured to look in ./build/ for
35  # the test files to load, so we must copy them there (see Set up for docker).
36  copy_dest = checkout_root.joinpath('skia', 'modules', 'canvaskit',
37                                     'build')
38  api.file.ensure_directory('mkdirs copy_dest', copy_dest, mode=0o777)
39  base_dir = api.vars.build_dir
40  copies = [
41    {
42      'src': base_dir.joinpath('canvaskit.js'),
43      'dst': copy_dest.joinpath('canvaskit.js'),
44    },
45    {
46      'src': base_dir.joinpath('canvaskit.wasm'),
47      'dst': copy_dest.joinpath('canvaskit.wasm'),
48    },
49  ]
50  recursive_read = [checkout_root.joinpath('skia')]
51
52  args = [
53    '--builder',              api.vars.builder_name,
54    '--git_hash',             api.properties['revision'],
55    '--buildbucket_build_id', api.properties.get('buildbucket_build_id', ''),
56    '--browser',              'Chrome',
57    '--config',               api.vars.configuration,
58    '--source_type',          'canvaskit',
59  ]
60  if api.vars.is_trybot:
61    args.extend([
62      '--issue',         api.vars.issue,
63      '--patchset',      api.vars.patchset,
64    ])
65
66  api.docker.run(
67      name='Test CanvasKit with Docker',
68      docker_image=DOCKER_IMAGE,
69      src_dir=checkout_root,
70      out_dir=out_dir,
71      script=checkout_root.joinpath(INNER_KARMA_SCRIPT),
72      args=args,
73      docker_args=None,
74      copies=copies,
75      recursive_read=recursive_read,
76      attempts=3,
77  )
78
79  api.gold_upload.upload()
80
81def GenTests(api):
82  yield (
83      api.test('Test-Debian10-EMCC-GCE-GPU-WEBGL1-wasm-Debug-All-CanvasKit') +
84      api.properties(buildername=('Test-Debian10-EMCC-GCE-GPU-WEBGL1'
85                                  '-wasm-Debug-All-CanvasKit'),
86                     repository='https://skia.googlesource.com/skia.git',
87                     revision='abc123',
88                     gs_bucket='skia-infra-gm',
89                     path_config='kitchen',
90                     swarm_out_dir='[SWARM_OUT_DIR]')
91  )
92
93  yield (
94      api.test('canvaskit_trybot') +
95      api.properties(buildername=('Test-Debian10-EMCC-GCE-CPU-AVX2'
96                                  '-wasm-Debug-All-CanvasKit'),
97                     repository='https://skia.googlesource.com/skia.git',
98                     revision='abc123',
99                     gs_bucket='skia-infra-gm',
100                     path_config='kitchen',
101                     swarm_out_dir='[SWARM_OUT_DIR]',
102                     patch_ref='89/456789/12',
103                     patch_repo='https://skia.googlesource.com/skia.git',
104                     patch_storage='gerrit',
105                     patch_set=7,
106                     patch_issue=1234,
107                     gerrit_project='skia',
108                     gerrit_url='https://skia-review.googlesource.com/')
109  )
110