Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

<!--README-end-->
37 changes: 35 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Collaborator

@2bndy5 2bndy5 Nov 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woah! I thought we would fallback to the static binaries for this.

FYI, nushell can convert string to integers:

let version = "${{ inputs.version }}" | into int

And, if you need to convert the integer to a string:

let ver_str = $"v($version)"

That way you can do comparisons like $version >= 13.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README changes should be reverted now that we have backward compatibility.


- 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).
Expand Down Expand Up @@ -377,12 +378,44 @@ 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 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 {
$uv_args = $uv_args | append '-v'
}
^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args ...$cmd

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 {
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
}

- name: Run cpp-linter
id: cpp-linter
Expand Down
Loading