Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/reviewer-queue/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Reviewer Bot Configuration
# ===========================
#
# This file contains configuration for the reviewer bot.
# When migrating to a GitHub App, update the bot_name and related settings.

# Bot identity
# ------------
# The name users use to invoke commands (without @)
# When switching to a GitHub App, update this to match the app's name
bot_name: guidelines-bot

# The label that triggers automatic reviewer assignment
coding_guideline_label: "coding guideline"

# File paths
# ----------
# Path to the members file (relative to repo root)
members_file: subcommittee/coding-guidelines/members.md

# Path to the state file (relative to repo root)
state_file: .github/reviewer-queue/state.yml

# Queue settings
# --------------
# Maximum number of recent assignments to keep in history
max_recent_assignments: 20

# Role in members.md that indicates someone should be in the reviewer queue
reviewer_role: Producer

# Review timeline (informational, not enforced)
# ---------------------------------------------
# Number of days a reviewer has to provide initial feedback
review_deadline_days: 14

# GitHub App Migration Notes
# --------------------------
# When ready to migrate to a GitHub App:
#
# 1. Create a GitHub App at https://github.com/settings/apps
# - Name: guidelines-bot (or your preferred name)
# - Permissions needed:
# - Issues: Read & Write
# - Pull requests: Read & Write
# - Contents: Read & Write (for state file updates)
# - Subscribe to events:
# - Issues
# - Pull request
# - Issue comment
#
# 2. Install the app on the repository
#
# 3. Update .github/workflows/reviewer-bot.yml:
# - Add step to generate app token (use actions/create-github-app-token)
# - Use the app token instead of GITHUB_TOKEN
#
# 4. Update bot_name above to match your app's name
#
# 5. The bot will now post comments as the app instead of github-actions[bot]
42 changes: 42 additions & 0 deletions .github/reviewer-queue/state.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Reviewer Queue State
# =====================
# This file is automatically maintained by the reviewer-bot workflow.
# It tracks the round-robin assignment of reviewers for coding guidelines.
#
# You can view this file to see:
# - Who is next up to review
# - Who is currently on a pass-until (vacation/away)
# - Recent assignment history
#
# DO NOT EDIT MANUALLY - changes will be overwritten by the bot.
# Use bot commands instead (see CONTRIBUTING.md for details).

# Last updated timestamp (ISO 8601)
last_updated: null

# Current position in round-robin queue (0-indexed)
# The reviewer at this index will be assigned next
current_index: 0

# Queue of active producers in rotation order
# This list is automatically synced from members.md
# Only members with Role="Producer" are included
queue: []

# Members temporarily excluded from rotation
# They will be automatically re-added to the queue after their return_date
pass_until:
# Example:
# - github: username
# return_date: 2025-02-01
# reason: "Optional reason for being away"
# original_queue_position: 5

# Recent assignments for visibility and debugging
# Keeps the last 20 assignments
recent_assignments:
# Example:
# - github: username
# issue_number: 123
# type: issue # or "pr"
# assigned_at: 2025-01-15T10:30:00Z
94 changes: 94 additions & 0 deletions .github/workflows/reviewer-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
name: Reviewer Bot

on:
# Trigger when issues are opened or labeled
issues:
types: [opened, labeled]

# Trigger when PRs are opened or labeled
# Using pull_request_target to handle PRs from forks with write permissions
pull_request_target:
types: [opened, labeled]

# Trigger on comments for bot commands
issue_comment:
types: [created]

# Allow manual triggering (useful for testing/debugging)
workflow_dispatch:
inputs:
action:
description: 'Action to perform'
required: true
default: 'sync-members'
type: choice
options:
- sync-members
- show-state

permissions:
issues: write
pull-requests: write
contents: write

jobs:
reviewer-bot:
runs-on: ubuntu-latest

# Skip if the comment is from a bot (prevent infinite loops)
if: >
github.event_name != 'issue_comment' ||
github.event.comment.user.type != 'Bot'

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# Need to fetch the full repo to update state file
fetch-depth: 0
# Use a token that can push (default GITHUB_TOKEN works for same-repo)
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install uv
uses: astral-sh/setup-uv@v6

- name: Set up Git for commits
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

- name: Run reviewer bot
id: bot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Pass event context to the script
EVENT_NAME: ${{ github.event_name }}
EVENT_ACTION: ${{ github.event.action }}
# Issue/PR context
ISSUE_NUMBER: ${{ github.event.issue.number || github.event.pull_request.number }}
ISSUE_TITLE: ${{ github.event.issue.title || github.event.pull_request.title }}
ISSUE_AUTHOR: ${{ github.event.issue.user.login || github.event.pull_request.user.login }}
ISSUE_HTML_URL: ${{ github.event.issue.html_url || github.event.pull_request.html_url }}
IS_PULL_REQUEST: ${{ github.event.pull_request != null || (github.event.issue.pull_request != null) }}
# Label context (for labeled events)
LABEL_NAME: ${{ github.event.label.name }}
# Comment context (for issue_comment events)
COMMENT_BODY: ${{ github.event.comment.body }}
COMMENT_AUTHOR: ${{ github.event.comment.user.login }}
COMMENT_ID: ${{ github.event.comment.id }}
# For manual dispatch
MANUAL_ACTION: ${{ github.event.inputs.action }}
# Repository info
REPO_OWNER: ${{ github.repository_owner }}
REPO_NAME: ${{ github.event.repository.name }}
# Labels on the issue/PR (as JSON)
ISSUE_LABELS: ${{ toJson(github.event.issue.labels.*.name || github.event.pull_request.labels.*.name) }}
run: |
uv run python scripts/reviewer_bot.py

- name: Commit state changes
if: steps.bot.outputs.state_changed == 'true'
run: |
git add .github/reviewer-queue/state.yml
git commit -m "chore: update reviewer queue state [skip ci]" || echo "No changes to commit"
git push || echo "No changes to push"
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ dependencies = [
"sphinx-autobuild>=2024.10.3",
"sphinx-needs>=5.1.0",
"sphinx-rtd-theme>=3.0.2",
"requests>=2.31.0",
"pyyaml>=6.0.1",
]

[tool.uv.workspace]
Expand Down Expand Up @@ -46,4 +48,3 @@ allow-dict-calls-with-keyword-arguments = true
dev = [
"ruff>=0.12.3",
]

Loading