From 6df3a078fcec184a61c10566560a0e8054584852 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 3 Nov 2025 22:43:21 +0200 Subject: [PATCH 1/4] Switch clang tools from static binaries to wheels --- README.md | 8 +++----- action.yml | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 385f9f4..e598fda 100644 --- a/README.md +++ b/README.md @@ -188,13 +188,12 @@ Otherwise, [nushell] and/or the LLVM-provided bash script will fail to run. ### On macOS runners The specified `version` of `clang-format` and `clang-tidy` is installed via Homebrew. -Failing that, we attempt to use static binaries that we built ourselves; -see [cpp-linter/clang-tools-pip] and [cpp-linter/clang-tools-static-binaries] projects for more detail. +Failing that, we attempt to use Python wheel that we built ourselves; see [cpp-linter/clang-tools-pip] project for more detail. ### On Windows runners -For Windows runners, we only use clang tools built as static binaries. -See [cpp-linter/clang-tools-pip] and [cpp-linter/clang-tools-static-binaries] projects for more detail. +For Windows runners, we only use clang tools Python wheels. +See [cpp-linter/clang-tools-pip] project for more detail. ## License @@ -203,7 +202,6 @@ The scripts and documentation in this project are released under the [MIT Licens [nushell]: https://www.nushell.sh/ [uv]: https://docs.astral.sh/uv/ [cpp-linter/clang-tools-pip]: https://github.com/cpp-linter/clang-tools-pip -[cpp-linter/clang-tools-static-binaries]: https://github.com/cpp-linter/clang-tools-static-binaries [gh-container-syntax]: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idcontainer diff --git a/action.yml b/action.yml index ac154ae..879c35e 100644 --- a/action.yml +++ b/action.yml @@ -40,6 +40,7 @@ inputs: description: | The desired version of the [clang-tools](https://github.com/cpp-linter/clang-tools-pip) to use. Accepted options are strings which can be 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10 or 9. + clang-tidy only supports versions 13 and above. - Set this option to a blank string (`''`) to use the platform's default installed version. - This value can also be a path to where the clang tools are installed (if using a custom install location). @@ -377,7 +378,7 @@ runs: ^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args print $"\n(ansi purple)Ensuring clang-format and clang-tidy ${{ inputs.version }} are present(ansi reset)" - let cmd = [clang-tools -i ${{ inputs.version }} -b] + let cmd = [clang-tools-wheel --tool clang-format --version ${{ inputs.version }}, clang-tools-wheel --tool clang-tidy --version ${{ inputs.version }}] $uv_args = [run --no-sync --project $action_path --directory (pwd)] if $verbosity { $uv_args = $uv_args | append '-v' From b1a59d8ae2c25475a288dfd07e57ce4a6c35e922 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 3 Nov 2025 22:49:48 +0200 Subject: [PATCH 2/4] fix: install clang-format and clang-tidy --- action.yml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 879c35e..16d514c 100644 --- a/action.yml +++ b/action.yml @@ -378,12 +378,15 @@ runs: ^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args print $"\n(ansi purple)Ensuring clang-format and clang-tidy ${{ inputs.version }} are present(ansi reset)" - let cmd = [clang-tools-wheel --tool clang-format --version ${{ inputs.version }}, clang-tools-wheel --tool clang-tidy --version ${{ inputs.version }}] - $uv_args = [run --no-sync --project $action_path --directory (pwd)] - if $verbosity { - $uv_args = $uv_args | append '-v' + let tools = ['clang-format' 'clang-tidy'] + for tool in $tools { + let cmd = [clang-tools-wheel --tool $tool --version ${{ inputs.version }}] + $uv_args = [run --no-sync --project $action_path --directory (pwd)] + if $verbosity { + $uv_args = $uv_args | append '-v' + } + ^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args ...$cmd } - ^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args ...$cmd - name: Run cpp-linter id: cpp-linter From 7653c20ee0ca8c28b0ff314d894643b8c352eb6a Mon Sep 17 00:00:00 2001 From: Xianpeng Shen Date: Mon, 3 Nov 2025 23:30:17 +0200 Subject: [PATCH 3/4] conditionally fallback to static binaries Co-authored-by: Brendan <2bndy5@gmail.com> --- action.yml | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 16d514c..accd67b 100644 --- a/action.yml +++ b/action.yml @@ -378,12 +378,36 @@ runs: ^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args print $"\n(ansi purple)Ensuring clang-format and clang-tidy ${{ inputs.version }} are present(ansi reset)" - let tools = ['clang-format' 'clang-tidy'] + let version = "${{ inputs.version }}" | into int + + $uv_args = [run --no-sync --project $action_path --directory (pwd)] + if $verbosity { + $uv_args = $uv_args | append '-v' + } + + mut tools = [] + if ("${{ inputs.tidy-checks }}" != "-*") { + # clang-tidy is being used + $tools = $tools | append "clang-tidy" + } + if ("${{ inputs.style }}" | is-not-empty) { + # clang-format is being used + $tools = $tools | append "clang-format" + } + for tool in $tools { - let cmd = [clang-tools-wheel --tool $tool --version ${{ inputs.version }}] - $uv_args = [run --no-sync --project $action_path --directory (pwd)] - if $verbosity { - $uv_args = $uv_args | append '-v' + print $"Installing ($tool) ($version)" + let cmd = if ( + (($version < 13) and ($tool | str ends-with "tidy")) + or ( + ($version <= 9) + and ($tool | str ends-with "format") + and not ((sys host | get 'long_os_version') | str starts-with "Linux") + ) + ) { + [clang-tools --tool $tool --install $version] + } else { + [clang-tools-wheel --tool $tool --version $version] } ^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args ...$cmd } From d3e381bd78daf2548d204d7adeb29a28522aff79 Mon Sep 17 00:00:00 2001 From: Xianpeng Shen Date: Tue, 4 Nov 2025 00:15:49 +0200 Subject: [PATCH 4/4] exit step early if using system default version Co-authored-by: Brendan <2bndy5@gmail.com> --- action.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index accd67b..013774e 100644 --- a/action.yml +++ b/action.yml @@ -378,7 +378,12 @@ runs: ^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args print $"\n(ansi purple)Ensuring clang-format and clang-tidy ${{ inputs.version }} are present(ansi reset)" - let version = "${{ inputs.version }}" | into int + let version_str = "${{ inputs.version }}" + if ($version_str | is-empty) { + print $"(ansi yellow)Using platform default clang tools \(version not specified)(ansi reset)" + exit 0 + } + let version = $version_str | into int $uv_args = [run --no-sync --project $action_path --directory (pwd)] if $verbosity {