xref: /aosp_15_r20/external/skia/infra/bots/recipes/test_pathkit.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 PathKit tests using docker
6
7PYTHON_VERSION_COMPATIBILITY = "PY3"
8
9DEPS = [
10  'checkout',
11  'docker',
12  'env',
13  'flavor',
14  'gold_upload',
15  'infra',
16  'recipe_engine/file',
17  'recipe_engine/path',
18  'recipe_engine/properties',
19  'recipe_engine/step',
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/pathkit/test_pathkit.sh'
27
28
29def RunSteps(api):
30  api.vars.setup()
31  api.flavor.setup("dm")
32  checkout_root = api.path.start_dir
33  out_dir = api.vars.swarming_out_dir
34
35  # The karma script is configured to look in ./npm-(asmjs|wasm)/bin/test/ for
36  # the test files to load, so we must copy them there (see Set up for docker).
37  copy_dest = checkout_root.joinpath('skia', 'modules', 'pathkit',
38                                     'build', 'wasm')
39  if 'asmjs' in api.vars.builder_name:
40    copy_dest = checkout_root.joinpath('skia', 'modules', 'pathkit',
41                                       'build', 'asmjs')
42
43  base_dir = api.vars.build_dir
44  bundle_name = 'pathkit.wasm'
45  if 'asmjs' in api.vars.builder_name:
46    # release mode has a .js.mem file that needs to come with.
47    # debug mode has an optional .map file, but we can omit that for tests
48    if 'Debug' in api.vars.builder_name:
49      bundle_name = ''
50    else:
51      bundle_name = 'pathkit.js.mem'
52
53  copies = [{
54    'src': base_dir.joinpath('pathkit.js'),
55    'dst': copy_dest.joinpath('pathkit.js'),
56  }]
57  if bundle_name:
58    copies.append({
59      'src': base_dir.joinpath(bundle_name),
60      'dst': copy_dest.joinpath(bundle_name),
61    })
62  recursive_read = [checkout_root.joinpath('skia')]
63
64  docker_args = None
65  if 'asmjs' in api.vars.builder_name:
66    docker_args = ['--env', 'ASM_JS=1']
67
68  args = [
69    '--builder',              api.vars.builder_name,
70    '--git_hash',             api.properties['revision'],
71    '--buildbucket_build_id', api.properties.get('buildbucket_build_id', ''),
72    '--browser',              'Chrome',
73    '--config',               api.vars.configuration,
74    '--source_type',          'pathkit',
75  ]
76  if 'asmjs' in api.vars.builder_name:
77    args.extend(['--compiled_language', 'asmjs']) # the default is wasm
78  if api.vars.is_trybot:
79    args.extend([
80      '--issue',         api.vars.issue,
81      '--patchset',      api.vars.patchset,
82    ])
83
84  api.docker.run(
85      name='Test PathKit with Docker',
86      docker_image=DOCKER_IMAGE,
87      src_dir=checkout_root,
88      out_dir=out_dir,
89      script=checkout_root.joinpath(INNER_KARMA_SCRIPT),
90      args=args,
91      docker_args=docker_args,
92      copies=copies,
93      recursive_read=recursive_read,
94      attempts=3,
95  )
96
97  api.gold_upload.upload()
98
99
100def GenTests(api):
101  yield (
102      api.test('Test-Debian10-EMCC-GCE-CPU-AVX2-wasm-Debug-All-PathKit') +
103      api.properties(buildername=('Test-Debian10-EMCC-GCE-CPU-AVX2'
104                                  '-wasm-Debug-All-PathKit'),
105                     repository='https://skia.googlesource.com/skia.git',
106                     revision='abc123',
107                     gs_bucket='skia-infra-gm',
108                     path_config='kitchen',
109                     swarm_out_dir='[SWARM_OUT_DIR]')
110  )
111
112  yield (
113      api.test('Test-Debian10-EMCC-GCE-CPU-AVX2-asmjs-Debug-All-PathKit') +
114      api.properties(buildername=('Test-Debian10-EMCC-GCE-CPU-AVX2'
115                                  '-asmjs-Debug-All-PathKit'),
116                     repository='https://skia.googlesource.com/skia.git',
117                     revision='abc123',
118                     gs_bucket='skia-infra-gm',
119                     path_config='kitchen',
120                     swarm_out_dir='[SWARM_OUT_DIR]')
121  )
122
123  yield (
124      api.test('Test-Debian10-EMCC-GCE-CPU-AVX2-asmjs-Release-All-PathKit') +
125      api.properties(buildername=('Test-Debian10-EMCC-GCE-CPU-AVX2'
126                                  '-asmjs-Release-All-PathKit'),
127                     repository='https://skia.googlesource.com/skia.git',
128                     revision='abc123',
129                     gs_bucket='skia-infra-gm',
130                     path_config='kitchen',
131                     swarm_out_dir='[SWARM_OUT_DIR]')
132  )
133
134  yield (
135      api.test('pathkit_trybot') +
136      api.properties(buildername=('Test-Debian10-EMCC-GCE-CPU-AVX2'
137                                  '-wasm-Debug-All-PathKit'),
138                     repository='https://skia.googlesource.com/skia.git',
139                     revision='abc123',
140                     gs_bucket='skia-infra-gm',
141                     path_config='kitchen',
142                     swarm_out_dir='[SWARM_OUT_DIR]',
143                     patch_ref='89/456789/12',
144                     patch_repo='https://skia.googlesource.com/skia.git',
145                     patch_storage='gerrit',
146                     patch_set=7,
147                     patch_issue=1234,
148                     gerrit_project='skia',
149                     gerrit_url='https://skia-review.googlesource.com/')
150  )
151