Improve Actions docs and comment accuracy (#755)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
||||
|
||||
# List Open PRs across Ultralytics repositories and auto-merge eligible Dependabot PRs
|
||||
# List Open PRs across Ultralytics repositories and auto-merge eligible GitHub Actions update PRs
|
||||
|
||||
name: Scan PRs
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ AI-powered formatting, labeling, and PR summaries for Python, Swift, and Markdow
|
||||
- **Broken Links Check:** Broken links identified using [Lychee](https://github.com/lycheeverse/lychee)
|
||||
- **PR Summary:** Concise Pull Request summaries generated using AI
|
||||
- **PR Review:** AI-powered code reviews identify critical bugs, security issues, and quality concerns with suggested fixes
|
||||
- **Auto-labeling:** Applies relevant labels to issues and PRs via AI
|
||||
- **Auto-labeling:** Applies relevant labels to issues, PRs, and discussions via AI
|
||||
|
||||
### 🤖 Supported AI Providers
|
||||
|
||||
@@ -55,9 +55,9 @@ The model is auto-detected based on which API key you provide. Override with the
|
||||
|
||||
Triggers on GitHub events to streamline workflows:
|
||||
|
||||
- **Push Events:** Automatically formats code when changes are pushed to `main`
|
||||
- **Pull Requests:** Ensures formatting standards, generates summaries, provides AI reviews, and applies labels
|
||||
- **Issues:** Automatically applies relevant labels using AI
|
||||
- **Discussions:** Automatically applies relevant labels using AI
|
||||
|
||||
### 🔧 Setup
|
||||
|
||||
@@ -74,6 +74,8 @@ name: Ultralytics Actions
|
||||
on:
|
||||
issues:
|
||||
types: [opened]
|
||||
discussion:
|
||||
types: [created]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
types: [opened, closed, synchronize, review_requested]
|
||||
@@ -82,6 +84,7 @@ permissions:
|
||||
contents: write # Modify code in PRs
|
||||
pull-requests: write # Add comments and labels to PRs
|
||||
issues: write # Add comments and labels to issues
|
||||
discussions: write # Add labels to discussions
|
||||
|
||||
jobs:
|
||||
actions:
|
||||
@@ -93,7 +96,7 @@ jobs:
|
||||
token: ${{ secrets.GITHUB_TOKEN }} # Auto-generated token
|
||||
labels: true # Auto-label issues/PRs using AI
|
||||
python: true # Format Python with Ruff
|
||||
python_docstrings: false # Format Python docstrings (default: false)
|
||||
python_docstrings: true # Format Python docstrings (default: true)
|
||||
biome: true # Format JS/TS with Biome (auto-detected via biome.json)
|
||||
prettier: true # Format YAML, JSON, Markdown, CSS
|
||||
swift: false # Format Swift (requires macos-latest)
|
||||
@@ -139,7 +142,7 @@ Free up disk space on GitHub runners by removing unnecessary packages and files.
|
||||
|
||||
### 3. Scan PRs Action
|
||||
|
||||
List open PRs across an organization and auto-merge eligible Dependabot PRs.
|
||||
List open PRs across an organization and auto-merge eligible GitHub Actions update PRs.
|
||||
|
||||
```yaml
|
||||
- uses: ultralytics/actions/scan-prs@main
|
||||
@@ -181,7 +184,7 @@ Ultralytics thrives on community collaboration, and we deeply value your contrib
|
||||
|
||||
Ultralytics offers two licensing options:
|
||||
|
||||
- **AGPL-3.0 License**: An [OSI-approved](https://opensource.org/license/agpl-3.0) open-source license ideal for students, researchers, and enthusiasts who value open collaboration. See the [LICENSE](https://github.com/ultralytics/ultralytics/blob/main/LICENSE) file for details.
|
||||
- **AGPL-3.0 License**: An [OSI-approved](https://opensource.org/license/agpl-3.0) open-source license ideal for students, researchers, and enthusiasts who value open collaboration. See the [LICENSE](https://github.com/ultralytics/actions/blob/main/LICENSE) file for details.
|
||||
- **Enterprise License**: Designed for commercial use, this license allows integrating Ultralytics software and AI models into commercial products without AGPL-3.0's open-source requirements. For enterprise solutions, contact [Ultralytics Licensing](https://www.ultralytics.com/license).
|
||||
|
||||
## 📫 Contact
|
||||
|
||||
+2
-1
@@ -113,7 +113,7 @@ runs:
|
||||
GITHUB_REF: ${{ github.ref }}
|
||||
run: |
|
||||
echo "::group::Install Dependencies"
|
||||
# Install from git branch if testing in ultralytics/actions repo, otherwise from PyPI
|
||||
# Install from current git branch if testing in ultralytics/actions repo, otherwise from GitHub main branch
|
||||
if [ "$GITHUB_REPOSITORY" = "ultralytics/actions" ]; then
|
||||
echo "Installing from git branch: $GITHUB_REF"
|
||||
packages="git+https://github.com/ultralytics/actions@${GITHUB_REF#refs/heads/}"
|
||||
@@ -375,6 +375,7 @@ runs:
|
||||
uses: lycheeverse/[email protected]
|
||||
with:
|
||||
# Check all markdown and html files in repo. Ignores the following status codes to reduce false positives:
|
||||
# - 401(generic, "unauthorized")
|
||||
# - 403(OpenVINO, "forbidden")
|
||||
# - 429(Instagram, "too many requests")
|
||||
# - 500(Zenodo, "cached")
|
||||
|
||||
+2
-1
@@ -11,7 +11,8 @@
|
||||
# │ │ ├── __init__.py
|
||||
# │ │ ├── github_utils.py
|
||||
# │ │ ├── openai_utils.py
|
||||
# │ │ └── common_utils.py
|
||||
# │ │ ├── common_utils.py
|
||||
# │ │ └── version_utils.py
|
||||
# │ ├── dispatch_actions.py
|
||||
# │ ├── first_interaction.py
|
||||
# │ ├── review_pr.py
|
||||
|
||||
@@ -64,7 +64,7 @@ def get_event_content(event) -> tuple[int, str, str, str, str, str, str]:
|
||||
def get_relevant_labels(
|
||||
issue_type: str, title: str, body: str, available_labels: dict, current_labels: list
|
||||
) -> list[str]:
|
||||
"""Determines relevant labels for GitHub issues/discussions using OpenAI."""
|
||||
"""Determines relevant labels for GitHub issues/discussions using AI."""
|
||||
filtered_labels = filter_labels(available_labels, current_labels, is_pr=(issue_type == "pull request"))
|
||||
labels_str = "\n".join(f"- {name}: {description}" for name, description in filtered_labels.items())
|
||||
|
||||
|
||||
+1
-1
@@ -69,7 +69,7 @@ def get_status_checks(rollup):
|
||||
|
||||
|
||||
def run():
|
||||
"""List open PRs across organization and auto-merge eligible Dependabot PRs."""
|
||||
"""List open PRs across organization and auto-merge eligible GitHub Actions update PRs."""
|
||||
org = os.getenv("ORG", "ultralytics")
|
||||
visibility_list = parse_visibility(os.getenv("VISIBILITY", "public"), os.getenv("REPO_VISIBILITY", "public"))
|
||||
filter_config = get_repo_filter(visibility_list)
|
||||
|
||||
@@ -75,7 +75,7 @@ def generate_issue_comment(pr_url, pr_summary, pr_credit, pr_title=""):
|
||||
|
||||
|
||||
def generate_pr_summary(repository, diff_text):
|
||||
"""Generates a concise, professional summary of a PR using OpenAI's API."""
|
||||
"""Generates a concise, professional summary of a PR using the OpenAI or Anthropic API."""
|
||||
prompt, is_large, skipped_files = get_pr_summary_prompt(repository, diff_text)
|
||||
|
||||
messages = [
|
||||
|
||||
@@ -43,7 +43,7 @@ def get_prs_between_tags(event, previous_tag: str, latest_tag: str) -> list:
|
||||
|
||||
prs = []
|
||||
for pr_number in sorted(pr_numbers): # earliest to latest
|
||||
time.sleep(1) # Rate limit: GitHub search API has strict limits
|
||||
time.sleep(1) # Rate limit: space out GitHub REST API requests
|
||||
pr_url = f"{GITHUB_API_URL}/repos/{event.repository}/pulls/{pr_number}"
|
||||
pr_response = event.get(pr_url)
|
||||
if pr_response.status_code == 200:
|
||||
|
||||
@@ -157,7 +157,7 @@ def generate_temp_filename(file_path, index, code_type):
|
||||
|
||||
|
||||
def process_markdown_file(file_path, temp_dir, process_python=True, process_bash=True, verbose=False):
|
||||
"""Processes a Markdown file, extracting code blocks for formatting and updating the original file."""
|
||||
"""Processes a Markdown file, extracting code blocks into temp files and returning the content and file info."""
|
||||
try:
|
||||
markdown_content = Path(file_path).read_text(encoding="utf-8")
|
||||
code_blocks_by_type = extract_code_blocks(markdown_content)
|
||||
|
||||
@@ -75,7 +75,7 @@ def remove_outer_codeblocks(string):
|
||||
|
||||
|
||||
def filter_labels(available_labels: dict, current_labels: list | None = None, is_pr: bool = False) -> dict:
|
||||
"""Filters labels by removing manually-assigned and mutually exclusive labels."""
|
||||
"""Filters labels by removing manually-assigned and mutually exclusive labels, adding an Alert label if absent."""
|
||||
current_labels = current_labels or []
|
||||
filtered = available_labels.copy()
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Dependabot Action
|
||||
|
||||
Update GitHub Actions versions across organization repos with cached version resolution. Designed for private/internal repos where GitHub's built-in Dependabot is not available.
|
||||
Update GitHub Actions versions across organization repos with cached version resolution. Provides centralized, org-wide updates (including private/internal repos) without per-repo Dependabot configuration.
|
||||
|
||||
## Usage
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
name: "Dependabot"
|
||||
author: "Ultralytics"
|
||||
description: "Update GitHub Actions versions across organization repos with cached lookups. Designed for private repos where GitHub Dependabot is not available."
|
||||
description: "Update GitHub Actions versions across organization repos with cached lookups. A centralized alternative to per-repo Dependabot configuration."
|
||||
branding:
|
||||
icon: "refresh-cw"
|
||||
color: "blue"
|
||||
|
||||
+10
-8
@@ -1,11 +1,11 @@
|
||||
# Scan PRs Action
|
||||
|
||||
List open PRs across an organization and auto-merge eligible Dependabot PRs.
|
||||
List open PRs across an organization and auto-merge eligible GitHub Actions update PRs.
|
||||
|
||||
## Features
|
||||
|
||||
- **PR Overview**: Lists all open PRs with age-based categorization (New, Green ≤7d, Yellow ≤30d, Red >30d)
|
||||
- **Auto-merge**: Automatically merges Dependabot PRs that update GitHub Actions workflows when all checks pass
|
||||
- **Auto-merge**: Automatically merges Dependabot and UltralyticsAssistant PRs that update GitHub Actions when no checks have failed
|
||||
- **Console Logging**: Detailed output showing which PRs were found, merged, or skipped with reasons
|
||||
|
||||
## Usage
|
||||
@@ -44,12 +44,14 @@ jobs:
|
||||
|
||||
## Auto-merge Criteria
|
||||
|
||||
Dependabot PRs are automatically merged if they meet ALL criteria:
|
||||
GitHub Actions update PRs are automatically merged if they meet ALL criteria:
|
||||
|
||||
1. Update files in `.github/workflows/` only
|
||||
2. PR is mergeable (no conflicts)
|
||||
3. All status checks passed (SUCCESS, SKIPPED, or NEUTRAL)
|
||||
4. Maximum 1 PR merged per repository per run
|
||||
1. Authored by Dependabot or UltralyticsAssistant
|
||||
2. Title contains `bump` and `/.github/workflows` (a GitHub Actions version bump)
|
||||
3. Update at least one GitHub Actions file (in `.github/workflows/`, or an `action.yml`/`action.yaml`)
|
||||
4. PR is mergeable (no conflicts)
|
||||
5. No status checks in a failed state (`FAILURE`, `ERROR`, `CANCELLED`, `TIMED_OUT`, `ACTION_REQUIRED`, `STARTUP_FAILURE`); pending or absent checks do not block merging
|
||||
6. Maximum 1 PR merged per repository per run
|
||||
|
||||
## Output
|
||||
|
||||
@@ -58,4 +60,4 @@ The action generates a GitHub step summary with:
|
||||
- Total PR count across all repos
|
||||
- PR breakdown by phase (New, Green, Yellow, Red)
|
||||
- Detailed list of PRs per repository
|
||||
- Summary of Dependabot PRs found, merged, and skipped
|
||||
- Summary of GitHub Actions update PRs found, merged, and skipped
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
name: "Scan PRs"
|
||||
author: "Ultralytics"
|
||||
description: "List open PRs and auto-merge eligible Dependabot PRs across organization"
|
||||
description: "List open PRs and auto-merge eligible GitHub Actions update PRs across organization"
|
||||
branding:
|
||||
icon: "git-pull-request"
|
||||
color: "blue"
|
||||
|
||||
Reference in New Issue
Block a user