Skip to content

Commit 15a9143

Browse files
committed
update
1 parent 7c9d0d5 commit 15a9143

File tree

6 files changed

+106
-54
lines changed

6 files changed

+106
-54
lines changed
Lines changed: 85 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,99 @@
1-
name: CI Tests with Detailed Report
1+
name: CI Test Report Publisher
2+
description: 'Publishes detailed test reports as GitHub comments with smart updates'
23

34
inputs:
4-
commentBody:
5-
type: string
6-
default: ''
7-
description: Path to summary report html file
8-
5+
comment-body:
6+
description: 'Path to the summary report HTML file'
7+
required: true
8+
default: 'test-results/report.html'
9+
report-title:
10+
description: 'Title for the test report comment'
11+
required: false
12+
default: '🧪 CI Test Summary Report'
13+
max-comment-length:
14+
description: 'Maximum comment length to avoid API limits'
15+
required: false
16+
default: '65536'
917

1018
runs:
1119
using: composite
1220
steps:
13-
- uses: actions/checkout@v4
14-
- name: Post readable test report
15-
shell: bash -xe {0}
21+
- name: Validate inputs
22+
shell: bash
23+
run: |
24+
if [[ ! -f "${{ inputs.comment-body }}" ]]; then
25+
echo "❌ Report file not found: ${{ inputs.comment-body }}"
26+
exit 1
27+
fi
28+
29+
- name: Post test report
30+
shell: bash
31+
env:
32+
REPORT_FILE: "${{ inputs.comment-body }}"
33+
MAX_LENGTH: "${{ inputs.max-comment-length }}"
34+
run: |
35+
# Read and sanitize report content
36+
report_content=$(< "$REPORT_FILE")
37+
38+
# Truncate if exceeding GitHub comment limits
39+
if [ ${#report_content} -gt $MAX_LENGTH ]; then
40+
echo "⚠️ Report content too long, truncating..."
41+
report_content="${report_content:0:$MAX_LENGTH}"
42+
report_content+="\n\n---\n*Report truncated due to length limits*"
43+
fi
44+
45+
# Escape content for JSON
46+
escaped_content=$(jq -R -s -c '.' <<< "$report_content")
47+
48+
echo "escaped_content<<EOF" >> $GITHUB_ENV
49+
echo "$escaped_content" >> $GITHUB_ENV
50+
echo "EOF" >> $GITHUB_ENV
51+
52+
- name: Publish or update comment
1653
uses: actions/github-script@v7
54+
env:
55+
COMMENT_BODY: ${{ env.comment_body }}
1756
with:
1857
script: |
19-
// Read the comment content from a file
20-
const fs = require('fs');
21-
const commentBody = fs.readFileSync('${{ inputs.commentBody }}', 'utf8');
22-
// Get existing comments
23-
const { data: comments } = await github.rest.issues.listComments({
24-
owner: context.repo.owner,
25-
repo: context.repo.repo,
26-
issue_number: context.issue.number,
27-
});
28-
// Find existing bot comment
29-
const existingComment = comments.find(comment =>
30-
comment.user.type === 'Bot' &&
31-
comment.body.includes('# 🧪 CI Test Summary Report')
32-
);
33-
if (existingComment) {
34-
await github.rest.issues.updateComment({
35-
owner: context.repo.owner,
36-
repo: context.repo.repo,
37-
comment_id: existingComment.id,
38-
body: commentBody
39-
});
40-
} else {
41-
await github.rest.issues.createComment({
58+
const { COMMENT_BODY } = process.env;
59+
60+
// Helper function to find bot comments
61+
const findBotComment = async () => {
62+
const { data: comments } = await github.rest.issues.listComments({
4263
owner: context.repo.owner,
4364
repo: context.repo.repo,
4465
issue_number: context.issue.number,
45-
body: commentBody
4666
});
67+
68+
return comments.find(comment =>
69+
comment.user.type === 'Bot' &&
70+
comment.body.includes('${{ inputs.report-title }}')
71+
);
72+
};
73+
74+
try {
75+
const existingComment = await findBotComment();
76+
77+
if (existingComment) {
78+
console.log('📝 Updating existing test report comment');
79+
await github.rest.issues.updateComment({
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
comment_id: existingComment.id,
83+
body: COMMENT_BODY
84+
});
85+
} else {
86+
console.log('💬 Creating new test report comment');
87+
await github.rest.issues.createComment({
88+
owner: context.repo.owner,
89+
repo: context.repo.repo,
90+
issue_number: context.issue.number,
91+
body: COMMENT_BODY
92+
});
93+
}
94+
95+
console.log('✅ Test report published successfully');
96+
} catch (error) {
97+
console.error('❌ Failed to publish test report:', error.message);
98+
throw error;
4799
}

.github/actions/lint-checks/action.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ runs:
88
shell: bash
99
run: |
1010
ci_report=".ci/templates/ci-report.txt"
11-
11+
1212
# Update CI report template
1313
sed -i "s+GITHUB_REPOSITORY+${{ github.repository }}+g;s+GITHUB_RUN_ID+${{ github.run_id }}+g" "${ci_report}"
14-
14+
1515
# Run lint check
1616
export ADDITIONAL_LINTRUNNER_ARGS="--skip CLANGTIDY,CLANGFORMAT,MERGE_CONFLICTLESS_CSV --all-files"
17-
17+
1818
if bash ".github/scripts/lintrunner.sh"; then
1919
sed -i 's+.*Lnit Check.*+|**Lnit Check**|✅|1|100%|N/A|N/A|+' "${ci_report}"
2020
echo "✅ Standard lint check passed"
@@ -31,14 +31,14 @@ runs:
3131
shell: bash
3232
run: |
3333
set -euo pipefail
34-
34+
3535
# Clone PyTorch and setup environment
3636
rm -rf pytorch
3737
git clone https://github.com/pytorch/pytorch pytorch
38-
38+
3939
cd pytorch
4040
cp -r ../torch-xpu-ops third_party/
41-
41+
4242
# Configure and run clang checks
4343
export ADDITIONAL_LINTRUNNER_ARGS="--take CLANGTIDY,CLANGFORMAT \
4444
build/xpu/**/*.* \
@@ -48,9 +48,9 @@ runs:
4848
third_party/torch-xpu-ops/src/**/**/*.* \
4949
third_party/torch-xpu-ops/src/**/**/**/*.*"
5050
export CLANG=1
51-
51+
5252
ci_report="../.ci/templates/ci-report.txt"
53-
53+
5454
if bash "third_party/torch-xpu-ops/.github/scripts/lintrunner.sh"; then
5555
sed -i 's+.*Clang Check.*+|**Clang Check**|✅|1|100%|N/A|N/A|+' "${ci_report}"
5656
echo "✅ Clang lint check passed"

.github/workflows/_linux_e2e_summary.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
if: ${{ github.event_name == 'pull_request' && steps.summary.outputs.performance_regression == 1 }}
9898
uses: ./.github/actions/add-comment
9999
with:
100-
commentBody: './performance.regression.pr.html'
100+
comment-body: './performance.regression.pr.html'
101101
- name: Result check
102102
if: ${{ ! cancelled() }}
103103
run: |

.github/workflows/_performance_comparison.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Setup python
2626
uses: actions/setup-python@v5
2727
with:
28-
python-version: '3.10'
28+
python-version: '3.10'
2929
- name: Checkout torch-xpu-ops
3030
uses: actions/checkout@v4
3131
- name: Downlaod artifacts

.github/workflows/_windows_ut.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ on:
4646

4747
permissions: read-all
4848

49-
env:
49+
env:
5050
USE_XPU: 1
5151
PYTORCH_EXTRA_INSTALL_REQUIREMENTS: >-
5252
intel-cmplr-lib-rt==2025.2.1 |
@@ -156,8 +156,8 @@ jobs:
156156
git config --global core.symlinks true
157157
git config --global core.fsmonitor false
158158
powershell -Command "Set-ItemProperty -Path "HKLM:\\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1"
159-
git status
160-
git show -s
159+
git status
160+
git show -s
161161
git submodule sync && git submodule update --init --recursive
162162
if %TORCH_XPU_OPS_COMMIT% == 'pinned' (
163163
echo "Don't replace torch-xpu-ops!"
@@ -277,7 +277,7 @@ jobs:
277277
REM Check the failure logs
278278
if exist "%GITHUB_WORKSPACE%\failures*.log" (
279279
echo Exist Failure logs
280-
echo Found Failure logs as below:
280+
echo Found Failure logs as below:
281281
for %%f in ("%GITHUB_WORKSPACE%\failures*.log") do (
282282
echo - %%f
283283
copy "%%f" "%GITHUB_WORKSPACE%\ut_log\"

.github/workflows/pull.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ jobs:
2727
steps:
2828
- name: Checkout Repository
2929
uses: actions/checkout@v4
30-
30+
3131
- name: Setup Linting Environment
3232
run: |
3333
sudo apt-get update
3434
sudo apt-get install -y libomp-dev dos2unix
35-
35+
3636
- name: Run Code Quality Checks
3737
id: lint-checks
3838
uses: ./.github/actions/lint-checks
3939

40-
- name: Initialize Test Summary
40+
- name: Publish test report
4141
uses: ./.github/actions/add-comment
4242
with:
43-
commentBody: .ci/templates/ci-report.txt
43+
comment-body: './.ci/templates/ci-report.txt'
4444

4545
conditions-filter:
4646
if: ${{ github.repository_owner == 'intel' && github.event.pull_request.draft == false }}
@@ -58,7 +58,7 @@ jobs:
5858
id: check-files
5959
with:
6060
filters: |
61-
src_changed:
61+
src_changed:
6262
- 'cmake/**'
6363
- 'tools/**'
6464
- 'src/**.cmake'
@@ -153,11 +153,11 @@ jobs:
153153

154154
windows:
155155
name: windows
156-
if: ${{ !(contains(needs.conditions-filter.outputs.disabled_tests, 'disable_all') || contains(needs.conditions-filter.outputs.disabled_tests, 'disable_win')) }}
156+
if: ${{ !(contains(needs.conditions-filter.outputs.disabled_tests, 'disable_all') || contains(needs.conditions-filter.outputs.disabled_tests, 'disable_win')) }}
157157
needs: [conditions-filter, preci-lint-check]
158158
secrets: inherit
159159
uses: ./.github/workflows/_windows_ut.yml
160-
with:
160+
with:
161161
ut: op_extended,test_xpu
162162
runner: Windows_CI
163163
src_changed: ${{ needs.conditions-filter.outputs.src_changed }}

0 commit comments

Comments
 (0)