From e327db1c44e27985a93dab43dd3fd41585cab3c4 Mon Sep 17 00:00:00 2001 From: Chris Austen Date: Mon, 29 Apr 2024 14:42:58 -0400 Subject: [PATCH] Check license per branch --- .github/workflows/ci.yaml | 2 +- tools/check_stamped.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 324cb77deff..8ab5fe25073 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -356,7 +356,7 @@ jobs: with: python-version: 3.8 - name: run License Check - run: python3 tools/check_stamped.py + run: python3 tools/check_stamped.py ${{ github.base_ref }} linux: diff --git a/tools/check_stamped.py b/tools/check_stamped.py index 16dde757ea0..793f60d1ac1 100644 --- a/tools/check_stamped.py +++ b/tools/check_stamped.py @@ -30,7 +30,7 @@ # in the license stamp, with the assumption being that any modifications/creations will need to be stamped to the year that the # modification/creation was made. ##################################################################################### -import subprocess, sys, datetime +import subprocess, sys, datetime, argparse debug = False @@ -111,14 +111,15 @@ def check_filename(filename: str, fileTuple: tuple or list) -> bool: return False -def main() -> None: +def main(branch) -> None: unsupported_file_types.extend(specificIgnores) ## Get a list of all files (not including deleted) that have changed/added in comparison to the latest Dev branch from MI Graphx # Subprocess 1 is fetching the latest dev branch from the MIgraphX Url and naming it as 'FETCH_HEAD' subprocess.run( - "git fetch https://github.com/ROCmSoftwarePlatform/AMDMIGraphX develop --quiet", + "git fetch https://github.com/ROCmSoftwarePlatform/AMDMIGraphX {0} --quiet" + .format(branch), shell=True, stdout=subprocess.PIPE) @@ -153,7 +154,7 @@ def main() -> None: elif len(stampedFilesWithBadYear) > 0: print( - f"\nError: The licenses for the following {str(len(stampedFilesWithBadYear))} file(s) either... do not match the year of commit, have a different copyright format or have not been synced from the latest develop branch:\n{str(stampedFilesWithBadYear)}\nThere is a license_stamper script (./tools/license_stamper.py), which you can run to automatically update and add any needed license stamps" + f"\nError: The licenses for the following {str(len(stampedFilesWithBadYear))} file(s) either... do not match the year of commit, have a different copyright format or have not been synced from the latest {branch} branch:\n{str(stampedFilesWithBadYear)}\nThere is a license_stamper script (./tools/license_stamper.py), which you can run to automatically update and add any needed license stamps" ) sys.exit(1) @@ -168,4 +169,9 @@ def main() -> None: if __name__ == "__main__": - main() + + parser = argparse.ArgumentParser() + parser.add_argument("branch") + args = parser.parse_args() + + main(args.branch)