From 881106e0fa6cc235a574c73401b9ddc131cd8dea Mon Sep 17 00:00:00 2001 From: Yixin Huang Date: Thu, 10 Oct 2024 16:00:12 +0200 Subject: [PATCH 01/11] 1st_version of the github_auto_add --- scripts/auto-add-github-resources.py | 139 +++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) create mode 100644 scripts/auto-add-github-resources.py diff --git a/scripts/auto-add-github-resources.py b/scripts/auto-add-github-resources.py new file mode 100644 index 00000000..23da72b2 --- /dev/null +++ b/scripts/auto-add-github-resources.py @@ -0,0 +1,139 @@ +import sys +import os +from _github_utilities import create_branch, get_file_in_repository, get_issue_body, write_file, send_pull_request +import yaml +from github import Github + +def main(): + """ + Main function to retrieve metadata from a GitHub repository and append it to a YAML file. + Creates a pull request with the updated data. + + Arguments: + - repository (str): GitHub repository name. + - issue (int): Issue number containing the GitHub link. + + Example: + python auto_add_github_entry.py "username/repo" 123 + """ + # Retrieve repository and issue number from command-line arguments + repository = sys.argv[1] + issue = int(sys.argv[2]) + + yml_filename = "resources/nfdi4bioimage.yml" + + # Get the issue body, which should contain a GitHub repository link + issue_text = get_issue_body(repository, issue) + if "\n" in issue_text or not issue_text.startswith("https://github.com/"): + print(issue_text, " is not a GitHub repository link. Exiting.") + return + + github_repo_url = issue_text + + # Retrieve GitHub metadata + github_data_dict = complete_github_data(github_repo_url) + github_yml = "\n- " + yaml.dump(github_data_dict).replace("\n", "\n ") + + # Read the existing YAML "database" + branch = create_branch(repository) + file_content = get_file_in_repository(repository, branch, yml_filename).decoded_content.decode() + + print("YAML file content length:", len(file_content)) + + # Add the new entry + file_content += github_yml + + # Save the updated content back to GitHub and create a pull request + write_file(repository, branch, yml_filename, file_content, "Add " + github_repo_url) + res = send_pull_request(repository, branch, "Add " + github_repo_url, f"closes #{issue}") + + print("Done.", res) + + +def complete_github_data(github_repo_url): + """ + Retrieves metadata from the specified GitHub repository with checks for missing fields. + + Arguments: + - github_repo_url (str): The URL of the GitHub repository to retrieve metadata from. + + Returns: + - entry (dict): A dictionary containing the repository metadata. + """ + token = os.getenv("GITHUB_TOKEN") + if not token: + raise Exception("GitHub token not found in environment. Please set GITHUB_TOKEN.") + + g = Github(token) + repo_path = github_repo_url.replace("https://github.com/", "") + repo = g.get_repo(repo_path) + + # Initialize the metadata dictionary + entry = {} + + # URL of the repository + entry['url'] = github_repo_url + + # Repository name (used as the title) + if repo.name: + entry['name'] = repo.name + else: + entry['name'] = "No name available" + + # Repository description + if repo.description: + entry['description'] = repo.description + else: + entry['description'] = "No description available" + + # License information (used as "type") + if repo.get_license(): + entry['type'] = repo.get_license().license.name + else: + entry['type'] = "No license available" + + # Authors (collaborators) + collaborators = repo.get_collaborators() + if collaborators.totalCount > 0: + entry['authors'] = ", ".join([collab.login for collab in collaborators]) + else: + entry['authors'] = "No authors available" + + # Tags (topics) + topics = repo.get_topics() + if topics: + entry['tags'] = ", ".join(topics) + else: + entry['tags'] = "No tags available" + + # Publication date (first release date or creation date) + entry['publication_date'] = get_publication_date(repo) + + # Last updated date + entry['last_updated'] = repo.updated_at.isoformat() if repo.updated_at else "No update information available" + + return entry + + +def get_publication_date(repo): + """ + Retrieves the publication date of the repository. If the repository has releases, + the date of the first release is used. If no releases are found, the repository's + creation date is used as the publication date. + + Arguments: + - repo (github.Repository.Repository): The GitHub repository object. + + Returns: + - publication_date (str): The ISO-formatted publication date. + """ + releases = repo.get_releases() + if releases.totalCount > 0: + first_release = releases[0] + return first_release.created_at.isoformat() + else: + return repo.created_at.isoformat() if repo.created_at else "No creation date available" + + +if __name__ == "__main__": + main() From fe84604a7624e5c423703c27bbabee8b95045eb3 Mon Sep 17 00:00:00 2001 From: Yixin Huang Date: Thu, 10 Oct 2024 16:11:37 +0200 Subject: [PATCH 02/11] Remove the test example from the local page --- scripts/auto-add-github-resources.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/auto-add-github-resources.py b/scripts/auto-add-github-resources.py index 23da72b2..ce1e1c40 100644 --- a/scripts/auto-add-github-resources.py +++ b/scripts/auto-add-github-resources.py @@ -12,9 +12,6 @@ def main(): Arguments: - repository (str): GitHub repository name. - issue (int): Issue number containing the GitHub link. - - Example: - python auto_add_github_entry.py "username/repo" 123 """ # Retrieve repository and issue number from command-line arguments repository = sys.argv[1] From 2bac904c9806d461b14815bdd78148725b7ef4f2 Mon Sep 17 00:00:00 2001 From: Yixin Huang Date: Thu, 10 Oct 2024 17:36:55 +0200 Subject: [PATCH 03/11] error 403, still not be solve --- scripts/auto-add-github-resources.py | 56 ++++++++++++++-------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/scripts/auto-add-github-resources.py b/scripts/auto-add-github-resources.py index ce1e1c40..e8a0fd93 100644 --- a/scripts/auto-add-github-resources.py +++ b/scripts/auto-add-github-resources.py @@ -2,7 +2,7 @@ import os from _github_utilities import create_branch, get_file_in_repository, get_issue_body, write_file, send_pull_request import yaml -from github import Github +from github import Github, GithubException # Import GithubException directly def main(): """ @@ -12,6 +12,10 @@ def main(): Arguments: - repository (str): GitHub repository name. - issue (int): Issue number containing the GitHub link. + + Example(local_test): + python auto_add_github_entry.py "username/repo" 123 + python auto-add-github-resources.py "nfdi4bioimage/training" 236 """ # Retrieve repository and issue number from command-line arguments repository = sys.argv[1] @@ -57,51 +61,49 @@ def complete_github_data(github_repo_url): Returns: - entry (dict): A dictionary containing the repository metadata. """ - token = os.getenv("GITHUB_TOKEN") + token = os.getenv("GITHUB_API_KEY") if not token: - raise Exception("GitHub token not found in environment. Please set GITHUB_TOKEN.") + raise Exception("GitHub API key not found. Please set GITHUB_API_KEY.") g = Github(token) repo_path = github_repo_url.replace("https://github.com/", "") repo = g.get_repo(repo_path) - # Initialize the metadata dictionary entry = {} - # URL of the repository + # Repository URL entry['url'] = github_repo_url - # Repository name (used as the title) - if repo.name: - entry['name'] = repo.name - else: - entry['name'] = "No name available" + # Repository name + entry['name'] = repo.name if repo.name else "No name available" # Repository description - if repo.description: - entry['description'] = repo.description - else: - entry['description'] = "No description available" + entry['description'] = repo.description if repo.description else "No description available" # License information (used as "type") - if repo.get_license(): - entry['type'] = repo.get_license().license.name - else: + try: + license_info = repo.get_license() + entry['type'] = license_info.license.name if license_info else "No license available" + except: entry['type'] = "No license available" - # Authors (collaborators) - collaborators = repo.get_collaborators() - if collaborators.totalCount > 0: - entry['authors'] = ", ".join([collab.login for collab in collaborators]) - else: - entry['authors'] = "No authors available" + # Collaborators + try: + collaborators = repo.get_collaborators() + if collaborators.totalCount > 0: + entry['authors'] = ", ".join([collab.login for collab in collaborators]) + else: + entry['authors'] = "No authors available" + except GithubException as e: # Correct exception reference + if e.status == 403: + print(f"403 error: Cannot access collaborators for {repo.full_name}. Skipping this step.") + entry['authors'] = "Collaborators not accessible" + else: + raise e # Tags (topics) topics = repo.get_topics() - if topics: - entry['tags'] = ", ".join(topics) - else: - entry['tags'] = "No tags available" + entry['tags'] = ", ".join(topics) if topics else "No tags available" # Publication date (first release date or creation date) entry['publication_date'] = get_publication_date(repo) From 499050badc0b82ddf3c2169fea2080cb82a49d6b Mon Sep 17 00:00:00 2001 From: Yixin Huang Date: Fri, 11 Oct 2024 11:30:29 +0200 Subject: [PATCH 04/11] 1.1 version, it works --- scripts/auto-add-github-resources.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/auto-add-github-resources.py b/scripts/auto-add-github-resources.py index e8a0fd93..69c5f7d6 100644 --- a/scripts/auto-add-github-resources.py +++ b/scripts/auto-add-github-resources.py @@ -2,7 +2,7 @@ import os from _github_utilities import create_branch, get_file_in_repository, get_issue_body, write_file, send_pull_request import yaml -from github import Github, GithubException # Import GithubException directly +from github import Github, GithubException def main(): """ @@ -87,17 +87,17 @@ def complete_github_data(github_repo_url): except: entry['type'] = "No license available" - # Collaborators + # Contributors try: - collaborators = repo.get_collaborators() - if collaborators.totalCount > 0: - entry['authors'] = ", ".join([collab.login for collab in collaborators]) + contributors = repo.get_contributors() + if contributors.totalCount > 0: + entry['authors'] = ", ".join([contrib.login for contrib in contributors]) else: entry['authors'] = "No authors available" except GithubException as e: # Correct exception reference if e.status == 403: - print(f"403 error: Cannot access collaborators for {repo.full_name}. Skipping this step.") - entry['authors'] = "Collaborators not accessible" + print(f"403 error: Cannot access contributors for {repo.full_name}. Skipping this step.") + entry['authors'] = "Contributors not accessible" else: raise e @@ -135,4 +135,4 @@ def get_publication_date(repo): if __name__ == "__main__": - main() + main() \ No newline at end of file From 49ccc5e95b3415b0f5f370d4eeb6d3a24837f097 Mon Sep 17 00:00:00 2001 From: Yixin Huang Date: Fri, 11 Oct 2024 16:23:02 +0200 Subject: [PATCH 05/11] 1.2version,Updating the output sequence --- scripts/auto-add-github-resources.py | 54 ++++++++++++++-------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/scripts/auto-add-github-resources.py b/scripts/auto-add-github-resources.py index 69c5f7d6..dd037273 100644 --- a/scripts/auto-add-github-resources.py +++ b/scripts/auto-add-github-resources.py @@ -71,45 +71,45 @@ def complete_github_data(github_repo_url): entry = {} - # Repository URL - entry['url'] = github_repo_url - - # Repository name - entry['name'] = repo.name if repo.name else "No name available" - - # Repository description - entry['description'] = repo.description if repo.description else "No description available" - - # License information (used as "type") - try: - license_info = repo.get_license() - entry['type'] = license_info.license.name if license_info else "No license available" - except: - entry['type'] = "No license available" - - # Contributors + # Authors (Contributors) try: contributors = repo.get_contributors() if contributors.totalCount > 0: - entry['authors'] = ", ".join([contrib.login for contrib in contributors]) + entry['author'] = ", ".join([contrib.login for contrib in contributors]) else: - entry['authors'] = "No authors available" + entry['author'] = "" except GithubException as e: # Correct exception reference if e.status == 403: print(f"403 error: Cannot access contributors for {repo.full_name}. Skipping this step.") - entry['authors'] = "Contributors not accessible" + entry['author'] = "Contributors not accessible" else: raise e - # Tags (topics) - topics = repo.get_topics() - entry['tags'] = ", ".join(topics) if topics else "No tags available" + # Repository description + entry['description'] = repo.description if repo.description else "" + + # License information (stored as "license") + try: + license_info = repo.get_license() + entry['license'] = license_info.license.name if license_info else "" + except: + entry['license'] = "" + + # Repository name + entry['name'] = repo.name if repo.name else "" # Publication date (first release date or creation date) entry['publication_date'] = get_publication_date(repo) - # Last updated date - entry['last_updated'] = repo.updated_at.isoformat() if repo.updated_at else "No update information available" + # Tags (topics?):So how should we define the tags of the github resource? + topics = repo.get_topics() + entry['tags'] = ", ".join(topics) if topics else "" + + # Type: So how should we define the type of the github resource? + entry['type'] = "" + + # Repository URL + entry['url'] = github_repo_url return entry @@ -131,8 +131,8 @@ def get_publication_date(repo): first_release = releases[0] return first_release.created_at.isoformat() else: - return repo.created_at.isoformat() if repo.created_at else "No creation date available" + return repo.created_at.isoformat() if repo.created_at else "" if __name__ == "__main__": - main() \ No newline at end of file + main() From f0a595606bf6b5e792b2540c9841502823a7465a Mon Sep 17 00:00:00 2001 From: Yixin Huang Date: Fri, 11 Oct 2024 16:53:17 +0200 Subject: [PATCH 06/11] 1.3 version, update to return full name if available --- scripts/auto-add-github-resources.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/scripts/auto-add-github-resources.py b/scripts/auto-add-github-resources.py index dd037273..e6f044ad 100644 --- a/scripts/auto-add-github-resources.py +++ b/scripts/auto-add-github-resources.py @@ -59,7 +59,7 @@ def complete_github_data(github_repo_url): - github_repo_url (str): The URL of the GitHub repository to retrieve metadata from. Returns: - - entry (dict): A dictionary containing the repository metadata. + - entry (dict): A dictionary containing the repository metadata in the correct order. """ token = os.getenv("GITHUB_API_KEY") if not token: @@ -71,14 +71,15 @@ def complete_github_data(github_repo_url): entry = {} - # Authors (Contributors) + # Contributors (Full name if available, otherwise username) try: contributors = repo.get_contributors() if contributors.totalCount > 0: - entry['author'] = ", ".join([contrib.login for contrib in contributors]) + # Use the contributor's full name if available, otherwise use the username + entry['author'] = ", ".join([contrib.name if contrib.name else contrib.login for contrib in contributors]) else: entry['author'] = "" - except GithubException as e: # Correct exception reference + except GithubException as e: if e.status == 403: print(f"403 error: Cannot access contributors for {repo.full_name}. Skipping this step.") entry['author'] = "Contributors not accessible" @@ -101,11 +102,11 @@ def complete_github_data(github_repo_url): # Publication date (first release date or creation date) entry['publication_date'] = get_publication_date(repo) - # Tags (topics?):So how should we define the tags of the github resource? + # Tags (topics): should we use the repository topics or the README.md file? topics = repo.get_topics() entry['tags'] = ", ".join(topics) if topics else "" - # Type: So how should we define the type of the github resource? + # Type: how should we determine this for a GitHub repository? entry['type'] = "" # Repository URL @@ -114,6 +115,7 @@ def complete_github_data(github_repo_url): return entry + def get_publication_date(repo): """ Retrieves the publication date of the repository. If the repository has releases, @@ -135,4 +137,4 @@ def get_publication_date(repo): if __name__ == "__main__": - main() + main() \ No newline at end of file From 6e41ca07b7917286a3dff55f2760bfe3a305b344 Mon Sep 17 00:00:00 2001 From: Robert Haase Date: Sat, 12 Oct 2024 18:17:29 +0200 Subject: [PATCH 07/11] update git-bob config --- .github/workflows/comment-on-issue.yml | 49 --------------- .github/workflows/git-bob.yml | 75 +++++++++++++++++++++++ .github/workflows/review-pull-request.yml | 51 --------------- 3 files changed, 75 insertions(+), 100 deletions(-) delete mode 100644 .github/workflows/comment-on-issue.yml create mode 100644 .github/workflows/git-bob.yml delete mode 100644 .github/workflows/review-pull-request.yml diff --git a/.github/workflows/comment-on-issue.yml b/.github/workflows/comment-on-issue.yml deleted file mode 100644 index 9b8bb810..00000000 --- a/.github/workflows/comment-on-issue.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Respond to Issue - -on: - issues: - types: [opened] - issue_comment: - types: - - created - -jobs: - respond: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Print pull request number - run: | - echo "Pull Request Number - ${{ github.event.pull_request.number }}" - echo "Organization - ${{ github.repository_owner }}" - echo "Repository Name - ${{ github.repository }}" - - - name: Print Job details - run: | - echo "Run ID - ${{ github.run_id }}" - echo "Job ID - ${{ github.job }}" - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install git-bob - - - name: Run Python - env: - ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}" - GOOGLE_API_KEY: "${{ secrets.GOOGLE_API_KEY }}" - GIT_BOB_LLM_NAME: "${{ secrets.GIT_BOB_LLM_NAME }}" - OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}" - GH_MODELS_API_KEY: "${{ secrets.GH_MODELS_API_KEY }}" - GITHUB_API_KEY: "${{ secrets.GITHUB_TOKEN }}" - GITHUB_RUN_ID: "${{ github.run_id }}" - run: | - git-bob comment-on-issue-action ${{ github.repository }} ${{ github.event.pull_request.number }} ${{ github.event.issue.number }} diff --git a/.github/workflows/git-bob.yml b/.github/workflows/git-bob.yml new file mode 100644 index 00000000..571dee1b --- /dev/null +++ b/.github/workflows/git-bob.yml @@ -0,0 +1,75 @@ +name: git-bob acting + +on: + issues: + types: [opened] + issue_comment: + types: + - created + pull_request: + types: [opened, synchronize] + pull_request_review_comment: + types: [ created ] + +jobs: + respond: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Print pull request number + run: | + echo "Pull Request Number - ${{ github.event.pull_request.number }}" + echo "Organization - ${{ github.repository_owner }}" + echo "Repository Name - ${{ github.repository }}" + + - name: Print Job details + run: | + echo "Run ID - ${{ github.run_id }}" + echo "Run No - ${{ github.run_number }}" + echo "Job - ${{ github.job }}" + echo "Job ID - ${{ github.job_id }}" + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -e . + pip install -r requirements.txt + + + - name: Run git-bob + env: + GIT_BOB_AGENT_NAME: "git-bob" + GIT_BOB_LLM_NAME: "${{ secrets.GIT_BOB_LLM_NAME }}" + ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}" + GOOGLE_API_KEY: "${{ secrets.GOOGLE_API_KEY }}" + OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}" + GH_MODELS_API_KEY: "${{ secrets.GH_MODELS_API_KEY }}" + KISSKI_API_KEY: "${{ secrets.KISSKI_API_KEY }}" + BLABLADOR_API_KEY: "${{ secrets.BLABLADOR_API_KEY }}" + GITHUB_API_KEY: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_RUN_ID: "${{ github.run_id }}" + TWINE_USERNAME: "${{ secrets.TWINE_USERNAME }}" + TWINE_PASSWORD: "${{ secrets.TWINE_PASSWORD }}" + SYSTEM_MESSAGE: | + You are an extremely skilled python developer and data scientist. Your name is git-bob. You are sometimes called github-actions bot. + You can solve programming tasks and review code. + When asked to solve a specific problem, you keep your code changes minimal and only solve the problem at hand. + You cannot retrieve information from other sources but from github.com. + Do not claim anything that you don't know. + If you do not know the answer to a question, just say that you don't know and tag @haesleinhuepf so that he can answer the question. + In case you are asked to review code, you focus on the quality of the code. + VISION_SYSTEM_MESSAGE: | + You are an AI-based vision model with excellent skills when it comes to describing image. When describing an image, you typically explain: + * What is shown in the image. + * If the image shows clearly distinct objects in its channels, these structures are listed for each channel individually. + * You speculate how the image was acquired. + run: | + git-bob github-action ${{ github.repository }} ${{ github.event.pull_request.number }} ${{ github.event.issue.number }} diff --git a/.github/workflows/review-pull-request.yml b/.github/workflows/review-pull-request.yml deleted file mode 100644 index 18c7dec0..00000000 --- a/.github/workflows/review-pull-request.yml +++ /dev/null @@ -1,51 +0,0 @@ -name: Review Pull Request - -on: - pull_request: - types: [opened, synchronize] - pull_request_review_comment: - types: [ created ] - -jobs: - respond: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Print pull request number - run: | - echo "Pull Request Number - ${{ github.event.pull_request.number }}" - echo "Organization - ${{ github.repository_owner }}" - echo "Repository Name - ${{ github.repository }}" - - - name: Print Job details - run: | - echo "Run ID - ${{ github.run_id }}" - echo "Run No - ${{ github.run_number }}" - echo "Job - ${{ github.job }}" - echo "Job ID - ${{ github.job_id }}" - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install git-bob - - - name: Run Python - env: - ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}" - GOOGLE_API_KEY: "${{ secrets.GOOGLE_API_KEY }}" - GIT_BOB_LLM_NAME: "${{ secrets.GIT_BOB_LLM_NAME }}" - OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}" - GH_MODELS_API_KEY: "${{ secrets.GH_MODELS_API_KEY }}" - GITHUB_API_KEY: "${{ secrets.GITHUB_TOKEN }}" - GITHUB_RUN_ID: "${{ github.run_id }}" - run: | - git-bob review-pull-request-action ${{ github.repository }} ${{ github.event.pull_request.number }} - From eb369506f8065f54544a292301e0c01192a78341 Mon Sep 17 00:00:00 2001 From: Robert Haase Date: Sat, 12 Oct 2024 18:21:06 +0200 Subject: [PATCH 08/11] Revert "update git-bob config" This reverts commit 6e41ca07b7917286a3dff55f2760bfe3a305b344. --- .github/workflows/comment-on-issue.yml | 49 +++++++++++++++ .github/workflows/git-bob.yml | 75 ----------------------- .github/workflows/review-pull-request.yml | 51 +++++++++++++++ 3 files changed, 100 insertions(+), 75 deletions(-) create mode 100644 .github/workflows/comment-on-issue.yml delete mode 100644 .github/workflows/git-bob.yml create mode 100644 .github/workflows/review-pull-request.yml diff --git a/.github/workflows/comment-on-issue.yml b/.github/workflows/comment-on-issue.yml new file mode 100644 index 00000000..9b8bb810 --- /dev/null +++ b/.github/workflows/comment-on-issue.yml @@ -0,0 +1,49 @@ +name: Respond to Issue + +on: + issues: + types: [opened] + issue_comment: + types: + - created + +jobs: + respond: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Print pull request number + run: | + echo "Pull Request Number - ${{ github.event.pull_request.number }}" + echo "Organization - ${{ github.repository_owner }}" + echo "Repository Name - ${{ github.repository }}" + + - name: Print Job details + run: | + echo "Run ID - ${{ github.run_id }}" + echo "Job ID - ${{ github.job }}" + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install git-bob + + - name: Run Python + env: + ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}" + GOOGLE_API_KEY: "${{ secrets.GOOGLE_API_KEY }}" + GIT_BOB_LLM_NAME: "${{ secrets.GIT_BOB_LLM_NAME }}" + OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}" + GH_MODELS_API_KEY: "${{ secrets.GH_MODELS_API_KEY }}" + GITHUB_API_KEY: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_RUN_ID: "${{ github.run_id }}" + run: | + git-bob comment-on-issue-action ${{ github.repository }} ${{ github.event.pull_request.number }} ${{ github.event.issue.number }} diff --git a/.github/workflows/git-bob.yml b/.github/workflows/git-bob.yml deleted file mode 100644 index 571dee1b..00000000 --- a/.github/workflows/git-bob.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: git-bob acting - -on: - issues: - types: [opened] - issue_comment: - types: - - created - pull_request: - types: [opened, synchronize] - pull_request_review_comment: - types: [ created ] - -jobs: - respond: - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v2 - - - name: Print pull request number - run: | - echo "Pull Request Number - ${{ github.event.pull_request.number }}" - echo "Organization - ${{ github.repository_owner }}" - echo "Repository Name - ${{ github.repository }}" - - - name: Print Job details - run: | - echo "Run ID - ${{ github.run_id }}" - echo "Run No - ${{ github.run_number }}" - echo "Job - ${{ github.job }}" - echo "Job ID - ${{ github.job_id }}" - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.x - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -e . - pip install -r requirements.txt - - - - name: Run git-bob - env: - GIT_BOB_AGENT_NAME: "git-bob" - GIT_BOB_LLM_NAME: "${{ secrets.GIT_BOB_LLM_NAME }}" - ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}" - GOOGLE_API_KEY: "${{ secrets.GOOGLE_API_KEY }}" - OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}" - GH_MODELS_API_KEY: "${{ secrets.GH_MODELS_API_KEY }}" - KISSKI_API_KEY: "${{ secrets.KISSKI_API_KEY }}" - BLABLADOR_API_KEY: "${{ secrets.BLABLADOR_API_KEY }}" - GITHUB_API_KEY: "${{ secrets.GITHUB_TOKEN }}" - GITHUB_RUN_ID: "${{ github.run_id }}" - TWINE_USERNAME: "${{ secrets.TWINE_USERNAME }}" - TWINE_PASSWORD: "${{ secrets.TWINE_PASSWORD }}" - SYSTEM_MESSAGE: | - You are an extremely skilled python developer and data scientist. Your name is git-bob. You are sometimes called github-actions bot. - You can solve programming tasks and review code. - When asked to solve a specific problem, you keep your code changes minimal and only solve the problem at hand. - You cannot retrieve information from other sources but from github.com. - Do not claim anything that you don't know. - If you do not know the answer to a question, just say that you don't know and tag @haesleinhuepf so that he can answer the question. - In case you are asked to review code, you focus on the quality of the code. - VISION_SYSTEM_MESSAGE: | - You are an AI-based vision model with excellent skills when it comes to describing image. When describing an image, you typically explain: - * What is shown in the image. - * If the image shows clearly distinct objects in its channels, these structures are listed for each channel individually. - * You speculate how the image was acquired. - run: | - git-bob github-action ${{ github.repository }} ${{ github.event.pull_request.number }} ${{ github.event.issue.number }} diff --git a/.github/workflows/review-pull-request.yml b/.github/workflows/review-pull-request.yml new file mode 100644 index 00000000..18c7dec0 --- /dev/null +++ b/.github/workflows/review-pull-request.yml @@ -0,0 +1,51 @@ +name: Review Pull Request + +on: + pull_request: + types: [opened, synchronize] + pull_request_review_comment: + types: [ created ] + +jobs: + respond: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Print pull request number + run: | + echo "Pull Request Number - ${{ github.event.pull_request.number }}" + echo "Organization - ${{ github.repository_owner }}" + echo "Repository Name - ${{ github.repository }}" + + - name: Print Job details + run: | + echo "Run ID - ${{ github.run_id }}" + echo "Run No - ${{ github.run_number }}" + echo "Job - ${{ github.job }}" + echo "Job ID - ${{ github.job_id }}" + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: 3.x + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install git-bob + + - name: Run Python + env: + ANTHROPIC_API_KEY: "${{ secrets.ANTHROPIC_API_KEY }}" + GOOGLE_API_KEY: "${{ secrets.GOOGLE_API_KEY }}" + GIT_BOB_LLM_NAME: "${{ secrets.GIT_BOB_LLM_NAME }}" + OPENAI_API_KEY: "${{ secrets.OPENAI_API_KEY }}" + GH_MODELS_API_KEY: "${{ secrets.GH_MODELS_API_KEY }}" + GITHUB_API_KEY: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_RUN_ID: "${{ github.run_id }}" + run: | + git-bob review-pull-request-action ${{ github.repository }} ${{ github.event.pull_request.number }} + From 27242edf77e7e8c9945fe4d2b48383cc0d85501e Mon Sep 17 00:00:00 2001 From: Yixin Huang Date: Mon, 14 Oct 2024 10:03:47 +0200 Subject: [PATCH 09/11] No updates, clean code redundancy --- scripts/auto-add-github-resources.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/scripts/auto-add-github-resources.py b/scripts/auto-add-github-resources.py index e6f044ad..5f57d75b 100644 --- a/scripts/auto-add-github-resources.py +++ b/scripts/auto-add-github-resources.py @@ -50,7 +50,6 @@ def main(): print("Done.", res) - def complete_github_data(github_repo_url): """ Retrieves metadata from the specified GitHub repository with checks for missing fields. @@ -114,8 +113,6 @@ def complete_github_data(github_repo_url): return entry - - def get_publication_date(repo): """ Retrieves the publication date of the repository. If the repository has releases, From fabfcc16587bf6c4bc6b70e41697f4ffa32c709a Mon Sep 17 00:00:00 2001 From: Yixin Huang Date: Tue, 22 Oct 2024 10:41:52 +0200 Subject: [PATCH 10/11] Update scripts/auto-add-github-resources.py Co-authored-by: Robert Haase --- scripts/auto-add-github-resources.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/auto-add-github-resources.py b/scripts/auto-add-github-resources.py index 5f57d75b..99f6041d 100644 --- a/scripts/auto-add-github-resources.py +++ b/scripts/auto-add-github-resources.py @@ -14,7 +14,7 @@ def main(): - issue (int): Issue number containing the GitHub link. Example(local_test): - python auto_add_github_entry.py "username/repo" 123 + python scripts/auto-add-github-resources.py username/repo 123 python auto-add-github-resources.py "nfdi4bioimage/training" 236 """ # Retrieve repository and issue number from command-line arguments From 9369211e39a50a4859613f425a06612b6b22e2a2 Mon Sep 17 00:00:00 2001 From: Yixin Huang Date: Tue, 22 Oct 2024 11:22:15 +0200 Subject: [PATCH 11/11] Make sure the tags and type are not empty --- scripts/auto-add-github-resources.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/scripts/auto-add-github-resources.py b/scripts/auto-add-github-resources.py index 99f6041d..92edba12 100644 --- a/scripts/auto-add-github-resources.py +++ b/scripts/auto-add-github-resources.py @@ -101,12 +101,11 @@ def complete_github_data(github_repo_url): # Publication date (first release date or creation date) entry['publication_date'] = get_publication_date(repo) - # Tags (topics): should we use the repository topics or the README.md file? - topics = repo.get_topics() - entry['tags'] = ", ".join(topics) if topics else "" + # Tags: always add the message "Dear users, please add tags." + entry['tags'] = "Dear users, please add tags." - # Type: how should we determine this for a GitHub repository? - entry['type'] = "" + # Type: Always set this field to "GitHub Repository" + entry['type'] = "GitHub Repository" # Repository URL entry['url'] = github_repo_url @@ -134,4 +133,4 @@ def get_publication_date(repo): if __name__ == "__main__": - main() \ No newline at end of file + main()