mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-05 23:01:17 +00:00
run_clang_tidy.ps1 had not been run on Windows before. - Run native commands through Invoke-Quiet. Under $ErrorActionPreference = "Stop", Windows PowerShell made CMake's first stderr line fatal, so configure always failed. - Pass the --line-filter name with native separators. clang-tidy matches it against the end of the file's native path, so on Windows every misc-include-cleaner finding was dropped. - Decode subprocess output as UTF-8 and let stdout replace characters it cannot encode. A changed line with text such as 打印 crashed the script under cp1252. - Check VCToolsInstallDir and WindowsSdkDir in VsDevCmd's output before applying it, so a failure names the command to run and leaves the calling shell untouched. - Log the git_commit_hash_header build, use -LiteralPath for logs, and hide VsDevCmd's stderr as build_win.bat does. On every platform, git quotes non-ASCII paths and appends a tab to a +++ header whose path contains a space, and parse_diff dropped both. changed_files and the workflow's changed-files step now pass core.quotePath=false, and parse_diff strips the tab.
90 lines
3.4 KiB
YAML
90 lines
3.4 KiB
YAML
name: clang-tidy
|
|
|
|
# Runs clang-tidy, with the checks in .clang-tidy, over the C++ lines a pull
|
|
# request changes (scripts/clang_tidy_diff.py). The compile database is
|
|
# configured without the precompiled header, so code that only builds because
|
|
# the PCH supplied an include fails here.
|
|
#
|
|
# No paths filter: the job is a required check, and a workflow skipped by a
|
|
# paths filter leaves a required check pending forever. A PR with no C++
|
|
# changes finishes after the first step.
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
- release/*
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
clang_tidy:
|
|
# Branch protection requires this check by name. Renaming the job disables
|
|
# that gate.
|
|
name: clang-tidy
|
|
runs-on: ${{ vars.SELF_HOSTED && 'orca-lnx-server' || 'ubuntu-24.04' }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v7
|
|
with:
|
|
lfs: 'false'
|
|
# The PR merge commit plus its first parent, the base it is diffed against.
|
|
fetch-depth: 2
|
|
|
|
- name: Look for changed C++ files
|
|
id: changes
|
|
run: |
|
|
if git -c core.quotePath=false diff --name-only HEAD^1 -- src tests | grep -qE '\.(cpp|cc|cxx|hpp|h|hxx)$'; then
|
|
echo "cpp=true" >> "$GITHUB_OUTPUT"
|
|
else
|
|
echo "No C++ changes under src/ or tests/."
|
|
fi
|
|
|
|
# Parsing needs the dependency headers, not a build of this PR's deps/, so
|
|
# a PR that changes deps/ falls back to the newest cache main has.
|
|
- name: Restore cached deps
|
|
if: steps.changes.outputs.cpp == 'true'
|
|
uses: actions/cache/restore@v6
|
|
with:
|
|
path: ${{ github.workspace }}/deps/build/OrcaSlicer_dep
|
|
key: linux-clang-cache-orcaslicer_deps-build-${{ hashFiles('deps/**') }}
|
|
restore-keys: linux-clang-cache-orcaslicer_deps-build-
|
|
fail-on-cache-miss: true
|
|
|
|
- name: Apt-Install Dependencies
|
|
if: steps.changes.outputs.cpp == 'true' && !vars.SELF_HOSTED
|
|
uses: ./.github/actions/apt-install-deps
|
|
|
|
- name: Install clang-tidy
|
|
if: steps.changes.outputs.cpp == 'true'
|
|
run: |
|
|
python3 -m venv "$RUNNER_TEMP/clang-tidy"
|
|
"$RUNNER_TEMP/clang-tidy/bin/pip" install --quiet -r scripts/clang_tidy_requirements.txt
|
|
|
|
# DEP_BUILD_DIR is named outright: CMake would otherwise derive it from the build
|
|
# directory's name and look for the dependencies in deps/build-tidy.
|
|
- name: Configure without the precompiled header
|
|
if: steps.changes.outputs.cpp == 'true'
|
|
run: >
|
|
cmake -S . -B build-tidy -G Ninja
|
|
-DCMAKE_BUILD_TYPE=Release
|
|
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
-DSLIC3R_PCH=OFF -DORCA_TOOLS=ON -DBUILD_TESTS=ON
|
|
-DDEP_BUILD_DIR=${{ github.workspace }}/deps/build
|
|
|
|
# The one header the build generates rather than the configure.
|
|
- name: Generate git_commit_hash.h
|
|
if: steps.changes.outputs.cpp == 'true'
|
|
run: cmake --build build-tidy --target git_commit_hash_header
|
|
|
|
- name: Run clang-tidy on the changed lines
|
|
if: steps.changes.outputs.cpp == 'true'
|
|
run: >
|
|
python3 scripts/clang_tidy_diff.py -p build-tidy --base HEAD^1
|
|
--clang-tidy "$RUNNER_TEMP/clang-tidy/bin/clang-tidy" -j "$(nproc)"
|