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
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,11 @@ jobs:
- name: Verify Weissman test exists
run: |
grep -q "def test_weissman_score" tests/test_richmack_metrics.py

- name: Print engineering scorecard
if: success()
env:
GH_TOKEN: ${{ github.token }}
SERVESENSE_ACTIVE_HOURS: "3.3"
run: |
./tools/servesense_score.sh
109 changes: 68 additions & 41 deletions tests/test_richmack_metrics.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,84 @@
from tools.richmack_metrics import calculate_metrics
from tools.richmack_metrics import component_scores


def test_weissman_score():
metrics = calculate_metrics(
merged_prs=4,
closed_issues=4,
open_issues=5,
def sample():
return component_scores(
merged_prs=6,
closed_issues=5,
open_issues=4,
open_prs=0,
issue_closure_rate=44.4,
pr_merge_rate=100.0,
roadmap_completion=44.4,
tests_passed=11,
tests_total=11,
ci_success=True,
active_hours=10,
python_files=5,
lines=1500,
functions=50,
test_count=15,
workflow_count=2,
automation_triggers=3,
automation_capabilities=4,
)


def test_complexity_score_is_bounded():
result = sample()

assert 0 <= result["complexity"] <= 10


def test_maintainability_score_is_bounded():
result = sample()

assert 0 <= result["maintainability"] <= 10


def test_throughput_score_is_bounded():
result = sample()

assert 0 <= result["throughput"] <= 10


def test_reliability_score_is_bounded():
result = sample()

assert result["reliability"] == 10.0


def test_velocity_score_is_bounded():
result = sample()

assert 0 <= result["velocity"] <= 10


def test_weissman_score_is_weighted_components():
result = sample()

expected = round(
((1 + 4) * (1 + 4))
/ (1 + 5 + 0),
result["complexity"] * 0.15
+ result["maintainability"] * 0.15
+ result["throughput"] * 0.15
+ result["reliability"] * 0.15
+ result["velocity"] * 0.10
+ result["automation"] * 0.15
+ result["testing"] * 0.15,
2,
)

assert metrics["weissman_score"] == expected
assert result["final_score"] == expected


def test_richmack_score():
metrics = calculate_metrics(
merged_prs=4,
closed_issues=4,
open_issues=5,
open_prs=0,
issue_closure_rate=44.4,
pr_merge_rate=100.0,
roadmap_completion=44.4,
)
def test_score_is_deterministic():
assert sample() == sample()

expected = round(
44.4 * 0.40
+ 100.0 * 0.35
+ 44.4 * 0.25,
1,
)

assert metrics["richmack_score"] == expected
def test_automation_score_is_bounded():
result = sample()

assert 0 <= result["automation"] <= 10

def test_zero_work_does_not_divide_by_zero():
metrics = calculate_metrics(
merged_prs=0,
closed_issues=0,
open_issues=0,
open_prs=0,
issue_closure_rate=0,
pr_merge_rate=0,
roadmap_completion=0,
)

assert metrics["weissman_score"] == 1.0
assert metrics["richmack_score"] == 0.0
def test_testing_score_is_bounded():
result = sample()

assert 0 <= result["testing"] <= 10
Loading
Loading