mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-14 13:56:47 +00:00
Add clang-tidy to Ubuntu images (#5541)
This commit is contained in:
@@ -24,14 +24,15 @@ function Get-ClangToolVersions {
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string] $ToolName,
|
||||
[string] $VersionLineMatcher = "${ToolName} version",
|
||||
[string] $VersionPattern = "\d+\.\d+\.\d+)-"
|
||||
)
|
||||
|
||||
$result = Get-CommandResult "apt list --installed" -Multiline
|
||||
$toolVersions = $result.Output | Where-Object { $_ -match "^${ToolName}-\d+"} | ForEach-Object {
|
||||
$clangCommand = ($_ -Split "/")[0]
|
||||
Invoke-Expression "$clangCommand --version" | Where-Object { $_ -match "${ToolName} version" } | ForEach-Object {
|
||||
$_ -match "${ToolName} version (?<version>${VersionPattern}" | Out-Null
|
||||
Invoke-Expression "$clangCommand --version" | Where-Object { $_ -match "${VersionLineMatcher}" } | ForEach-Object {
|
||||
$_ -match "${VersionLineMatcher} (?<version>${VersionPattern}" | Out-Null
|
||||
$Matches.version
|
||||
}
|
||||
} | Sort-Object {[Version]$_}
|
||||
@@ -41,12 +42,17 @@ function Get-ClangToolVersions {
|
||||
|
||||
function Get-ClangVersions {
|
||||
$clangVersions = Get-ClangToolVersions -ToolName "clang"
|
||||
return "Clang " + $clangVersions
|
||||
return "Clang $clangVersions"
|
||||
}
|
||||
|
||||
function Get-ClangFormatVersions {
|
||||
$clangFormatVersions = Get-ClangToolVersions -ToolName "clang-format"
|
||||
return "Clang-format " + $clangFormatVersions
|
||||
return "Clang-format $clangFormatVersions"
|
||||
}
|
||||
|
||||
function Get-ClangTidyVersions {
|
||||
$clangFormatVersions = Get-ClangToolVersions -ToolName "clang-tidy" -VersionLineMatcher "LLVM version" -VersionPattern "\d+\.\d+\.\d+)"
|
||||
return "Clang-tidy $clangFormatVersions"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ $runtimesList = @(
|
||||
(Get-RubyVersion),
|
||||
(Get-JuliaVersion),
|
||||
(Get-ClangVersions),
|
||||
(Get-ClangFormatVersions)
|
||||
(Get-ClangFormatVersions),
|
||||
(Get-ClangTidyVersions)
|
||||
)
|
||||
|
||||
if ((Test-IsUbuntu18) -or (Test-IsUbuntu20)) {
|
||||
|
||||
@@ -11,7 +11,7 @@ function InstallClang {
|
||||
local version=$1
|
||||
|
||||
echo "Installing clang-$version..."
|
||||
apt-get install -y "clang-$version" "lldb-$version" "lld-$version" "clang-format-$version"
|
||||
apt-get install -y "clang-$version" "lldb-$version" "lld-$version" "clang-format-$version" "clang-tidy-$version"
|
||||
}
|
||||
|
||||
function SetDefaultClang {
|
||||
@@ -21,6 +21,8 @@ function SetDefaultClang {
|
||||
update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${version} 100
|
||||
update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${version} 100
|
||||
update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-${version} 100
|
||||
update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-${version} 100
|
||||
update-alternatives --install /usr/bin/run-clang-tidy run-clang-tidy /usr/bin/run-clang-tidy-${version} 100
|
||||
}
|
||||
|
||||
versions=$(get_toolset_value '.clang.versions[]')
|
||||
|
||||
@@ -120,6 +120,9 @@ Describe "clang" {
|
||||
|
||||
"clang-$ClangVersion --version" | Should -ReturnZeroExitCode
|
||||
"clang++-$ClangVersion --version" | Should -ReturnZeroExitCode
|
||||
"clang-format-$ClangVersion --version" | Should -ReturnZeroExitCode
|
||||
"clang-tidy-$ClangVersion --version" | Should -ReturnZeroExitCode
|
||||
"run-clang-tidy-$ClangVersion --help" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user