From 8e778d86f7d7ec4e69a061f4c8397dc641dbd3ed Mon Sep 17 00:00:00 2001 From: Jacob Wienecke Date: Mon, 27 Jan 2025 15:22:07 -0600 Subject: [PATCH] scripts: ci: check_compliance.py: Fix perl script running on windows Add an if clause to the CheckPatch Class that checks for windows os. If windows os, check for perl installation. If no perl installation present. Fail the check. Without this change, CheckPatch can fail silently on windows, as windows does not have a way to run perl scripts. Signed-off-by: Jacob Wienecke --- scripts/ci/check_compliance.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/ci/check_compliance.py b/scripts/ci/check_compliance.py index c096cb5f4ca..8dd4fc5db12 100755 --- a/scripts/ci/check_compliance.py +++ b/scripts/ci/check_compliance.py @@ -212,16 +212,29 @@ class CheckPatch(ComplianceTest): if not os.path.exists(checkpatch): self.skip(f'{checkpatch} not found') + # check for Perl installation on Windows + if os.name == 'nt': + if not shutil.which('perl'): + self.failure("Perl not installed - required for checkpatch.pl. Please install Perl or add to PATH.") + return + else: + cmd = ['perl', checkpatch] + + # Linux and MacOS + else: + cmd = [checkpatch] + + cmd.extend(['--mailback', '--no-tree', '-']) diff = subprocess.Popen(('git', 'diff', '--no-ext-diff', COMMIT_RANGE), stdout=subprocess.PIPE, cwd=GIT_TOP) try: - subprocess.run((checkpatch, '--mailback', '--no-tree', '-'), + subprocess.run(cmd, check=True, stdin=diff.stdout, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, - shell=True, cwd=GIT_TOP) + shell=False, cwd=GIT_TOP) except subprocess.CalledProcessError as ex: output = ex.output.decode("utf-8")