From 6df3a078fcec184a61c10566560a0e8054584852 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 3 Nov 2025 22:43:21 +0200 Subject: [PATCH 1/9] 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/9] 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/9] 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/9] 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 { From 98087f75d0ae994b8a372c19d9879829ba0b94a4 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Mon, 10 Nov 2025 18:26:09 -0800 Subject: [PATCH 5/9] revise README about clang tools' origin --- README.md | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e598fda..ba47e0b 100644 --- a/README.md +++ b/README.md @@ -185,15 +185,25 @@ apt-get install -y libc6 wget lsb-release software-properties-common gnupg Otherwise, [nushell] and/or the LLVM-provided bash script will fail to run. +If installing clang tools fails using the `apt` package manager, then we alteratively try (in order of attempts): + +1. PyPI Packages [clang-tidy][clang-tidy-wheel] and/or [clang-format][clang-format-wheel] +2. Static binaries that we built ourselves; see [cpp-linter/clang-tools-pip] project for more detail. + ### On macOS runners -The specified `version` of `clang-format` and `clang-tidy` is installed via Homebrew. -Failing that, we attempt to use Python wheel that we built ourselves; see [cpp-linter/clang-tools-pip] project for more detail. +The specified `version` of `clang-format` and `clang-tidy` is installed via (in order of attempts): + +1. Homebrew +2. PyPI Packages [clang-tidy][clang-tidy-wheel] and/or [clang-format][clang-format-wheel] +3. Static binaries 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 Python wheels. -See [cpp-linter/clang-tools-pip] project for more detail. +For Windows runners, we use clang tools installed via (in order of attempts): + +1. PyPI Packages [clang-tidy][clang-tidy-wheel] and/or [clang-format][clang-format-wheel] +2. Static binaries that we built ourselves; see [cpp-linter/clang-tools-pip] project for more detail. ## License @@ -203,5 +213,7 @@ The scripts and documentation in this project are released under the [MIT Licens [uv]: https://docs.astral.sh/uv/ [cpp-linter/clang-tools-pip]: https://github.com/cpp-linter/clang-tools-pip [gh-container-syntax]: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#jobsjob_idcontainer +[clang-tidy-wheel]: https://pypi.org/project/clang-tidy +[clang-format-wheel]: https://pypi.org/project/clang-format From a5e258bef28bb226fa0d43947558162d576af88c Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Mon, 10 Nov 2025 18:26:59 -0800 Subject: [PATCH 6/9] revert doc string revision in action.yml --- action.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 013774e..8bf26dd 100644 --- a/action.yml +++ b/action.yml @@ -40,7 +40,6 @@ 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 +376,6 @@ 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_str = "${{ inputs.version }}" if ($version_str | is-empty) { print $"(ansi yellow)Using platform default clang tools \(version not specified)(ansi reset)" @@ -400,6 +398,7 @@ runs: $tools = $tools | append "clang-format" } + print $"\n(ansi purple)Ensuring ($tools | str join " and ") ${{ inputs.version }} are present(ansi reset)" for tool in $tools { print $"Installing ($tool) ($version)" let cmd = if ( From b72d11b82df50ee1739b4c668448d87e01f4723a Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Mon, 10 Nov 2025 18:51:36 -0800 Subject: [PATCH 7/9] compensate when input `version` specifies a path --- action.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 8bf26dd..e0d2193 100644 --- a/action.yml +++ b/action.yml @@ -381,7 +381,18 @@ runs: print $"(ansi yellow)Using platform default clang tools \(version not specified)(ansi reset)" exit 0 } - let version = $version_str | into int + let version = try { + $version_str | into int + } catch { + print "Version is not an integer" + if not ($version_str | path exists) { + print "::error title=Invalid version input::Version must be a blank sting, an integer, or a valid path" + exit 1 + } else { + print $"(ansi yellow)Using custom clang tools installation at path: ($version_str)(ansi reset)" + exit 0 + } + } $uv_args = [run --no-sync --project $action_path --directory (pwd)] if $verbosity { From d4c6a650e9403003f0d3ebe2e7101aa2aebc60e4 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Mon, 10 Nov 2025 19:23:35 -0800 Subject: [PATCH 8/9] fix spelling and make OS detection robust --- action.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/action.yml b/action.yml index e0d2193..5f8f3b5 100644 --- a/action.yml +++ b/action.yml @@ -348,7 +348,7 @@ runs: } print $"\n(ansi purple)Installing uv version ($env.UV_VERSION)(ansi reset)" - let is_windows = (sys host | get 'name') == 'Windows' + let is_windows = (version | get "build_os") | str starts-with "windows" let uv_installer_url = if $is_windows { $"https://astral.sh/uv/($env.UV_VERSION)/install.ps1" } else { @@ -386,7 +386,7 @@ runs: } catch { print "Version is not an integer" if not ($version_str | path exists) { - print "::error title=Invalid version input::Version must be a blank sting, an integer, or a valid path" + print "::error title=Invalid version input::Version must be a blank string, an integer, or a valid path" exit 1 } else { print $"(ansi yellow)Using custom clang tools installation at path: ($version_str)(ansi reset)" @@ -417,7 +417,7 @@ runs: or ( ($version <= 9) and ($tool | str ends-with "format") - and not ((sys host | get 'long_os_version') | str starts-with "Linux") + and not ((version | get "build_os") | str starts-with "linux") ) ) { [clang-tools --tool $tool --install $version] From 454ad2755e5e0241c5ade59c07caa25e876038c6 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Mon, 10 Nov 2025 19:27:48 -0800 Subject: [PATCH 9/9] README rewording about listed clang tools sources --- README.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ba47e0b..b29ae26 100644 --- a/README.md +++ b/README.md @@ -185,14 +185,16 @@ apt-get install -y libc6 wget lsb-release software-properties-common gnupg Otherwise, [nushell] and/or the LLVM-provided bash script will fail to run. -If installing clang tools fails using the `apt` package manager, then we alteratively try (in order of attempts): +If installing clang tools fails using the `apt` package manager, then +we alteratively try the following sources in order: 1. PyPI Packages [clang-tidy][clang-tidy-wheel] and/or [clang-format][clang-format-wheel] 2. Static binaries that we built ourselves; see [cpp-linter/clang-tools-pip] project for more detail. ### On macOS runners -The specified `version` of `clang-format` and `clang-tidy` is installed via (in order of attempts): +The specified `version` of `clang-format` and `clang-tidy` is installed via +the following sources in order (which ever succeeds first): 1. Homebrew 2. PyPI Packages [clang-tidy][clang-tidy-wheel] and/or [clang-format][clang-format-wheel] @@ -200,7 +202,8 @@ The specified `version` of `clang-format` and `clang-tidy` is installed via (in ### On Windows runners -For Windows runners, we use clang tools installed via (in order of attempts): +For Windows runners, we use clang tools installed via +the following sources in order (which ever succeeds first): 1. PyPI Packages [clang-tidy][clang-tidy-wheel] and/or [clang-format][clang-format-wheel] 2. Static binaries that we built ourselves; see [cpp-linter/clang-tools-pip] project for more detail.