Skip to content

Commit 7c9d0d5

Browse files
committed
update lint check
1 parent aef4941 commit 7c9d0d5

File tree

2 files changed

+73
-45
lines changed

2 files changed

+73
-45
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: 'Run Lint Checks'
2+
description: 'Execute code quality and linting checks'
3+
4+
runs:
5+
using: "composite"
6+
steps:
7+
- name: Run Standard Lint Check
8+
shell: bash
9+
run: |
10+
ci_report=".ci/templates/ci-report.txt"
11+
12+
# Update CI report template
13+
sed -i "s+GITHUB_REPOSITORY+${{ github.repository }}+g;s+GITHUB_RUN_ID+${{ github.run_id }}+g" "${ci_report}"
14+
15+
# Run lint check
16+
export ADDITIONAL_LINTRUNNER_ARGS="--skip CLANGTIDY,CLANGFORMAT,MERGE_CONFLICTLESS_CSV --all-files"
17+
18+
if bash ".github/scripts/lintrunner.sh"; then
19+
sed -i 's+.*Lnit Check.*+|**Lnit Check**|✅|1|100%|N/A|N/A|+' "${ci_report}"
20+
echo "✅ Standard lint check passed"
21+
else
22+
sed -i 's+.*Lnit Check.*+|**Lnit Check**|❌|1|0%|N/A|N/A|+' "${ci_report}"
23+
echo "❌ Standard lint check failed"
24+
exit 1
25+
fi
26+
- name: Checkout Repository
27+
uses: actions/checkout@v4
28+
with:
29+
path: torch-xpu-ops
30+
- name: Run Clang-based Lint Check
31+
shell: bash
32+
run: |
33+
set -euo pipefail
34+
35+
# Clone PyTorch and setup environment
36+
rm -rf pytorch
37+
git clone https://github.com/pytorch/pytorch pytorch
38+
39+
cd pytorch
40+
cp -r ../torch-xpu-ops third_party/
41+
42+
# Configure and run clang checks
43+
export ADDITIONAL_LINTRUNNER_ARGS="--take CLANGTIDY,CLANGFORMAT \
44+
build/xpu/**/*.* \
45+
build/xpu/*.* \
46+
third_party/torch-xpu-ops/src/*.* \
47+
third_party/torch-xpu-ops/src/**/*.* \
48+
third_party/torch-xpu-ops/src/**/**/*.* \
49+
third_party/torch-xpu-ops/src/**/**/**/*.*"
50+
export CLANG=1
51+
52+
ci_report="../.ci/templates/ci-report.txt"
53+
54+
if bash "third_party/torch-xpu-ops/.github/scripts/lintrunner.sh"; then
55+
sed -i 's+.*Clang Check.*+|**Clang Check**|✅|1|100%|N/A|N/A|+' "${ci_report}"
56+
echo "✅ Clang lint check passed"
57+
else
58+
sed -i 's+.*Clang Check.*+|**Clang Check**|❌|1|0%|N/A|N/A|+' "${ci_report}"
59+
echo "❌ Clang lint check failed"
60+
exit 1
61+
fi

.github/workflows/pull.yml

Lines changed: 12 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -25,53 +25,20 @@ jobs:
2525
runs-on: ubuntu-24.04
2626
timeout-minutes: 30
2727
steps:
28-
- name: Checkout torch-xpu-ops
28+
- name: Checkout Repository
2929
uses: actions/checkout@v4
30-
with:
31-
path: torch-xpu-ops
32-
- name: Run lint check
33-
run: |
34-
cd ./torch-xpu-ops
35-
lint_script=".github/scripts/lintrunner.sh"
36-
ci_report="${{ github.workspace }}/torch-xpu-ops/.ci/templates/ci-report.txt"
37-
sed -i 's+GITHUB_REPOSITORY+${{ github.repository }}+;s+GITHUB_RUN_ID+${{ github.run_id }}+' ${ci_report}
38-
# Run lint check with proper error handling and reporting
39-
export ADDITIONAL_LINTRUNNER_ARGS="--skip CLANGTIDY,CLANGFORMAT,MERGE_CONFLICTLESS_CSV --all-files"
40-
if bash "$lint_script"; then
41-
sed -i 's+.*Lnit Check.*+|**Lnit Check**|✅|1|100%|N/A|N/A|+' "$ci_report"
42-
echo "Lint check: PASSED"
43-
else
44-
sed -i 's+.*Lnit Check.*+|**Lnit Check**|❌|1|0%|N/A|N/A|+' "$ci_report"
45-
echo "Lint check: FAILED"
46-
exit 1
47-
fi
48-
- name: Run lint check with Clang
30+
31+
- name: Setup Linting Environment
4932
run: |
50-
sudo apt update && sudo apt install -y libomp-dev
51-
rm -rf pytorch
52-
git clone https://github.com/pytorch/pytorch pytorch
53-
cd pytorch && cp -r ../torch-xpu-ops third_party/
54-
export ADDITIONAL_LINTRUNNER_ARGS="--take CLANGTIDY,CLANGFORMAT \
55-
build/xpu/**/*.* \
56-
build/xpu/*.* \
57-
third_party/torch-xpu-ops/src/*.* \
58-
third_party/torch-xpu-ops/src/**/*.* \
59-
third_party/torch-xpu-ops/src/**/**/*.* \
60-
third_party/torch-xpu-ops/src/**/**/**/*.*"
61-
export CLANG=1
62-
# Run lint check with proper error handling and reporting
63-
lint_script="third_party/torch-xpu-ops/.github/scripts/lintrunner.sh"
64-
ci_report="${{ github.workspace }}/torch-xpu-ops/.ci/templates/ci-report.txt"
65-
if bash "$lint_script"; then
66-
sed -i 's+.*Clang Check.*+|**Clang Check**|✅|1|100%|N/A|N/A|+' "$ci_report"
67-
echo "Lint check: PASSED"
68-
else
69-
sed -i 's+.*Clang Check.*+|**Clang Check**|❌|1|0%|N/A|N/A|+' "$ci_report"
70-
echo "Lint check: FAILED"
71-
exit 1
72-
fi
73-
- name: Init test summary result
74-
uses: ./torch-xpu-ops/.github/actions/add-comment
33+
sudo apt-get update
34+
sudo apt-get install -y libomp-dev dos2unix
35+
36+
- name: Run Code Quality Checks
37+
id: lint-checks
38+
uses: ./.github/actions/lint-checks
39+
40+
- name: Initialize Test Summary
41+
uses: ./.github/actions/add-comment
7542
with:
7643
commentBody: .ci/templates/ci-report.txt
7744

0 commit comments

Comments
 (0)