Skip to content

Optimize PR Checking, Branch Handling, and Workflow Timing in contribute.py #135

@saksham-gera

Description

@saksham-gera

There are several inefficiencies in the current GitHub automation script that need to be optimized for better performance and reliability:

  1. Inefficient Open PR Check (anyOpenPR)
  • Currently, the script fetches all pull requests and iterates through them to find an open PR.

Suggested Fix: Use repo.get_pulls(state='open', head=BRANCH_NAME) instead to fetch only relevant PRs.

  1. Creating Duplicate Branches
  • The script checks if a branch exists by iterating through all branches, which is inefficient for large repositories.

Suggested Fix: Use repo.get_branch(BRANCH_NAME) and handle exceptions if the branch does not exist.

  1. Inefficient PR Status Fetching (printPRStatus)
  • The script finds the highest issue/PR number instead of retrieving the latest PR efficiently.

Suggested Fix: Use repo.get_pulls(state='open', sort='created', direction='desc') to fetch the latest PR.

  1. Excessive time.sleep(4) Delay
  • The script waits for 4 seconds before checking PR status, which is arbitrary and may be unnecessary.

Suggested Fix: Implement a retry mechanism with exponential backoff instead of using a static sleep time.

  1. Non-Standard Exit Codes
  • The script exits with exit(0) even in failure cases, which incorrectly signals success.

Suggested Fix: Use exit(1) for errors to properly indicate failure cases.

  1. STUDY_NAME Should Be Replaced STUDY_NAME_PATH With In checkInputValidity()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions