xref: /aosp_15_r20/external/angle/infra/specs/PRESUBMIT.py (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1# Copyright 2021 The ANGLE Project 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"""
5See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
6for more details on the presubmit API built into depot_tools.
7"""
8
9import os
10
11USE_PYTHON3 = True
12
13
14def _CommonChecks(input_api, output_api):
15    d = os.path.dirname
16    angle_root = d(d(input_api.PresubmitLocalPath()))
17    gen_script = os.path.join(angle_root, 'testing', 'buildbot', 'generate_buildbot_json.py')
18
19    # Validate the format of the mb_config.pyl file.
20    mb_path = os.path.join(angle_root, 'tools', 'mb', 'mb.py')
21    config_path = os.path.join(input_api.PresubmitLocalPath(), 'angle_mb_config.pyl')
22
23    commands = [
24        input_api.Command(
25            name='generate_buildbot_json',
26            cmd=[
27                input_api.python3_executable, gen_script, '--check', '--verbose',
28                '--pyl-files-dir',
29                input_api.PresubmitLocalPath()
30            ],
31            kwargs={},
32            message=output_api.PresubmitError),
33        input_api.Command(
34            name='mb_validate',
35            cmd=[
36                input_api.python3_executable,
37                mb_path,
38                'validate',
39                '-f',
40                config_path,
41            ],
42            kwargs={'cwd': input_api.PresubmitLocalPath()},
43            message=output_api.PresubmitError),
44    ]
45    messages = []
46
47    messages.extend(input_api.RunTests(commands))
48    return messages
49
50
51def CheckChangeOnUpload(input_api, output_api):
52    return _CommonChecks(input_api, output_api)
53
54
55def CheckChangeOnCommit(input_api, output_api):
56    return _CommonChecks(input_api, output_api)
57