CI: limit C++ lint to changed lines.

This commit is contained in:
Jacob Oursland
2025-06-16 22:53:26 -07:00
parent e18b8bdf15
commit 2dbf9d3937
3 changed files with 23 additions and 1 deletions

View File

@@ -63,8 +63,11 @@ jobs:
with: with:
artifactBasename: Lint-${{ github.run_id }} artifactBasename: Lint-${{ github.run_id }}
changedFiles: ${{ needs.Prepare.outputs.changedFiles }} changedFiles: ${{ needs.Prepare.outputs.changedFiles }}
changedLines: ${{ needs.Prepare.outputs.changedLines }}
changedCppFiles: ${{ needs.Prepare.outputs.changedCppFiles }} changedCppFiles: ${{ needs.Prepare.outputs.changedCppFiles }}
changedCppLines: ${{ needs.Prepare.outputs.changedCppLines }}
changedPythonFiles: ${{ needs.Prepare.outputs.changedPythonFiles }} changedPythonFiles: ${{ needs.Prepare.outputs.changedPythonFiles }}
changedPythonLines: ${{ needs.Prepare.outputs.changedPythonLines }}
WrapUp: WrapUp:
needs: [ needs: [

View File

@@ -34,12 +34,21 @@ on:
changedFiles: changedFiles:
type: string type: string
required: true required: true
changedLines:
type: string
required: false
changedCppFiles: changedCppFiles:
type: string type: string
required: true required: true
changedCppLines:
type: string
required: false
changedPythonFiles: changedPythonFiles:
type: string type: string
required: true required: true
changedPythonLines:
type: string
required: false
checkLineendings: checkLineendings:
default: false default: false
type: boolean type: boolean
@@ -317,6 +326,7 @@ jobs:
run: | run: |
python3 tools/lint/clang_tidy.py \ python3 tools/lint/clang_tidy.py \
--files "${{ inputs.changedCppFiles }}" \ --files "${{ inputs.changedCppFiles }}" \
--line-filter '${{ inputs.changedCppLines }}' \
--clang-style "${{ inputs.clangStyle }}" \ --clang-style "${{ inputs.clangStyle }}" \
--log-dir "${{ env.logdir }}" \ --log-dir "${{ env.logdir }}" \
--report-file "${{ env.reportdir }}${{ env.reportfilename }}" --report-file "${{ env.reportdir }}${{ env.reportfilename }}"

View File

@@ -76,6 +76,11 @@ def main():
required=True, required=True,
help="Clang-format style (e.g., 'file' to use .clang-format or a specific style).", help="Clang-format style (e.g., 'file' to use .clang-format or a specific style).",
) )
parser.add_argument(
"--line-filter",
required=False,
help='Line-filter for clang-tidy (i.e. [{"name":"file1.cpp","lines":[[1,3],[5,7]]},...])',
)
args = parser.parse_args() args = parser.parse_args()
init_environment(args) init_environment(args)
@@ -96,7 +101,11 @@ def main():
enabled_checks_log = os.path.join(args.log_dir, "clang-tidy-enabled-checks.log") enabled_checks_log = os.path.join(args.log_dir, "clang-tidy-enabled-checks.log")
write_file(enabled_checks_log, enabled_output) write_file(enabled_checks_log, enabled_output)
clang_cmd = clang_tidy_base_cmd + args.files.split() clang_cmd = clang_tidy_base_cmd
if args.line_filter:
clang_cmd = clang_cmd + [f"--line-filter={args.line_filter}"]
clang_cmd = clang_cmd + args.files.split()
print("clang_cmd = ", clang_cmd)
clang_stdout, clang_stderr, _ = run_command(clang_cmd) clang_stdout, clang_stderr, _ = run_command(clang_cmd)
clang_tidy_output = clang_stdout + clang_stderr clang_tidy_output = clang_stdout + clang_stderr