Skip to content

Commit 092ed9e

Browse files
committed
Add CI/CD for linting in CIR
1 parent ab27364 commit 092ed9e

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Clang CIR clang-tidy linting
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_dispatch:
8+
push:
9+
branches:
10+
- 'main'
11+
paths:
12+
- 'clang/lib/CIR/FrontendAction/**'
13+
- '.github/workflows/clang-cir-lint.yml'
14+
pull_request:
15+
branches:
16+
- main
17+
- 'users/**'
18+
paths:
19+
- 'clang/lib/CIR/FrontendAction/**'
20+
- '.github/workflows/clang-cir-lint.yml'
21+
22+
concurrency:
23+
# Skip intermediate builds: always.
24+
# Cancel intermediate builds: only if it is a pull request build.
25+
group: ${{ github.workflow }}-${{ github.ref }}
26+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
27+
28+
jobs:
29+
code_linter:
30+
if: github.repository_owner == 'llvm'
31+
runs-on: ubuntu-24.04
32+
steps:
33+
- name: Fetch LLVM sources
34+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
35+
with:
36+
fetch-depth: 2
37+
38+
- name: Get changed files
39+
id: changed-files
40+
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
41+
with:
42+
separator: ","
43+
skip_initial_fetch: true
44+
base_sha: 'HEAD~1'
45+
sha: 'HEAD'
46+
47+
- name: Listed files
48+
env:
49+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
50+
run: |
51+
echo "Changed files:"
52+
echo "$CHANGED_FILES"
53+
54+
- name: Install clang-tidy
55+
uses: aminya/setup-cpp@17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
56+
with:
57+
clang-tidy: 20.1.8
58+
59+
- name: Setup Python env
60+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
61+
with:
62+
python-version: '3.12'
63+
64+
- name: Configure and CodeGen
65+
run: |
66+
cmake -G Ninja \
67+
-B build \
68+
-S llvm \
69+
-DLLVM_ENABLE_ASSERTIONS=OFF \
70+
-DLLVM_ENABLE_PROJECTS="clang;mlir" \
71+
-DCMAKE_CXX_COMPILER=clang++ \
72+
-DCMAKE_C_COMPILER=clang \
73+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
74+
-DLLVM_INCLUDE_TESTS=OFF \
75+
-DCLANG_INCLUDE_TESTS=OFF \
76+
-DMLIR_INCLUDE_TESTS=OFF \
77+
-DCMAKE_BUILD_TYPE=Release \
78+
-DLLVM_TARGETS_TO_BUILD=host \
79+
-DCLANG_ENABLE_CIR=ON
80+
81+
ninja -C build $(ninja -C build -t targets all | grep IncGen | sed 's/:.*//') clang-tablegen-targets
82+
83+
- name: Run run-clang-tidy
84+
env:
85+
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
86+
run: |
87+
./clang-tools-extra/clang-tidy/tool/run-clang-tidy.py \
88+
-p build "$CHANGED_FILES" \
89+
-checks="-*,readability-identifier-naming" \
90+
-warnings-as-errors="-*,readability-identifier-naming" \
91+
-j $(nproc)

0 commit comments

Comments
 (0)