Skip to content
Closed
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
33 changes: 22 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ inputs:
version:
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 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12 or 11.
Accepted options include major versions like 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12 or 11.

- Set this option to a blank string (`''`) to use the platform's default installed version.
- Semantic version strings like `20.1` or `20.1.7` are also supported.
- This value can also be a path to where the clang tools are installed (if using a custom install location).
required: false
default: '20'
Expand Down Expand Up @@ -384,13 +385,17 @@ runs:
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 string, 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
try {
$version_str | split row '.' | first | into int
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is ok, but it isn't complete semantic version support.

Because it only checks the major version is an int, users could pass in version: 12.x, and none of our install tools support this format.

} catch {
print "Version does not have an integer major component"
if not ($version_str | path exists) {
print "::error title=Invalid version input::Version must be a blank string, an integer, a semantic version string, or a valid path"
exit 1
} else {
print $"(ansi yellow)Using custom clang tools installation at path: ($version_str)(ansi reset)"
exit 0
}
}
}

Expand All @@ -411,7 +416,13 @@ runs:

print $"\n(ansi purple)Ensuring ($tools | str join ' and ') ($version_str) are present(ansi reset)"
for tool in $tools {
print $"Installing ($tool) ($version)"
let installed_tool = $"($tool)-($version_str)"
if not ((which $installed_tool) | is-empty) {
print $"(ansi yellow)Using existing ($installed_tool) from a prior installation source(ansi reset)"
continue
}

print $"Installing ($tool) ($version_str)"
let cmd = if (
(($version < 13) and ($tool | str ends-with "tidy"))
or (
Expand All @@ -420,9 +431,9 @@ runs:
and not ((version | get "build_os") | str starts-with "linux")
)
) {
[clang-tools --tool $tool --install $version]
[clang-tools --tool $tool --install $version_str]
} else {
[clang-tools-wheel --tool $tool --version $version]
[clang-tools-wheel --tool $tool --version $version_str]
}
^$'($env.UV_INSTALL_DIR)/uv' ...$uv_args ...$cmd
}
Expand Down