Skip to content

Commit 2fa2868

Browse files
authored
Merge pull request #2409 from farid-zare/CI
Update codecov.yml
2 parents 260f2b2 + da8d66e commit 2fa2868

File tree

1 file changed

+7
-41
lines changed

1 file changed

+7
-41
lines changed

.github/workflows/codecov.yml

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,51 +18,17 @@ jobs:
1818
1919
- name: Run MATLAB Tests
2020
run: |
21-
matlab -batch "run('cobratoolbox/initCobraToolbox.m'); diary('test_results.txt'); run('cobratoolbox/test/testAll.m'); diary off;"
21+
matlab -batch "run('cobratoolbox/initCobraToolbox.m'); diary('cobratoolbox/test_results.txt'); run('cobratoolbox/test/testAll.m'); diary off;"
2222
2323
- name: Upload Test Report
2424
uses: actions/upload-artifact@v4
2525
with:
2626
name: test-report
27-
path: |
28-
test_results.txt
29-
cobratoolbox/CodeCovTestResults.xml
27+
path: cobratoolbox/test_results.txt # Correct path
3028

31-
# Parse Test Results and Comment on PR using regex
32-
- name: Parse Test Results and Comment on PR
33-
uses: actions/github-script@v5
34-
env:
35-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
- name: Upload Coverage to Codecov
30+
if: always()
31+
uses: codecov/codecov-action@v3
3632
with:
37-
script: |
38-
const fs = require('fs');
39-
const xml = fs.readFileSync('cobratoolbox/CodeCovTestResults.xml', 'utf8');
40-
41-
// Extract data using regex
42-
const passedRegex = /tests="(\d+)" failures="(\d+)" errors="(\d+)" skipped="(\d+)"/;
43-
const matches = passedRegex.exec(xml);
44-
const totalTests = matches[1];
45-
const failures = matches[2];
46-
const errors = matches[3];
47-
const skipped = matches[4];
48-
49-
let summary = `Test Results: Passed: ${totalTests - failures - skipped}, Failed: ${failures}, Errors: ${errors}, Skipped: ${skipped}`;
50-
51-
// Find failed tests
52-
const failedTestsRegex = /<testcase classname="[^"]*" name="([^"]+)"[^>]*>\s*<(error|failure)[^>]*>([^<]*)<\/(error|failure)>/g;
53-
let failedTestDetails = '';
54-
let match;
55-
while ((match = failedTestsRegex.exec(xml)) !== null) {
56-
failedTestDetails += `\n* ${match[1]}: ${match[3]}`;
57-
}
58-
59-
if (failedTestDetails.length > 0) {
60-
summary += `\n\nFailed Tests:${failedTestDetails}`;
61-
}
62-
63-
github.rest.issues.createComment({
64-
issue_number: context.issue.number,
65-
owner: context.repo.owner,
66-
repo: context.repo.repo,
67-
body: summary
68-
});
33+
files: cobratoolbox/CodeCovTestResults.xml # Correct path
34+

0 commit comments

Comments
 (0)