We add a new script: scripts/check-maintainers-file.py, that will run at configuration time (and not at build time), to not hurt build time. This script runs in 0.2s on my dev VM, which has an old cpu.
We can expect things to be mostly in sync since adding or removing a source or test file will trigger a configure step. For the rest, like docs, tcg tests, or remaining files, GitLab CI will build things from scratch and always run the configure step. With this, it should be impossible by design to have an upstream MAINTAINERS file with non existing file entries. Signed-off-by: Pierrick Bouvier <[email protected]> --- meson.build | 5 +++ scripts/check-maintainers-file.py | 53 +++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100755 scripts/check-maintainers-file.py diff --git a/meson.build b/meson.build index 19e123423b5..57e9c9de42b 100644 --- a/meson.build +++ b/meson.build @@ -17,6 +17,11 @@ add_test_setup('thorough', meson.add_postconf_script(find_program('scripts/symlink-install-tree.py')) +# check our MAINTAINERS file is consistent +check_maintainers = find_program('scripts/check-maintainers-file.py') +maintainers_file = files('MAINTAINERS') +run_command([check_maintainers, maintainers_file], check: true) + #################### # Global variables # #################### diff --git a/scripts/check-maintainers-file.py b/scripts/check-maintainers-file.py new file mode 100755 index 00000000000..b001816a401 --- /dev/null +++ b/scripts/check-maintainers-file.py @@ -0,0 +1,53 @@ +#! /usr/bin/env python3 + +# Check incorrect file entries in MAINTAINERS +# +# Author: Pierrick Bouvier <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import argparse +import glob +import sys + + +def check_one_entry(line) -> bool: + return True + + +def main() -> None: + parser = argparse.ArgumentParser(description="Check MAINTAINERS file") + parser.add_argument("maintainers", help="Path to MAINTAINERS file") + args = parser.parse_args() + + found_file_entry = False + found_incorrect_entries = False + line_counter = 0 + + with open(args.maintainers) as file: + for entry in file: + line_counter += 1 + + if not entry.startswith("F:"): + continue + entry = entry[2:].strip() + found_file_entry = True + + file_exists = len(glob.glob(entry, recursive=True)) > 0 + if file_exists: + continue + + found_incorrect_entries = True + print( + f"No matching files for {args.maintainers} +{line_counter}: {entry}", + file=sys.stderr, + ) + + if not found_file_entry: + raise Exception("no file entry found - is MAINTAINERS path correct?") + if found_incorrect_entries: + raise Exception(f"incorrect entries found in {args.maintainers}") + + +if __name__ == "__main__": + main() -- 2.43.0
