diff --git a/.github/workflows/process-git-request.py b/.github/workflows/process-git-request.py new file mode 100644 index 0000000000000..c16b95b9111f4 --- /dev/null +++ b/.github/workflows/process-git-request.py @@ -0,0 +1,78 @@ +import sys +import subprocess +import os + +requestors = {"gvrose8192": ""} + +def file_prepend(file, str): + with open(file, 'r') as fd: + contents = fd.read() + new_contents = str + contents + + # Overwrite file but now with prepended string on it + with open(file, 'w') as fd: + fd.write(new_contents) + +def process_git_request(fname, target_branch, source_branch, prj_dir): + retcode = 200 # presume success + # print(f"Opening file {fname}") + file = open(fname, "w") + working_dir = prj_dir + # print(f"Working Dir : {working_dir}") + os.chdir(working_dir) + # print(f"pwd : {os.getcwd()}") + git_cmd = f"git log --oneline --no-abbrev-commit origin/{target_branch}..origin/{source_branch}" + # print(git_cmd) + try: + out, err = subprocess.Popen(git_cmd, shell=True, stdout=subprocess.PIPE, + stderr=subprocess.PIPE, text=True).communicate() + if err: + print(f"Command error output is {err}") + file.write(f"Command error output is {err}") + file.close() + retcode = 201 + return retcode + + output_lines = out.split() + # we just want the commit sha IDs + for x in output_lines: + print(f"This is output_lines {x}") + + file.close() + return retcode + except Exception as e: + print(f"Error executing git command: {str(e)}") + file.close() + return 201 + +first_arg, *argv_in = sys.argv[1:] # Skip script name in sys.argv + +if len(argv_in) < 5: + print("Not enough arguments: fname, target_branch, source_branch, prj_dir, pull_request, requestor") + sys.exit() + +fname = str(first_arg) +fname = "tmp-" + fname +# print("filename is " + fname) +target_branch = str(argv_in[0]) +# print("target branch is " + target_branch) +source_branch = str(argv_in[1]) +# print("source branch is " + source_branch) +prj_dir = str(argv_in[2]) +# print("project dir is " + prj_dir) +pullreq = str(argv_in[3]) +# print("pull request is " + pullreq) +requestor = str(argv_in[4]) + +retcode = process_git_request(fname, target_branch, source_branch, prj_dir) + +if retcode != 200: + with open(fname, 'r') as fd: + contents = fd.read() + print(contents) + sys.exit(1) +else: + print("Done") + +sys.exit(0) + diff --git a/.github/workflows/process-pull-request.yml b/.github/workflows/process-pull-request.yml index 706b4e2d339a1..5a7eb640cd835 100644 --- a/.github/workflows/process-pull-request.yml +++ b/.github/workflows/process-pull-request.yml @@ -19,19 +19,9 @@ jobs: runs-on: ubuntu-latest strategy: - matrix: - ruby-version: ['3.0'] steps: - uses: actions/checkout@v4 - - name: Set up Ruby - # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby, - # change this to (see https://github.com/ruby/setup-ruby#versioning): - uses: ruby/setup-ruby@v1 - # uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0 - with: - ruby-version: ${{ matrix.ruby-version }} - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - name: Set up Python uses: actions/setup-python@v5 - name: Run tests @@ -42,9 +32,9 @@ jobs: if ! git fetch origin ${{ github.head_ref }}; then echo "Unable to checkout ${{ github.head_ref }}" fi - git remote add linux https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git - git fetch --shallow-since="3 years ago" linux - echo "Will run process-git-request.rb with:" + # git remote add linux https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git + # git fetch --shallow-since="3 years ago" linux + echo "Will run process-git-request.py with:" echo "fname = ${{ github.run_id }}" echo "target_branch = ${{ github.base_ref }}" echo "source_branch = ${{ github.head_ref }}" @@ -52,5 +42,5 @@ jobs: echo "pull_request = ${{ github.ref }}" echo "requestor = ${{ github.actor }}" cd ${{ github.workspace }} - /usr/bin/ruby .github/workflows/process-git-request.rb ${{ github.run_id }} ${{ github.base_ref }} \ + /usr/bin/python3 .github/workflows/process-git-request.py ${{ github.run_id }} ${{ github.base_ref }} \ ${{ github.head_ref }} ${{ github.workspace }} ${{ github.ref }} ${{ github.actor }}