xref: /aosp_15_r20/external/angle/build/config/siso/PRESUBMIT.py (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
1# Copyright 2023 The Chromium Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5PRESUBMIT_VERSION = '2.0.0'
6
7
8def CheckSisoConfigFormat(input_api, output_api):
9  """Check if build/config/siso/*.star files are formatted correctly."""
10  repo_root = input_api.change.RepositoryRoot()
11  log_level = 'debug' if input_api.verbose else 'warning'
12  commands = []
13  for f in input_api.AffectedFiles():
14    filepath = f.AbsoluteLocalPath()
15    if not filepath.endswith('.star'):
16      continue
17    if not input_api.os_path.isfile(filepath):
18      continue
19    name = 'Validate ' + filepath
20    cmd = ['lucicfg', 'fmt', '-dry-run', '-log-level', log_level, filepath]
21    commands.append(input_api.Command(name, cmd, {}, output_api.PresubmitError))
22  return input_api.RunTests(commands)
23