Skip to content

Commit

Permalink
Merge branch 'develop' into fix_compilation_on_windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kahmed10 authored Jan 9, 2025
2 parents 77481d6 + 64647a0 commit 845ef56
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 24 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,14 @@ jobs:
docker-images: true

- uses: actions/[email protected]
with:
fetch-depth: 0 # Fetch the entire repository history and all branches
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: run License Check
run: python3 tools/check_stamped.py ${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
- name: Run License Check
run: python3 tools/check_stamped.py origin/${{ github.event_name == 'pull_request' && github.base_ref || 'develop' }}

linux:

Expand Down
66 changes: 44 additions & 22 deletions tools/check_stamped.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#####################################################################################
# The MIT License (MIT)
#
# Copyright (c) 2015-2024 Advanced Micro Devices, Inc. All rights reserved.
# Copyright (c) 2015-2025 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -30,9 +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, argparse

debug = False
import subprocess, sys, datetime, argparse, os

current_year = datetime.date.today().year

Expand Down Expand Up @@ -63,7 +61,7 @@ def hasKeySequence(inputfile: str, key_message: str) -> bool:


# Simple just open and write stuff to each file with the license stamp
def needStampCheck(filename: str) -> bool:
def needStampCheck(filename: str, debug: bool) -> bool:
# open save old contents and append things here
if debug: print("Open", filename, end=' ')
#Empty name isn't a filename
Expand Down Expand Up @@ -111,29 +109,52 @@ def check_filename(filename: str, fileTuple: tuple or list) -> bool:
return False


def main(branch) -> None:
unsupported_file_types.extend(specificIgnores)
def eval(cmd, **kwargs):
return subprocess.run(cmd,
capture_output=True,
shell=isinstance(cmd, str),
check=True,
**kwargs).stdout.decode('utf-8').strip()


def is_excluded(f):
base = os.path.basename(f)
return base in unsupported_file_types


def get_top():
return eval("git rev-parse --show-toplevel")


## Get a list of all files (not including deleted) that have changed/added in comparison to the latest Dev branch from MI Graphx
def get_head():
return eval("git rev-parse --abbrev-ref HEAD")

# 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 {0} --quiet"
.format(branch),
shell=True,
stdout=subprocess.PIPE)

# proc 2 is getting the list of file differences between FETCH_HEAD and the branch to be merged. (filters out deleted files from FETCH_HEAD)
proc = subprocess.run("git diff --name-only --diff-filter=d FETCH_HEAD",
shell=True,
stdout=subprocess.PIPE)
fileList = proc.stdout.decode().split('\n')
def get_merge_base(branch):
head = get_head()
return eval(f"git merge-base {branch} {head}")


def get_files_changed(against):
files = eval(
f"git diff-index --cached --name-only --diff-filter=d {against}",
cwd=get_top()).splitlines()
return (f for f in files
if f.endswith(supported_file_types) and not is_excluded(f))


def main(branch, debug) -> None:
unsupported_file_types.extend(specificIgnores)

fileList = list(get_files_changed(branch))

if debug: print(f"Target file list {len(fileList)}:\n" + str(fileList))
if debug:
print(f"Branch: {branch}, Target file list {len(fileList)}:\n" +
str(fileList))

for file in fileList:
if check_filename(file, supported_file_types):
if needStampCheck(file) and not check_filename(
if needStampCheck(file, debug) and not check_filename(
file, unsupported_file_types):
unstampedFiles.append(file)
else:
Expand Down Expand Up @@ -172,6 +193,7 @@ def main(branch) -> None:

parser = argparse.ArgumentParser()
parser.add_argument("branch")
parser.add_argument('-d', '--debug', action='store_true')
args = parser.parse_args()

main(args.branch)
main(args.branch, args.debug)

0 comments on commit 845ef56

Please sign in to comment.