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
6 changes: 4 additions & 2 deletions .github/workflows/issue-difficulty.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ jobs:
gh label create "difficulty: medium" --force --color d93f0b --description "Leaderboard: 6 points when the PR closing this is merged"
gh label create "difficulty: low" --force --color 0e8a16 --description "Leaderboard: 3 points when the PR closing this is merged"
gh label create "needs difficulty" --force --color fbca04 --description "Maintainer: add difficulty: hard, medium or low so this can be scored"
gh label create "tracking" --force --color c5def5 --description "Umbrella or announcement issue; not a task, not scored"

- name: Flag or clear this issue
if: github.event_name == 'issues'
env:
ISSUE: ${{ github.event.issue.number }}
run: |
if gh issue view "$ISSUE" --json labels --jq '.labels[].name' | grep -qiE '^difficulty'; then
# Tracking/umbrella issues aren't tasks, so they don't need a difficulty.
if gh issue view "$ISSUE" --json labels --jq '.labels[].name' | grep -qiE '^(difficulty|tracking$)'; then
gh issue edit "$ISSUE" --remove-label "needs difficulty" || true
else
gh issue edit "$ISSUE" --add-label "needs difficulty"
Expand All @@ -54,7 +56,7 @@ jobs:
if: github.event_name == 'workflow_dispatch' && inputs.backfill
run: |
gh issue list --state open --limit 500 --json number,labels \
--jq '.[] | select(([.labels[].name] | map(test("^difficulty"; "i")) | any) | not) | .number' \
--jq '.[] | select(([.labels[].name] | map(test("^(difficulty|tracking$)"; "i")) | any) | not) | .number' \
| while read -r number; do
echo "#$number needs a difficulty label"
gh issue edit "$number" --add-label "needs difficulty"
Expand Down
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ based on the difficulty of the issue they close:
| `difficulty: medium` | 6 |
| `difficulty: low` | 3 |

| Level | Points needed |
|---------|--------------:|
| Level 1 | 100 |
| Level 2 | 50 |
| Level 3 | 25 |
| Level | Points needed |
|--------|--------------:|
| Gold | 100 |
| Silver | 50 |
| Bronze | 25 |

How it works:

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ PRs welcome — see [CONTRIBUTING.md](CONTRIBUTING.md) and
Hackathon? Issues tagged [`hackathon`](https://github.com/secfoo-com/secfoo/issues?q=is%3Aopen+label%3Ahackathon)
are open for contribution, and merged PRs earn points on the
[contributor leaderboard](https://github.com/secfoo-com/secfoo/blob/leaderboard/LEADERBOARD.md)
(10 / 6 / 3 for hard / medium / low issues; levels at 25, 50 and 100).
(10 / 6 / 3 for hard / medium / low issues; Bronze, Silver and Gold at 25, 50 and 100).

<a href="https://github.com/secfoo-com/secfoo/blob/leaderboard/LEADERBOARD.md"><img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fsecfoo-com%2Fsecfoo%2Fleaderboard%2Fbadge.json" alt="Hackathon leaderboard"></a>

Expand Down
8 changes: 4 additions & 4 deletions scripts/leaderboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
difficulty label: ``difficulty: hard`` = 10, ``difficulty: medium`` = 6,
``difficulty: low`` = 3.
* Each issue is scored once, for the first merged PR that closed it.
* Contributors reach Level 3 at 25 points, Level 2 at 50, Level 1 at 100.
* Contributors reach Bronze at 25 points, Silver at 50, Gold at 100.
* Merged PRs that close an issue without a difficulty label earn nothing yet;
they're listed under "Needs a difficulty label" so a maintainer can add one.
The board recomputes from scratch on every run, so late labels count.
Expand Down Expand Up @@ -41,9 +41,9 @@
# Highest level first. A contributor holds the first level whose threshold
# they meet; below the lowest threshold they have no level yet.
LEVELS = [
{"name": "Level 1", "min_points": 100},
{"name": "Level 2", "min_points": 50},
{"name": "Level 3", "min_points": 25},
{"name": "Gold", "min_points": 100},
{"name": "Silver", "min_points": 50},
{"name": "Bronze", "min_points": 25},
]

GRAPHQL_URL = "https://api.github.com/graphql"
Expand Down
14 changes: 7 additions & 7 deletions tests/test_leaderboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ def test_points_and_levels():
assert leaderboard.POINTS == {"hard": 10, "medium": 6, "low": 3}
assert leaderboard.level_for(0) is None
assert leaderboard.level_for(24) is None
assert leaderboard.level_for(25) == "Level 3"
assert leaderboard.level_for(50) == "Level 2"
assert leaderboard.level_for(99) == "Level 2"
assert leaderboard.level_for(100) == "Level 1"
assert leaderboard.next_level_for(30) == {"name": "Level 2", "min_points": 50}
assert leaderboard.level_for(25) == "Bronze"
assert leaderboard.level_for(50) == "Silver"
assert leaderboard.level_for(99) == "Silver"
assert leaderboard.level_for(100) == "Gold"
assert leaderboard.next_level_for(30) == {"name": "Silver", "min_points": 50}
assert leaderboard.next_level_for(150) is None


Expand Down Expand Up @@ -116,7 +116,7 @@ def test_levels_reached():
issues = [issue(100 + i, "difficulty: hard") for i in range(10)]
board = leaderboard.score([pr(1, "alice", "2026-11-08T10:00:00Z", issues)], REPO)
assert board["contributors"][0]["points"] == 100
assert board["contributors"][0]["level"] == "Level 1"
assert board["contributors"][0]["level"] == "Gold"


def test_markdown_badge_and_comment_render():
Expand All @@ -138,7 +138,7 @@ def test_markdown_badge_and_comment_render():
comment = leaderboard.render_pr_comment(board, 1)
assert "+10 points" in comment
assert "alice now has **10 points** (rank #1)." in comment
assert "15 more to reach Level 3" in comment
assert "15 more to reach Bronze" in comment

pending = leaderboard.render_pr_comment(board, 2)
assert "no `difficulty:` label yet" in pending
Expand Down
Loading