From 1be8da980b7eeb0ff5cb3e942e4fbcd2b75e3c9f Mon Sep 17 00:00:00 2001 From: Henner Zeller Date: Mon, 7 Oct 2024 14:03:09 -0700 Subject: [PATCH] Generate clang-tidy comments in pull requests. Using a github action; see details https://github.com/ZedThree/clang-tidy-review This only runs on changed files, so clang-tidy reports are useful and actionable. --- .github/workflows/continuous-integration.yml | 13 +++++++++++++ xls/fuzzer/run_fuzz.cc | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index a779dc5b3b..2918444cfd 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -42,3 +42,16 @@ jobs: - name: Bazel Test All (opt) run: | bazel test -c opt --noshow_progress --test_output=errors -- //... + + - name: Create compilation DB + run: | + xls/dev_tools/make-compilation-db.sh + ls -l compile_commands.json + + - name: Run clang-tidy on changes and report in PR + uses: ZedThree/clang-tidy-review@v0.19.0 + with: + clang_tidy_version: 17 + config_file: ".clang-tidy" + + id: review diff --git a/xls/fuzzer/run_fuzz.cc b/xls/fuzzer/run_fuzz.cc index 88dd99985b..8d45d3ca7f 100644 --- a/xls/fuzzer/run_fuzz.cc +++ b/xls/fuzzer/run_fuzz.cc @@ -189,9 +189,9 @@ absl::Status RunSample(const Sample& smp, const std::filesystem::path& run_dir, }; // Pass on verbosity flags if available. - if (int64_t verbosity = absl::GetFlag(FLAGS_v); verbosity > 0) { - argv.push_back(absl::StrCat("--v=", verbosity)); - } + if (int64_t verbosity = absl::GetFlag(FLAGS_v); verbosity > 0) + argv.push_back(absl::StrCat("--v=", verbosity)); // testing clang-tidy + if (std::string vmodule = absl::GetFlag(FLAGS_vmodule); !vmodule.empty()) { argv.push_back(absl::StrCat("--vmodule=", absl::GetFlag(FLAGS_vmodule))); }