Skip to content

Commit 00281aa

Browse files
committed
Try xml based test result analysis
1 parent 2f20912 commit 00281aa

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
working-directory: test
7777

7878
- name: Run tests
79-
run: python -m pytest -ra --tb=short -q 2>&1 | tee ../test-output.txt
79+
run: python -m pytest -ra --tb=short --junitxml=../results.xml
8080
working-directory: test
8181
env:
8282
CPPINTEROP_EXTRA_INTERPRETER_ARGS: "-std=c++${{ matrix.runtime_cxx_standard }}"
@@ -86,7 +86,7 @@ jobs:
8686
uses: actions/upload-artifact@v4
8787
with:
8888
name: result-${{ matrix.os }}-llvm${{ matrix.llvm }}-py${{ matrix.python }}-cpp${{ matrix.runtime_cxx_standard }}
89-
path: test-output.txt
89+
path: results.xml
9090

9191
report:
9292
if: always() && github.event_name == 'pull_request'
@@ -107,16 +107,21 @@ jobs:
107107
108108
const rows = fs.readdirSync('.').filter(d => d.startsWith('result-')).sort().map(d => {
109109
const cfg = d.replace('result-', '');
110-
const file = `${d}/test-output.txt`;
111-
const lines = fs.existsSync(file) ? fs.readFileSync(file, 'utf8').trim().split('\n') : [];
112-
const result = lines.length ? lines.at(-1) : 'no output';
113-
return `| ${cfg} | \`${result}\` |`;
110+
const file = `${d}/results.xml`;
111+
if (!fs.existsSync(file)) return `| ${cfg} | ⚠️ no results |`;
112+
const xml = fs.readFileSync(file, 'utf8');
113+
const attr = (name) => xml.match(new RegExp(`${name}="(\\d+)"`))?.[1] || '0';
114+
const [tests, fail, skip, err, time] = ['tests', 'failures', 'skipped', 'errors', 'time'].map(attr);
115+
const passed = tests - fail - skip - err;
116+
const status = (Number(fail) + Number(err)) > 0 ? '❌' : '✅';
117+
return `| ${status} ${cfg} | ${passed} passed, ${fail} failed, ${skip} skipped, ${err} errors (${time}s) |`;
114118
});
115119
116120
const sha = context.payload.pull_request.head.sha.slice(0, 7);
117121
const time = new Date().toISOString().replace('T', ' ').slice(0, 19) + ' UTC';
118-
const header = `## Test Results\n\`${sha}\` — ${time}`;
119-
const body = [marker, header, '| Configuration | Result |', '|---|---|', ...rows].join('\n');
122+
const body = [marker, `## Test Results`, `\`${sha}\` — ${time}\n`,
123+
'| Configuration | Result |', '|---|---|', ...rows].join('\n');
124+
120125
const { data: comments } = await github.rest.issues.listComments({
121126
...context.repo, issue_number: context.issue.number,
122127
});

0 commit comments

Comments
 (0)