Similar to #158335. pr-code-lint.yml was in progress as a PR when that change landed, so this workflow did not get updated.
113 lines
3.5 KiB
YAML
113 lines
3.5 KiB
YAML
name: "Code lint"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- 'users/**'
|
|
paths:
|
|
- 'clang-tools-extra/clang-tidy/**'
|
|
- '.github/workflows/pr-code-lint.yml'
|
|
|
|
jobs:
|
|
code_linter:
|
|
if: github.repository_owner == 'llvm'
|
|
runs-on: ubuntu-24.04
|
|
defaults:
|
|
run:
|
|
shell: bash
|
|
container:
|
|
image: 'ghcr.io/llvm/ci-ubuntu-24.04:latest'
|
|
timeout-minutes: 60
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
steps:
|
|
- name: Fetch LLVM sources
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
|
with:
|
|
fetch-depth: 2
|
|
|
|
- name: Get changed files
|
|
id: changed-files
|
|
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
|
|
with:
|
|
separator: ","
|
|
skip_initial_fetch: true
|
|
base_sha: 'HEAD~1'
|
|
sha: 'HEAD'
|
|
|
|
- name: Listed files
|
|
env:
|
|
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
|
|
run: |
|
|
echo "Changed files:"
|
|
echo "$CHANGED_FILES"
|
|
|
|
- name: Install clang-tidy
|
|
uses: aminya/setup-cpp@17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
|
|
with:
|
|
clang-tidy: 20.1.8
|
|
|
|
- name: Setup Python env
|
|
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install Python dependencies
|
|
run: python3 -m pip install -r llvm/utils/git/requirements_linting.txt
|
|
|
|
# TODO: create special mapping for 'codegen' targets, for now build predefined set
|
|
# TODO: add entrypoint in 'compute_projects.py' that only adds a project and its direct dependencies
|
|
- name: Configure and CodeGen
|
|
run: |
|
|
git config --global --add safe.directory '*'
|
|
|
|
. <(git diff --name-only HEAD~1...HEAD | python3 .ci/compute_projects.py)
|
|
|
|
if [[ "${projects_to_build}" == "" ]]; then
|
|
echo "No projects to analyze"
|
|
exit 0
|
|
fi
|
|
|
|
cmake -G Ninja \
|
|
-B build \
|
|
-S llvm \
|
|
-DLLVM_ENABLE_ASSERTIONS=OFF \
|
|
-DLLVM_ENABLE_PROJECTS="${projects_to_build}" \
|
|
-DCMAKE_CXX_COMPILER=clang++ \
|
|
-DCMAKE_C_COMPILER=clang \
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
|
|
-DLLVM_INCLUDE_TESTS=OFF \
|
|
-DCLANG_INCLUDE_TESTS=OFF \
|
|
-DCMAKE_BUILD_TYPE=Release
|
|
|
|
ninja -C build \
|
|
clang-tablegen-targets \
|
|
genconfusable # for "ConfusableIdentifierCheck.h"
|
|
|
|
- name: Run code linter
|
|
env:
|
|
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
|
|
run: |
|
|
echo "[]" > comments &&
|
|
python3 llvm/utils/git/code-lint-helper.py \
|
|
--token ${{ secrets.GITHUB_TOKEN }} \
|
|
--issue-number $GITHUB_PR_NUMBER \
|
|
--start-rev HEAD~1 \
|
|
--end-rev HEAD \
|
|
--verbose \
|
|
--changed-files "$CHANGED_FILES"
|
|
|
|
- name: Upload results
|
|
uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 #v4.3.0
|
|
if: always()
|
|
with:
|
|
name: workflow-args
|
|
path: |
|
|
comments
|