Improve docs, comments, and correctness (#761)

This commit is contained in:
Glenn Jocher
2026-06-05 22:49:03 +02:00
committed by GitHub
parent d3aaee18ca
commit 506b366fe2
11 changed files with 38 additions and 27 deletions
+1
View File
@@ -32,6 +32,7 @@ body:
- "Retry Action"
- "Cleanup Disk Action"
- "Scan PRs Action"
- "Dependabot Action"
- "Python package (`ultralytics-actions`)"
- "Repository documentation / README"
- "Other"
@@ -32,6 +32,7 @@ body:
- "Retry Action"
- "Cleanup Disk Action"
- "Scan PRs Action"
- "Dependabot Action"
- "Python package (`ultralytics-actions`)"
- "Repository documentation / README"
- "Other"
+1
View File
@@ -30,6 +30,7 @@ body:
- "Retry Action"
- "Cleanup Disk Action"
- "Scan PRs Action"
- "Dependabot Action"
- "Python package (`ultralytics-actions`)"
- "Repository documentation / README"
- "Other"
+4 -6
View File
@@ -27,7 +27,7 @@ This repository provides three main components:
## Ultralytics Actions (Main Action)
AI-powered formatting, labeling, and PR summaries for Python, Swift, and Markdown files.
AI-powered formatting, labeling, and PR summaries for Python, Swift, Dart, and Markdown files.
### 📄 Features
@@ -98,7 +98,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }} # Auto-generated token
labels: true # Auto-label issues/PRs using AI
python-version: "3.13" # Optional: set up a specific Python version
python-version: "3.14" # Optional: set up a specific Python version
python: true # Format Python with Ruff
python_docstrings: true # Format Python docstrings (default: true)
biome: true # Format JS/TS with Biome (auto-detected via biome.json)
@@ -172,11 +172,9 @@ Update GitHub Actions versions across organization repositories with cached rele
## Python Package
Install `ultralytics-actions` for programmatic access to action utilities.
Install the `ultralytics-actions` package for programmatic access to action utilities, including all [requirements](https://github.com/ultralytics/actions/blob/main/pyproject.toml), in a [**Python>=3.8**](https://www.python.org/) environment.
[![PyPI - Version](https://img.shields.io/pypi/v/ultralytics-actions?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics-actions/)
[![Ultralytics Downloads](https://static.pepy.tech/badge/ultralytics-actions)](https://clickpy.clickhouse.com/dashboard/ultralytics-actions)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics-actions?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics-actions/)
[![PyPI - Version](https://img.shields.io/pypi/v/ultralytics-actions?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics-actions/) [![Ultralytics Downloads](https://static.pepy.tech/badge/ultralytics-actions)](https://clickpy.clickhouse.com/dashboard/ultralytics-actions) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics-actions?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics-actions/)
```bash
pip install ultralytics-actions
+3 -4
View File
@@ -98,6 +98,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }} # Auto-generated token
labels: true # Auto-label issues/PRs using AI
python-version: "3.14" # Optional: set up a specific Python version
python: true # Format Python with Ruff
python_docstrings: true # Format Python docstrings (default: true)
biome: true # Format JS/TS with Biome (auto-detected via biome.json)
@@ -171,11 +172,9 @@ jobs:
## Python 包
安装 `ultralytics-actions` 以便通过代码使用 action 工具。
在 [**Python>=3.8**](https://www.python.org/) 环境中安装 `ultralytics-actions` 包及其全部[依赖项](https://github.com/ultralytics/actions/blob/main/pyproject.toml),以便通过代码使用 action 工具。
[![PyPI - Version](https://img.shields.io/pypi/v/ultralytics-actions?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics-actions/)
[![Ultralytics Downloads](https://static.pepy.tech/badge/ultralytics-actions)](https://clickpy.clickhouse.com/dashboard/ultralytics-actions)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics-actions?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics-actions/)
[![PyPI - Version](https://img.shields.io/pypi/v/ultralytics-actions?logo=pypi&logoColor=white)](https://pypi.org/project/ultralytics-actions/) [![Ultralytics Downloads](https://static.pepy.tech/badge/ultralytics-actions)](https://clickpy.clickhouse.com/dashboard/ultralytics-actions) [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ultralytics-actions?logo=python&logoColor=gold)](https://pypi.org/project/ultralytics-actions/)
```bash
pip install ultralytics-actions
+1 -5
View File
@@ -84,9 +84,6 @@ inputs:
first_issue_response:
description: "Example response to a new issue"
required: false
first_pr_response:
description: "Example response to a new PR"
required: false
bun_update:
description: "Run bun update to update bun.lock if bun project detected"
required: false
@@ -269,7 +266,7 @@ runs:
codespell \
--builtin clear,rare,informal,en-GB_to_en-US \
--write-changes \
--uri-ignore-words-list * \
--uri-ignore-words-list "*" \
--ignore-regex '\b[a-z]+[A-Z][a-zA-Z]*\b' \
--ignore-words-list "nin,cancelled,MapPin,couldn,grey,writeable,RepResNet,Idenfy,WIT,Smoot,EHR,ROUGE,ALS,Carmel,FPR,Hach,Calle,ore,COO,MOT,crate,nd,ned,strack,dota,ane,segway,fo,gool,winn,commend,bloc,nam,afterall,skelton,goin,cann,CANN" \
--skip "*.pt,*.pth,*.torchscript,*.onnx,*.tflite,*.pb,*.bin,*.param,*.mlmodel,*.engine,*.npy,*.data*,*.csv,*pnnx*,*venv*,*translat*,*lock*,__pycache__*,*.ico,*.jpg,*.png,*.webp,*.avif,*.mp4,*.mov,/runs,/.git,./docs/??/*.md,./docs/mkdocs_??.yml,action.yml"
@@ -296,7 +293,6 @@ runs:
env:
GITHUB_TOKEN: ${{ inputs.token }}
FIRST_ISSUE_RESPONSE: ${{ inputs.first_issue_response }}
FIRST_PR_RESPONSE: ${{ inputs.first_pr_response }}
BRAVE_API_KEY: ${{ inputs.brave_api_key }}
OPENAI_API_KEY: ${{ inputs.openai_api_key }}
ANTHROPIC_API_KEY: ${{ inputs.anthropic_api_key }}
+1 -1
View File
@@ -29,4 +29,4 @@
# ├── test_summarize_pr.py
# └── ...
__version__ = "0.2.15"
__version__ = "0.2.16"
+11 -1
View File
@@ -2,6 +2,8 @@
from __future__ import annotations
from urllib.parse import urlparse
from .utils import (
ACTIONS_CREDIT,
GITHUB_API_URL,
@@ -41,7 +43,15 @@ def generate_merge_message(pr_summary, pr_credit, pr_url):
def generate_issue_comment(pr_url, pr_summary, pr_credit, pr_title=""):
"""Generates personalized issue comment based on PR context."""
repo_parts = pr_url.split("/repos/")[1].split("/pulls/")[0] if "/repos/" in pr_url else ""
# pr_url is the GraphQL PullRequest.url HTML URL (https://github.com/owner/repo/pull/N) in production;
# REST API URLs (https://api.github.com/repos/owner/repo/pulls/N) are also supported
parsed = urlparse(pr_url)
if "/repos/" in pr_url and "/pulls/" in pr_url:
repo_parts = pr_url.split("/repos/", 1)[1].split("/pulls/", 1)[0]
elif parsed.hostname == "github.com" and "/pull/" in parsed.path:
repo_parts = parsed.path.lstrip("/").split("/pull/", 1)[0]
else:
repo_parts = ""
owner_repo = repo_parts.split("/")
repo_name = owner_repo[-1] if len(owner_repo) > 1 else "package"
+1 -1
View File
@@ -235,7 +235,7 @@ def get_response(
}
if system_content:
data["system"] = system_content
# Skip web_search for Anthropic when using JSON schema (causes empty responses)
# Tools (web_search) are not forwarded to Anthropic (caused empty responses with JSON schema)
# Handle structured JSON output for Anthropic
if text_format and text_format.get("format", {}).get("type") == "json_schema":
schema = text_format["format"].get("schema", {})
+1 -1
View File
@@ -33,7 +33,7 @@ jobs:
## How It Works
1. Lists all active repos in the org (filtered by visibility)
2. Fetches workflow files (`.github/workflows/*.yml` and `action.yml`) from each repo
2. Fetches GitHub Actions files (`.github/workflows/*.yml`/`*.yaml` and `action.yml`/`action.yaml`) from each repo
3. Parses `uses:` lines and resolves the latest release for each action
4. Creates one PR per outdated action per repo, updating all files that reference it
5. Skips PRs that already exist (matches by title)
+13 -8
View File
@@ -34,12 +34,17 @@ def test_generate_issue_comment(mock_get_response):
"""Test generating issue comments about PR fixes."""
mock_get_response.return_value = "This issue is fixed in PR #123"
comment = generate_issue_comment(
pr_url="https://api.github.com/repos/owner/repo/pulls/123",
pr_summary="Fixed bug",
pr_credit="@testuser",
pr_title="Bug fix PR",
)
for pr_url in ("https://github.com/owner/repo/pull/123", "https://api.github.com/repos/owner/repo/pulls/123"):
comment = generate_issue_comment(
pr_url=pr_url,
pr_summary="Fixed bug",
pr_credit="@testuser",
pr_title="Bug fix PR",
)
assert comment == "This issue is fixed in PR #123"
mock_get_response.assert_called_once()
assert comment == "This issue is fixed in PR #123"
prompt = mock_get_response.call_args[0][0][1]["content"]
assert "pip install -U repo>=VERSION" in prompt
assert "pip install git+https://github.com/owner/repo.git@main" in prompt
assert mock_get_response.call_count == 2