Skip to content

Commit 7d63127

Browse files
committed
Add always updating report for results
1 parent 7183b2e commit 7d63127

1 file changed

Lines changed: 43 additions & 8 deletions

File tree

.github/workflows/ci.yml

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,46 @@ jobs:
7979
env:
8080
CPPINTEROP_EXTRA_INTERPRETER_ARGS: "-std=c++${{ matrix.runtime_cxx_standard }}"
8181

82-
- name: Post results to PR
83-
if: always() && github.event_name == 'pull_request'
84-
run: |
85-
summary=$(tail -1 test-output.txt)
86-
gh pr comment ${{ github.event.pull_request.number }} \
87-
--body "**LLVM ${{ matrix.llvm }} / Python ${{ matrix.python }} / C++${{ matrix.runtime_cxx_standard }}**: \`${summary}\`"
88-
env:
89-
GH_TOKEN: ${{ github.token }}
82+
- name: Upload result
83+
if: always()
84+
uses: actions/upload-artifact@v4
85+
with:
86+
name: result-${{ matrix.os }}-llvm${{ matrix.llvm }}-py${{ matrix.python }}-cpp${{ matrix.runtime_cxx_standard }}
87+
path: test-output.txt
88+
89+
report:
90+
if: always() && github.event_name == 'pull_request'
91+
needs: build-and-test
92+
runs-on: ubuntu-latest
93+
permissions:
94+
pull-requests: write
95+
steps:
96+
- uses: actions/download-artifact@v4
97+
with:
98+
pattern: result-*
99+
100+
- uses: actions/github-script@v7
101+
with:
102+
script: |
103+
const fs = require('fs');
104+
const marker = '<!-- cppjit-ci -->';
105+
106+
const rows = fs.readdirSync('.').filter(d => d.startsWith('result-')).sort().map(d => {
107+
const cfg = d.replace('result-', '');
108+
const file = `${d}/test-output.txt`;
109+
const lines = fs.existsSync(file) ? fs.readFileSync(file, 'utf8').trim().split('\n') : [];
110+
const result = lines.length ? lines.at(-1) : 'no output';
111+
return `| ${cfg} | \`${result}\` |`;
112+
});
113+
114+
const body = [marker, '## Test Results', '| Configuration | Result |', '|---|---|', ...rows].join('\n');
115+
const { data: comments } = await github.rest.issues.listComments({
116+
...context.repo, issue_number: context.issue.number,
117+
});
118+
const existing = comments.find(c => c.body.startsWith(marker));
119+
120+
if (existing) {
121+
await github.rest.issues.updateComment({ ...context.repo, comment_id: existing.id, body });
122+
} else {
123+
await github.rest.issues.createComment({ ...context.repo, issue_number: context.issue.number, body });
124+
}

0 commit comments

Comments
 (0)