Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
84 changes: 29 additions & 55 deletions .github/workflows/points.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
name: Points Allocation
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

name: Contributor Points Tracker

on:
pull_request_review:
types: [submitted]
types: [submitted, edited, dismissed]
issue_comment:
types: [created]
types: [created, edited]
pull_request:
types: [opened, closed, reopened, labeled, unlabeled]
pull_request_review_comment:
types: [created, edited]
issues:
types: [opened, closed, labeled]

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

jobs:
assign-points:
track-points:
runs-on: ubuntu-latest
# Only run for PR reviews or comments on PRs (not regular issues)
# Only run for PR-related events or issue events (not regular issue comments)
if: >
github.event_name == 'pull_request_review' ||
(github.event_name == 'issue_comment' && github.event.issue.pull_request != null)
github.event_name == 'pull_request_review_comment' ||
github.event_name == 'pull_request' ||
github.event_name == 'issues' ||
(github.event_name == 'issue_comment' && github.event.issue.pull_request)
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
ref: ${{ github.event.repository.default_branch }}

- name: Set up Python
uses: actions/setup-python@v5
Expand All @@ -33,51 +45,13 @@ jobs:
cache: 'pip'

- name: Install dependencies
run: pip install PyYAML

- name: Run points script
id: assign_points
run: |
set +e # Don't exit on error
python scripts/assign_points.py
exit_code=$?
echo "exit_code=$exit_code" >> $GITHUB_OUTPUT

# Exit codes:
# 0 = Success (points awarded)
# 2 = No-op (no points, but not an error)
# 1 or other = Actual error

if [ $exit_code -eq 0 ] || [ $exit_code -eq 2 ]; then
exit 0
else
exit $exit_code
fi

- name: Update leaderboard markdown
if: steps.assign_points.outputs.exit_code == '0'
run: python scripts/update_leaderboard.py
pip install PyYAML requests

- name: Create Pull Request
if: steps.assign_points.outputs.exit_code == '0'
uses: peter-evans/create-pull-request@v6
continue-on-error: true
with:
token: ${{ secrets.GITHUB_TOKEN }}
add: 'leaderboard.json,LEADERBOARD.md'
commit-message: "Update leaderboard"
branch: leaderboard-update-${{ github.run_id }}
delete-branch: true
title: "Update contributor leaderboard"
body: |
## Leaderboard Update

This PR updates the contributor leaderboard based on recent PR review activity.

**Triggered by:** ${{ github.event_name }}
**Run:** ${{ github.run_number }}

Please review and merge to update the leaderboard.
labels: |
leaderboard
automated
- name: Calculate and update points
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_EVENT_PATH: ${{ github.event_path }}
run: python scripts/track_points.py
45 changes: 33 additions & 12 deletions scripts/config_points.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
# Contributor Points Configuration
#
# Scoring is based on actual review actions, not keywords.
# All contributions are valued and tracked automatically.
# This configuration defines point values for various contribution activities.
# Points are calculated automatically by the workflow and displayed in PR comments.
#
# Scoring Rules:
# 1. Any PR review submission = review_submission points (base points)
# 2. Substantial review (100+ characters, excluding whitespace) = detailed_review bonus (additive)
# 3. PR approval (state=approved) = approve_pr bonus (additive)
# 4. PR comment (not a full review) = pr_comment points
# 1. Review submission = base points
# 2. Detailed review (100+ characters) = bonus points (additive)
# 3. PR approval = bonus points (additive)
# 4. PR merged = points for author
# 5. Special labels (bug, priority, docs) = bonus points
# 6. First-time contributor = bonus points
#
# Examples:
# - Simple review with short comment = 5 points
# - Review with detailed comment (100+ characters) = 5 + 5 = 10 points
# - Approved PR = 5 + 3 = 8 points
# - Approved PR with detailed feedback = 5 + 5 + 3 = 13 points
# - Comment on PR (not a review) = 2 points
# - Review with detailed comment (100+ chars) = 10 points (5 + 5)
# - Approved PR with detailed feedback = 13 points (5 + 5 + 3)
# - PR merged with bug fix = 10 points (5 + 5)

points:
# Review & Comment Points
review_submission: 5 # Base points for submitting any PR review
detailed_review: 5 # Bonus for substantial review (100+ characters of feedback)
detailed_review: 5 # Bonus for substantial review (100+ characters)
approve_pr: 3 # Bonus for approving a PR
pr_comment: 2 # Points for commenting on a PR (not a full review)

# PR Author Points
pr_merged: 5 # Points when PR is successfully merged

# Label-Based Bonuses (for PR authors)
bug_fix: 5 # Bonus for fixing bugs
high_priority: 3 # Bonus for high-priority work
critical_bug: 10 # Bonus for critical bug fixes
documentation: 4 # Bonus for documentation contributions
performance_improvement: 6 # Bonus for performance enhancements
security_fix: 15 # Bonus for security fixes

# Special Bonuses
first_time_contributor: 5 # Bonus for first-time contributors

# Future Implementation (not currently calculated)
# speed_bonus_24h: 3 # TODO: Bonus for PRs merged within 24 hours
# test_coverage: 8 # TODO: Bonus for adding comprehensive tests
# mentorship: 10 # TODO: Points for mentoring sessions
# issue_triage: 2 # TODO: Points for triaging issues
Loading