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
118 changes: 118 additions & 0 deletions .github/workflows/update-codeowners.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Update CODEOWNERS

on:
schedule:
# Run weekly on Monday at 00:00 UTC
- cron: '0 0 * * 1'
workflow_dispatch: # Allow manual triggering

permissions:
contents: write
pull-requests: write

jobs:
update-codeowners:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
DEPTH: 3
MIN_COMMITS: 1
DAYS_BACK: 180
TOP_N: 5
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0 # Fetch full history for accurate analysis
token: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Run CODEOWNERS analyzer
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python scripts/codeowner_analyzer.py \
Comment thread
yzh119 marked this conversation as resolved.
--output .github/CODEOWNERS \
--depth ${{ env.DEPTH }} \
--min-commits ${{ env.MIN_COMMITS }} \
--days-back ${{ env.DAYS_BACK }} \
--top-n ${{ env.TOP_N }} \
--allowed-users-file scripts/authorized_codeowner.txt

Comment on lines +35 to +45
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | πŸ”΄ Critical

Authenticate gh with GH_TOKEN, not just GITHUB_TOKEN

The analyzer calls gh api. In Actions, gh requires GH_TOKEN to be set; relying solely on GITHUB_TOKEN may fail. Set both for clarity. (docs.github.com)

Apply:

       - name: Run CODEOWNERS analyzer
         env:
-          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional, keeps other tooling happy
         run: |
           python scripts/codeowner_analyzer.py \
             --output .github/CODEOWNERS \
             --depth 3 \
             --min-commits 1 \
             --days-back 180 \
             --top-n 5 \
             --allowed-users-file scripts/authorized_codeowner.txt
πŸ€– Prompt for AI Agents
.github/workflows/update-codeowners.yml lines 31-41: the workflow only sets
GITHUB_TOKEN but the codeowner analyzer uses the GitHub CLI which expects
GH_TOKEN; update the env block to also export GH_TOKEN by assigning GH_TOKEN:
${{ secrets.GITHUB_TOKEN }} (so both GITHUB_TOKEN and GH_TOKEN are available to
the run) and ensure the GH_TOKEN line is added alongside the existing
GITHUB_TOKEN entry.

- name: Check for changes
id: check_changes
run: |
# Check if CODEOWNERS file is new (unstaged) or has changes
if git ls-files --error-unmatch .github/CODEOWNERS >/dev/null 2>&1; then
# File is tracked, check for changes
if git diff --quiet .github/CODEOWNERS; then
echo "changed=false" >> $GITHUB_OUTPUT
echo "No changes detected in CODEOWNERS"
else
echo "changed=true" >> $GITHUB_OUTPUT
echo "Changes detected in CODEOWNERS"
fi
else
# File is untracked (newly created)
echo "changed=true" >> $GITHUB_OUTPUT
echo "CODEOWNERS file is new"
fi

- name: Create Pull Request
if: steps.check_changes.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.FLASHINFER_BOT_TOKEN }}
committer: flashinfer-bot <flashinfer-bot@users.noreply.github.com>
author: flashinfer-bot <flashinfer-bot@users.noreply.github.com>
commit-message: |
chore: update CODEOWNERS based on git history

Auto-generated CODEOWNERS update based on commit activity over the last ${{ env.DAYS_BACK }} days.

πŸ€– Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
branch: auto-update-codeowners
Comment on lines +72 to +80
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor

Remove external vendor branding from commit body

Commit message body includes references to β€œClaude Code” and β€œCo-Authored-By: Claude.” Prefer neutral/first‑party wording to avoid brand/legal noise.

           commit-message: |
             chore: update CODEOWNERS based on git history
-
-            Auto-generated CODEOWNERS update based on commit activity over the last 180 days.
-
-            πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
-
-            Co-Authored-By: Claude <noreply@anthropic.com>
+            Auto-generated CODEOWNERS update based on commit activity over the last 180 days.
πŸ“ Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
commit-message: |
chore: update CODEOWNERS based on git history
Auto-generated CODEOWNERS update based on commit activity over the last 180 days.
πŸ€– Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
branch: auto-update-codeowners
commit-message: |
chore: update CODEOWNERS based on git history
Auto-generated CODEOWNERS update based on commit activity over the last 180 days.
branch: auto-update-codeowners
πŸ€– Prompt for AI Agents
.github/workflows/update-codeowners.yml lines 68-76: the autogenerated commit
body includes external vendor branding ("Claude Code" and "Co-Authored-By:
Claude"); remove or replace those references with neutral first‑party wording.
Update the commit-message block to omit the "πŸ€– Generated with [Claude Code]..."
line and remove the "Co-Authored-By" trailer, or replace with a neutral note
like "Auto-generated" and ensure the branch and message remain intact.

base: main
delete-branch: true
title: 'chore: Update CODEOWNERS'
body: |
## Summary

This PR updates the CODEOWNERS file based on git commit history analysis from the last ${{ env.DAYS_BACK }} days.

## Changes

- Updated `.github/CODEOWNERS` with current code ownership based on:
- Commit frequency
- File coverage
- Commit recency

## How to Review

1. Review the changes to `.github/CODEOWNERS`
2. Verify that the assigned owners are appropriate for each module
3. Make manual adjustments if needed before merging

## Notes

- This is an automated PR generated weekly
- Minimum commits threshold: ${{ env.MIN_COMMITS }}
- Analysis period: ${{ env.DAYS_BACK }} days
- Directory depth: ${{ env.DEPTH }} levels
- Top N owners per module: ${{ env.TOP_N }}

---

πŸ€– This PR was automatically generated by the [update-codeowners workflow](.github/workflows/update-codeowners.yml)
labels: |
automated
maintenance
assignees: |

reviewers: |
21 changes: 21 additions & 0 deletions scripts/authorized_codeowner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
aleozlx
Amir-19
Anerudhan
azhurkevich
bkryu
cyx-6
dierksen
IwakuraRein
joker-eph
kahyunnam
kaixih
nv-yunzheq
nvmbreughe
paul841029
Quackens
sergachev
sunggg
ttyio
wenscarl
yongwww
yzh119
Loading