-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (86 loc) · 3.16 KB
/
ci.yml
File metadata and controls
110 lines (86 loc) · 3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
pull-requests: write
jobs:
test:
runs-on: slopometry-linux-x64
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Full history for git-dependent tests
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Install dependencies
run: uv sync --all-extras
- name: Run linting
run: uv run ruff check src/ tests/
- name: Run tests
run: uv run pytest --cov-report=xml
qpe:
name: Slopometry QPE
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up uv
uses: astral-sh/setup-uv@v4
- name: Install slopometry from checkout
run: uv tool install . --find-links "https://github.com/Droidcraft/rust-code-analysis/releases/expanded_assets/python-2026.1.31"
- name: Run QPE check
id: qpe
run: |
slopometry summoner qpe
echo "json=$(slopometry summoner qpe --json | jq -c)" >> $GITHUB_OUTPUT
- name: Comment on PR
uses: actions/github-script@v7
with:
script: |
const qpe = ${{ steps.qpe.outputs.json }};
const smells = Object.entries(qpe.smell_counts)
.filter(([_, v]) => v > 0)
.sort((a, b) => b[1] - a[1])
.map(([k, v]) => `| ${k.replace(/_/g, ' ')} | ${v} |`)
.join('\n');
const body = `## 📊 Slopometry QPE Report
**QPE Score: ${qpe.qpe.toFixed(4)}**
| Metric | Value | Description |
|--------|-------|-------------|
| MI (normalized) | ${qpe.mi_normalized.toFixed(3)} | Maintainability Index / 100 |
| Smell Penalty | ${qpe.smell_penalty.toFixed(3)} | Weighted code smell deduction |
| Adjusted Quality | ${qpe.adjusted_quality.toFixed(3)} | MI × (1 - smell_penalty) + bonuses |
| Effort Factor | ${qpe.effort_factor.toFixed(2)} | log(Halstead Effort + 1) |
<details>
<summary>Code Smell Breakdown</summary>
| Smell | Count |
|-------|-------|
${smells}
</details>
> Higher QPE = better quality per unit effort`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existing = comments.find(c => c.body.includes('Slopometry QPE Report'));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});
}