|
| 1 | +name: Update CODEOWNERS |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run weekly on Monday at 00:00 UTC |
| 6 | + - cron: '0 0 * * 1' |
| 7 | + workflow_dispatch: # Allow manual triggering |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + pull-requests: write |
| 12 | + |
| 13 | +jobs: |
| 14 | + update-codeowners: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + timeout-minutes: 30 |
| 17 | + env: |
| 18 | + DEPTH: 3 |
| 19 | + MIN_COMMITS: 1 |
| 20 | + DAYS_BACK: 180 |
| 21 | + TOP_N: 5 |
| 22 | + steps: |
| 23 | + - name: Checkout repository |
| 24 | + |
| 25 | + with: |
| 26 | + fetch-depth: 0 # Fetch full history for accurate analysis |
| 27 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 28 | + |
| 29 | + - name: Set up Python |
| 30 | + uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: '3.11' |
| 33 | + |
| 34 | + - name: Run CODEOWNERS analyzer |
| 35 | + env: |
| 36 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + run: | |
| 38 | + python scripts/codeowner_analyzer.py \ |
| 39 | + --output .github/CODEOWNERS \ |
| 40 | + --depth ${{ env.DEPTH }} \ |
| 41 | + --min-commits ${{ env.MIN_COMMITS }} \ |
| 42 | + --days-back ${{ env.DAYS_BACK }} \ |
| 43 | + --top-n ${{ env.TOP_N }} \ |
| 44 | + --allowed-users-file scripts/authorized_codeowner.txt |
| 45 | +
|
| 46 | + - name: Check for changes |
| 47 | + id: check_changes |
| 48 | + run: | |
| 49 | + # Check if CODEOWNERS file is new (unstaged) or has changes |
| 50 | + if git ls-files --error-unmatch .github/CODEOWNERS >/dev/null 2>&1; then |
| 51 | + # File is tracked, check for changes |
| 52 | + if git diff --quiet .github/CODEOWNERS; then |
| 53 | + echo "changed=false" >> $GITHUB_OUTPUT |
| 54 | + echo "No changes detected in CODEOWNERS" |
| 55 | + else |
| 56 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 57 | + echo "Changes detected in CODEOWNERS" |
| 58 | + fi |
| 59 | + else |
| 60 | + # File is untracked (newly created) |
| 61 | + echo "changed=true" >> $GITHUB_OUTPUT |
| 62 | + echo "CODEOWNERS file is new" |
| 63 | + fi |
| 64 | +
|
| 65 | + - name: Create Pull Request |
| 66 | + if: steps.check_changes.outputs.changed == 'true' |
| 67 | + uses: peter-evans/create-pull-request@v7 |
| 68 | + with: |
| 69 | + token: ${{ secrets.FLASHINFER_BOT_TOKEN }} |
| 70 | + committer: flashinfer-bot <[email protected]> |
| 71 | + author: flashinfer-bot <[email protected]> |
| 72 | + commit-message: | |
| 73 | + chore: update CODEOWNERS based on git history |
| 74 | +
|
| 75 | + Auto-generated CODEOWNERS update based on commit activity over the last ${{ env.DAYS_BACK }} days. |
| 76 | +
|
| 77 | + 🤖 Generated with [Claude Code](https://claude.com/claude-code) |
| 78 | +
|
| 79 | + Co-Authored-By: Claude <[email protected]> |
| 80 | + branch: auto-update-codeowners |
| 81 | + base: main |
| 82 | + delete-branch: true |
| 83 | + title: 'chore: Update CODEOWNERS' |
| 84 | + body: | |
| 85 | + ## Summary |
| 86 | +
|
| 87 | + This PR updates the CODEOWNERS file based on git commit history analysis from the last ${{ env.DAYS_BACK }} days. |
| 88 | +
|
| 89 | + ## Changes |
| 90 | +
|
| 91 | + - Updated `.github/CODEOWNERS` with current code ownership based on: |
| 92 | + - Commit frequency |
| 93 | + - File coverage |
| 94 | + - Commit recency |
| 95 | +
|
| 96 | + ## How to Review |
| 97 | +
|
| 98 | + 1. Review the changes to `.github/CODEOWNERS` |
| 99 | + 2. Verify that the assigned owners are appropriate for each module |
| 100 | + 3. Make manual adjustments if needed before merging |
| 101 | +
|
| 102 | + ## Notes |
| 103 | +
|
| 104 | + - This is an automated PR generated weekly |
| 105 | + - Minimum commits threshold: ${{ env.MIN_COMMITS }} |
| 106 | + - Analysis period: ${{ env.DAYS_BACK }} days |
| 107 | + - Directory depth: ${{ env.DEPTH }} levels |
| 108 | + - Top N owners per module: ${{ env.TOP_N }} |
| 109 | +
|
| 110 | + --- |
| 111 | +
|
| 112 | + 🤖 This PR was automatically generated by the [update-codeowners workflow](.github/workflows/update-codeowners.yml) |
| 113 | + labels: | |
| 114 | + automated |
| 115 | + maintenance |
| 116 | + assignees: | |
| 117 | +
|
| 118 | + reviewers: | |
0 commit comments