1+ name : " Code lint"
2+
3+ permissions :
4+ contents : read
5+
6+ on :
7+ pull_request :
8+ branches :
9+ - main
10+ - ' users/**'
11+ - add-clang-tidy-ci
12+ paths :
13+ - ' clang-tools-extra/clang-tidy/**'
14+ - ' .github/workflows/clang-tidy-self-check.yml'
15+
16+ jobs :
17+ code_linter :
18+ # if: github.repository_owner == 'llvm'
19+ runs-on : ubuntu-24.04
20+ container :
21+ image : ' ghcr.io/llvm/ci-ubuntu-24.04:latest'
22+ timeout-minutes : 60
23+ concurrency :
24+ group : ${{ github.workflow }}-${{ github.ref }}
25+ cancel-in-progress : true
26+ steps :
27+ - name : Fetch LLVM sources
28+ uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
29+ with :
30+ fetch-depth : 2
31+
32+ - name : Get changed files
33+ id : changed-files
34+ uses : step-security/changed-files@3dbe17c78367e7d60f00d78ae6781a35be47b4a1 # v45.0.1
35+ with :
36+ separator : " ,"
37+ skip_initial_fetch : true
38+ base_sha : ' HEAD~1'
39+ sha : ' HEAD'
40+
41+ - name : Listed files
42+ env :
43+ CHANGED_FILES : ${{ steps.changed-files.outputs.all_changed_files }}
44+ run : |
45+ echo "Changed files:"
46+ echo "$CHANGED_FILES"
47+
48+ - name : Fetch code linting utils
49+ uses : actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
50+ with :
51+ repository : ${{ github.repository }}
52+ ref : ${{ github.head_ref }} # FIXME: github.base_ref
53+ sparse-checkout : |
54+ llvm/utils/git/code-lint-helper.py
55+ clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
56+ sparse-checkout-cone-mode : false
57+ path : code-lint-tools
58+
59+ # FIXME: add setup of sccache
60+
61+ - name : Setup Python env
62+ uses : actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
63+ with :
64+ python-version : ' 3.11'
65+ cache : ' pip'
66+ cache-dependency-path : ' code-format-tools/llvm/utils/git/requirements_linting.txt'
67+
68+ - name : Install python dependencies
69+ run : pip install -r code-format-tools/llvm/utils/git/requirements_linting.txt
70+
71+ - name : Install clang-tidy
72+ uses : aminya/setup-cpp@17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
73+ with :
74+ clang-tidy : 20.1.8
75+
76+ # FIXME: create special mapping for 'gen' targets, for now build predefined set
77+ - name : Configure and Build
78+ run : |
79+ source <(git diff --name-only HEAD~1..HEAD | python3 .ci/compute_projects.py)
80+
81+ if [[ "${projects_to_build}" == "" ]]; then
82+ echo "No projects to build"
83+ exit 0
84+ fi
85+
86+ echo "Building projects: ${projects_to_build}"
87+ echo "Running project checks targets: ${project_check_targets}"
88+
89+ cmake -G Ninja \
90+ -B build \
91+ -S llvm \
92+ -DLLVM_ENABLE_ASSERTIONS=OFF \
93+ -DLLVM_ENABLE_PROJECTS="${projects_to_build}" \
94+ -DCMAKE_CXX_COMPILER=clang++ \
95+ -DCMAKE_C_COMPILER=clang \
96+ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
97+ -DLLVM_INCLUDE_TESTS=OFF \
98+ -DCLANG_INCLUDE_TESTS=OFF \
99+ -DCMAKE_BUILD_TYPE=Release
100+
101+ ninja -C build clang-tablegen-targets intrinsics_gen genconfusable
102+
103+ - name : Run code linter
104+ env :
105+ CHANGED_FILES : ${{ steps.changed-files.outputs.all_changed_files }}
106+ run : |
107+ echo "[]" > comments &&
108+ python ./code-lint-tools/llvm/utils/git/code-lint-helper.py \
109+ --write-comment-to-file \
110+ --start-rev HEAD~1 \
111+ --end-rev HEAD \
112+ --changed-files "$CHANGED_FILES"
113+
114+ - name : Upload results
115+ uses : actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0
116+ if : always()
117+ with :
118+ name : workflow-args
119+ path : |
120+ comments
0 commit comments