Skip to content

Commit e15673a

Browse files
Add algorithm comparison test results as PR comment
Co-authored-by: timosachsenberg <5803621+timosachsenberg@users.noreply.github.com>
1 parent de0c92a commit e15673a

1 file changed

Lines changed: 67 additions & 1 deletion

File tree

.github/workflows/python-app.yml

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ on:
1111

1212
permissions:
1313
contents: read
14+
pull-requests: write
1415

1516
jobs:
1617
build:
@@ -194,13 +195,77 @@ jobs:
194195
ls -lh data/1_phosphors_result.idXML || echo "Warning: PhosphoRS reference file not found"
195196
196197
- name: Run algorithm comparison tests
198+
id: algorithm_comparison
197199
run: |
200+
set -o pipefail
198201
# Run algorithm comparison tests to compare new results with reference results
199202
# Tests compare at different thresholds:
200203
# - LucXor: local_flr < 0.01, 0.05, 0.1 (with q-value < 0.01)
201204
# - AScore: AScore >= 3, 15, 20 (with q-value < 0.01)
202205
# - PhosphoRS: site probability > 75%, 90%, 99% (with q-value < 0.01)
203-
pytest tests/test_algorithm_comparison.py -v -s --tb=short --color=yes
206+
pytest tests/test_algorithm_comparison.py -v -s --tb=short --color=no 2>&1 | tee algorithm_comparison_results.txt
207+
208+
- name: Post algorithm comparison results to PR
209+
if: github.event_name == 'pull_request' && always()
210+
uses: actions/github-script@v7
211+
with:
212+
script: |
213+
const fs = require('fs');
214+
const resultsFile = 'algorithm_comparison_results.txt';
215+
216+
if (!fs.existsSync(resultsFile)) {
217+
console.log('Results file not found, skipping comment');
218+
return;
219+
}
220+
221+
let results = fs.readFileSync(resultsFile, 'utf8');
222+
223+
// Truncate if too long (GitHub comments have a limit)
224+
const maxLength = 65000;
225+
if (results.length > maxLength) {
226+
results = results.substring(0, maxLength) + '\n\n... (truncated)';
227+
}
228+
229+
const body = [
230+
'## Algorithm Comparison Test Results',
231+
'',
232+
'<details>',
233+
'<summary>Click to expand test results</summary>',
234+
'',
235+
'```',
236+
results,
237+
'```',
238+
'',
239+
'</details>'
240+
].join('\n');
241+
242+
// Find and update existing comment or create new one
243+
const { data: comments } = await github.rest.issues.listComments({
244+
owner: context.repo.owner,
245+
repo: context.repo.repo,
246+
issue_number: context.issue.number,
247+
});
248+
249+
const botComment = comments.find(comment =>
250+
comment.user.login === 'github-actions[bot]' &&
251+
comment.body.includes('## Algorithm Comparison Test Results')
252+
);
253+
254+
if (botComment) {
255+
await github.rest.issues.updateComment({
256+
owner: context.repo.owner,
257+
repo: context.repo.repo,
258+
comment_id: botComment.id,
259+
body: body
260+
});
261+
} else {
262+
await github.rest.issues.createComment({
263+
owner: context.repo.owner,
264+
repo: context.repo.repo,
265+
issue_number: context.issue.number,
266+
body: body
267+
});
268+
}
204269
205270
- name: Upload test outputs as artifacts
206271
if: always()
@@ -209,6 +274,7 @@ jobs:
209274
name: test-outputs
210275
path: |
211276
test_*.idXML
277+
algorithm_comparison_results.txt
212278
retention-days: 7
213279

214280
- name: Upload coverage to artifacts

0 commit comments

Comments
 (0)