[Ubuntu] Implement new directories hierarchy (#8627)

This commit is contained in:
Shamil Mubarakshin
2023-11-15 11:36:04 +01:00
committed by GitHub
parent d1f2c9a3be
commit 5d40b1e213
146 changed files with 393 additions and 407 deletions

View File

@@ -0,0 +1,15 @@
Describe "ActionArchiveCache" {
Context "Action archive cache directory not empty" {
It "/opt/actionarchivecache not empty" {
(Get-ChildItem -Path "/opt/actionarchivecache/*.tar.gz" -Recurse).Count | Should -BeGreaterThan 0
}
}
Context "Action tarball not empty" {
$testCases = Get-ChildItem -Path "/opt/actionarchivecache/*.tar.gz" -Recurse | ForEach-Object { @{ ActionTarball = $_.FullName } }
It "<ActionTarball>" -TestCases $testCases {
param ([string] $ActionTarball)
(Get-Item "$ActionTarball").Length | Should -BeGreaterThan 0
}
}
}

View File

@@ -0,0 +1,67 @@
Describe "Android" {
$androidSdkManagerPackages = Get-AndroidPackages
[int]$platformMinVersion = Get-ToolsetValue "android.platform_min_version"
[version]$buildToolsMinVersion = Get-ToolsetValue "android.build_tools_min_version"
[array]$ndkVersions = Get-ToolsetValue "android.ndk.versions"
$ndkFullVersions = $ndkVersions | ForEach-Object { (Get-ChildItem "/usr/local/lib/android/sdk/ndk/${_}.*" | Select-Object -Last 1).Name } | ForEach-Object { "ndk/${_}" }
# Platforms starting with a letter are the preview versions, which is not installed on the image
$platformVersionsList = ($androidSdkManagerPackages | Where-Object { "$_".StartsWith("platforms;") }) -replace 'platforms;android-', '' | Where-Object { $_ -match "^\d" } | Sort-Object -Unique
$platformsInstalled = $platformVersionsList | Where-Object { [int]($_.Split("-")[0]) -ge $platformMinVersion } | ForEach-Object { "platforms/android-${_}" }
$buildToolsList = ($androidSdkManagerPackages | Where-Object { "$_".StartsWith("build-tools;") }) -replace 'build-tools;', ''
$buildTools = $buildToolsList | Where-Object { $_ -match "\d+(\.\d+){2,}$"} | Where-Object { [version]$_ -ge $buildToolsMinVersion } | Sort-Object -Unique |
ForEach-Object { "build-tools/${_}" }
$androidPackages = @(
$platformsInstalled,
$buildTools,
$ndkFullVersions,
(Get-ToolsetValue "android.extra_list" | ForEach-Object { "extras/${_}" }),
(Get-ToolsetValue "android.addon_list" | ForEach-Object { "add-ons/${_}" }),
(Get-ToolsetValue "android.additional_tools" | ForEach-Object { "${_}" })
)
$androidPackages = $androidPackages | ForEach-Object { $_ }
BeforeAll {
function Validate-AndroidPackage {
param (
[Parameter(Mandatory=$true)]
[string]$PackageName
)
# Convert 'm2repository;com;android;support;constraint;constraint-layout-solver;1.0.0-beta1' ->
# 'm2repository/com/android/support/constraint/constraint-layout-solver/1.0.0-beta1'
# 'cmake;3.6.4111459' -> 'cmake/3.6.4111459'
$PackageName = $PackageName.Replace(";", "/")
$targetPath = Join-Path $env:ANDROID_HOME $PackageName
$targetPath | Should -Exist
}
}
Context "SDKManagers" {
$testCases = @(
@{
PackageName = "SDK tools"
Sdkmanager = "$env:ANDROID_HOME/tools/bin/sdkmanager"
},
@{
PackageName = "Command-line tools"
Sdkmanager = "$env:ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager"
}
)
It "Sdkmanager from <PackageName> is available" -TestCases $testCases {
"$Sdkmanager --version" | Should -ReturnZeroExitCode
}
}
Context "Packages" {
$testCases = $androidPackages | ForEach-Object { @{ PackageName = $_ } }
It "<PackageName>" -TestCases $testCases {
param ([string] $PackageName)
Validate-AndroidPackage $PackageName
}
}
}

View File

@@ -0,0 +1,59 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
$cmd = (Get-ToolsetContent).apt.cmd_packages + (Get-ToolsetContent).apt.vital_packages
Describe "Apt" {
$testCases = $cmd | ForEach-Object {
@{ toolName = $_ }
}
It "<toolName> is available" -TestCases $testCases {
if ($toolName -eq "acl")
{
$toolName = "getfacl"
}
if ($toolName -eq "aria2")
{
$toolName = "aria2c"
}
if ($toolName -eq "p7zip-full")
{
$toolName = "p7zip"
}
if ($toolName -eq "subversion")
{
$toolName = "svn"
}
if ($toolName -eq "sphinxsearch")
{
$toolName = "searchd"
}
if ($toolName -eq "binutils")
{
$toolName = "strings"
}
if ($toolName -eq "coreutils")
{
$toolName = "tr"
}
if ($toolName -eq "net-tools")
{
$toolName = "netstat"
}
if ($toolName -eq "mercurial")
{
$toolName = "hg"
}
(Get-Command -Name $toolName).CommandType | Should -BeExactly "Application"
}
}

View File

@@ -0,0 +1,41 @@
Describe "Firefox" {
It "Firefox" {
"firefox --version" | Should -ReturnZeroExitCode
}
It "Geckodriver" {
"geckodriver --version" | Should -ReturnZeroExitCode
}
}
Describe "Chrome" {
It "Chrome" {
"google-chrome --version" | Should -ReturnZeroExitCode
}
It "Chrome Driver" {
"chromedriver --version" | Should -ReturnZeroExitCode
}
It "Chrome and Chrome Driver major versions are the same" {
$chromeMajor = (google-chrome --version).Trim("Google Chrome ").Split(".")[0]
$chromeDriverMajor = (chromedriver --version).Trim("ChromeDriver ").Split(".")[0]
$chromeMajor | Should -BeExactly $chromeDriverMajor
}
}
Describe "Edge" {
It "Edge" {
"microsoft-edge --version" | Should -ReturnZeroExitCode
}
It "Edge Driver" {
"msedgedriver --version" | Should -ReturnZeroExitCode
}
}
Describe "Chromium" {
It "Chromium" {
"chromium-browser --version" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,56 @@
Describe "Azure CLI" {
It "Azure CLI" {
"az --version" | Should -ReturnZeroExitCode
}
}
Describe "Azure DevOps CLI" {
It "az devops" {
"az devops -h" | Should -ReturnZeroExitCode
}
}
Describe "Aliyun CLI" {
It "Aliyun CLI" {
"aliyun version" | Should -ReturnZeroExitCode
}
}
Describe "AWS" {
It "AWS CLI" {
"aws --version" | Should -ReturnZeroExitCode
}
It "Session Manager Plugin for the AWS CLI" {
session-manager-plugin 2>&1 | Out-String | Should -Match "plugin was installed successfully"
}
It "AWS SAM CLI" {
"sam --version" | Should -ReturnZeroExitCode
}
}
Describe "GitHub CLI" {
It "gh cli" {
"gh --version" | Should -ReturnZeroExitCode
}
}
Describe "Google Cloud CLI" {
It "Google Cloud CLI" {
"gcloud --version" | Should -ReturnZeroExitCode
}
}
Describe "OC CLI" {
It "OC CLI" {
"oc version" | Should -ReturnZeroExitCode
}
}
Describe "Oras CLI" {
It "Oras CLI" {
"oras version" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,52 @@
Describe "PHP" {
[array]$testCases = (Get-ToolsetContent).php.versions | ForEach-Object { @{phpVersion = $_} }
It "php <phpVersion>" -TestCases $testCases {
param (
[string] $phpVersion
)
"php$phpVersion --version" | Should -ReturnZeroExitCode
"php-config$phpVersion --version" | Should -ReturnZeroExitCode
"phpize$phpVersion --version" | Should -ReturnZeroExitCode
}
It "PHPUnit" {
"phpunit --version" | Should -ReturnZeroExitCode
}
It "Composer" {
"composer --version" | Should -ReturnZeroExitCode
}
It "Pear" {
"pear" | Should -ReturnZeroExitCode
}
It "Pecl" {
"pecl" | Should -ReturnZeroExitCode
}
}
Describe "Swift" {
It "swift" {
"swift --version" | Should -ReturnZeroExitCode
}
It "swiftc" {
"swiftc --version" | Should -ReturnZeroExitCode
}
It "libsourcekitd" {
"/usr/local/lib/libsourcekitdInProc.so" | Should -Exist
}
}
Describe "PipxPackages" {
[array]$testCases = (Get-ToolsetContent).pipx | ForEach-Object { @{package=$_.package; cmd = $_.cmd} }
It "<package>" -TestCases $testCases {
"$cmd --version" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,39 @@
Describe "MongoDB" -Skip:(Test-IsUbuntu22) {
It "<ToolName>" -TestCases @(
@{ ToolName = "mongo" }
@{ ToolName = "mongod" }
) {
$toolsetVersion = (Get-ToolsetContent).mongodb.version
(&$ToolName --version)[2].Split('"')[-2] | Should -BeLike "$toolsetVersion*"
}
}
Describe "PostgreSQL" {
It "PostgreSQL Service" {
"sudo systemctl start postgresql" | Should -ReturnZeroExitCode
"pg_isready" | Should -MatchCommandOutput "/var/run/postgresql:5432 - accepting connections"
"sudo systemctl stop postgresql" | Should -ReturnZeroExitCode
}
It "PostgreSQL version should correspond to the version in the toolset" {
$toolsetVersion = (Get-ToolsetContent).postgresql.version
# Client version
(psql --version).split()[-1] | Should -BeLike "$toolsetVersion*"
# Server version
(pg_config --version).split()[-1] | Should -BeLike "$toolsetVersion*"
}
}
Describe "MySQL" {
It "MySQL CLI" {
"mysql -V" | Should -ReturnZeroExitCode
}
It "MySQL Service" {
"sudo systemctl start mysql" | Should -ReturnZeroExitCode
mysql -s -N -h localhost -uroot -proot -e "select count(*) from mysql.user where user='root' and authentication_string is null;" | Should -BeExactly 0
"sudo mysql -vvv -e 'CREATE DATABASE smoke_test' -uroot -proot" | Should -ReturnZeroExitCode
"sudo mysql -vvv -e 'DROP DATABASE smoke_test' -uroot -proot" | Should -ReturnZeroExitCode
"sudo systemctl stop mysql" | Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,42 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1"
Describe "Dotnet and tools" {
BeforeAll {
$env:PATH = "/etc/skel/.dotnet/tools:$($env:PATH)"
$dotnetSDKs = dotnet --list-sdks | ConvertTo-Json
$dotnetRuntimes = dotnet --list-runtimes | ConvertTo-Json
}
$dotnetVersions = (Get-ToolsetContent).dotnet.versions
Context "Default" {
It "Default Dotnet SDK is available" {
"dotnet --version" | Should -ReturnZeroExitCode
}
}
foreach ($version in $dotnetVersions) {
Context "Dotnet $version" {
$dotnet = @{ dotnetVersion = $version }
It "SDK $version is available" -TestCases $dotnet {
$dotnetSDKs | Should -Match "$dotnetVersion.[1-9]*"
}
It "Runtime $version is available" -TestCases $dotnet {
$dotnetRuntimes | Should -Match "$dotnetVersion.[1-9]*"
}
}
}
Context "Dotnet tools" {
$dotnetTools = (Get-ToolsetContent).dotnet.tools
$testCases = $dotnetTools | ForEach-Object { @{ ToolName = $_.name; TestInstance = $_.test }}
It "<ToolName> is available" -TestCases $testCases {
"$TestInstance" | Should -ReturnZeroExitCode
}
}
}

View File

@@ -0,0 +1,38 @@
Describe "Haskell" {
$GHCCommonPath = "/usr/local/.ghcup/ghc"
$GHCVersions = Get-ChildItem -Path $GHCCommonPath | Where-Object { $_.Name -match "\d+\.\d+" }
$testCase = @{ GHCVersions = $GHCVersions }
It "GHC directory contains two version of GHC" -TestCases $testCase {
param ([object] $GHCVersions)
$GHCVersions.Count | Should -Be 2
}
$testCases = $GHCVersions | ForEach-Object { @{ GHCPath = "${_}/bin/ghc"} }
It "GHC version <GHCPath>" -TestCases $testCases {
param ([string] $GHCPath)
"$GHCPath --version" | Should -ReturnZeroExitCode
}
It "GHCup" {
"ghcup --version" | Should -ReturnZeroExitCode
}
It "Default GHC" {
"ghc --version" | Should -ReturnZeroExitCode
}
It "Cabal" {
"cabal --version" | Should -ReturnZeroExitCode
}
It "Stack" {
"stack --version" | Should -ReturnZeroExitCode
}
It "Stack hook is not installed" {
"$HOME/.stack/hooks/ghc-install.sh" | Should -Not -Exist
}
}

View File

@@ -0,0 +1,50 @@
Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" -DisableNameChecking
Describe "Java" {
$toolsetJava = (Get-ToolsetContent).java
$defaultVersion = $toolsetJava.default
$jdkVersions = $toolsetJava.versions
[array]$testCases = $jdkVersions | ForEach-Object { @{Version = $_ } }
It "Java <DefaultJavaVersion> is default" -TestCases @{ DefaultJavaVersion = $defaultVersion } {
$actualJavaPath = Get-EnvironmentVariable "JAVA_HOME"
$expectedJavaPath = Get-EnvironmentVariable "JAVA_HOME_${DefaultJavaVersion}_X64"
$actualJavaPath | Should -Not -BeNullOrEmpty
$expectedJavaPath | Should -Not -BeNullOrEmpty
$actualJavaPath | Should -Be $expectedJavaPath
}
It "<ToolName>" -TestCases @(
@{ ToolName = "java" }
@{ ToolName = "javac" }
@{ ToolName = "mvn" }
@{ ToolName = "ant" }
) {
"$ToolName -version" | Should -ReturnZeroExitCode
}
It "Gradle" {
"gradle -version" | Should -ReturnZeroExitCode
$gradleVariableValue = Get-EnvironmentVariable "GRADLE_HOME"
$gradleVariableValue | Should -BeLike "/usr/share/gradle-*"
$gradlePath = Join-Path $env:GRADLE_HOME "bin/gradle"
"`"$GradlePath`" -version" | Should -ReturnZeroExitCode
}
It "Java <Version>" -TestCases $testCases {
$javaVariableValue = Get-EnvironmentVariable "JAVA_HOME_${Version}_X64"
$javaVariableValue | Should -Not -BeNullOrEmpty
$javaPath = Join-Path $javaVariableValue "bin/java"
"`"$javaPath`" -version" | Should -ReturnZeroExitCode
if ($Version -eq 8) {
$Version = "1.${Version}"
}
"`"$javaPath`" -version" | Should -MatchCommandOutput "openjdk\ version\ `"${Version}(\.[0-9_\.]+)?`""
}
}

View File

@@ -0,0 +1,18 @@
Describe "Node.js" {
$binaries = @("node")
$module_commands = (Get-ToolsetContent).node_modules | ForEach-Object { $_.command }
$testCases = $binaries + $module_commands | ForEach-Object { @{NodeCommand = $_} }
It "<NodeCommand>" -TestCases $testCases {
param (
[string] $NodeCommand
)
"$NodeCommand --version" | Should -ReturnZeroExitCode
}
It "Node.js version should correspond to the version in the toolset" {
node --version | Should -BeLike "v$((Get-ToolsetContent).node.default).*"
}
}

View File

@@ -0,0 +1,62 @@
Describe "PowerShellModules" {
$modules = (Get-ToolsetContent).powershellModules
$withoutVersionsModules = $modules | Where-Object {-not $_.versions} | ForEach-Object {
@{moduleName = $_.name}
}
$withVersionsModules = $modules | Where-Object {$_.versions} | ForEach-Object {
$moduleName = $_.name
$_.versions | ForEach-Object {
@{moduleName = $moduleName; expectedVersion = $_}
}
}
It "<moduleName> is installed" -TestCases $withoutVersionsModules {
Get-Module -Name $moduleName -ListAvailable | Should -BeTrue
}
if ($withVersionsModules) {
It "<moduleName> with <expectedVersion> is installed" -TestCases $withVersionsModules {
(Get-Module -Name $moduleName -ListAvailable).Version -contains $expectedVersion | Should -BeTrue
}
}
}
Describe "AzureModules" {
$modules = (Get-ToolsetContent).azureModules
$modulesRootPath = "/usr/share"
foreach ($module in $modules) {
$moduleName = $module.name
Context "$moduleName" {
foreach ($version in $module.versions) {
$modulePath = Join-Path -Path $modulesRootPath -ChildPath "${moduleName}_${version}"
$moduleInfo = @{ moduleName = $moduleName; modulePath = $modulePath; expectedVersion = $version }
It "<expectedVersion> exists in modules directory" -TestCases $moduleInfo {
$testJob = Start-Job -ScriptBlock {
param (
$modulePath,
$moduleName
)
$env:PSModulePath = "${modulePath}:${env:PSModulePath}"
(Get-Module -ListAvailable -Name $moduleName).Version.ToString()
} -ArgumentList $modulePath, $moduleName
$moduleVersion = $testJob | Wait-Job | Receive-Job
Remove-Job $testJob
$moduleVersion | Should -Match $expectedVersion
}
}
if ($module.default) {
$moduleInfo = @{ moduleName = $moduleName; moduleDefault = $module.default }
It "<moduleDefault> set as default" -TestCases $moduleInfo {
$moduleVersion = (Get-Module -ListAvailable -Name $moduleName).Version.ToString()
$moduleVersion | Should -Match $moduleDefault
}
}
}
}
}

View File

@@ -0,0 +1,3 @@
Import-Module "$PSScriptRoot/../helpers/Tests.Helpers.psm1" -DisableNameChecking
Invoke-PesterTests "*"

View File

@@ -0,0 +1,7 @@
Describe "RunnerCache" {
Context "runner cache directory not empty" {
It "/opt/runner-cache not empty" {
(Get-ChildItem -Path "/opt/runner-cache/*.tar.gz" -Recurse).Count | Should -BeGreaterThan 0
}
}
}

View File

@@ -0,0 +1,417 @@
Describe "azcopy" {
It "azcopy" {
"azcopy --version" | Should -ReturnZeroExitCode
}
It "azcopy10 link exists" {
"azcopy10 --version" | Should -ReturnZeroExitCode
}
}
Describe "Bicep" {
It "Bicep" {
"bicep --version" | Should -ReturnZeroExitCode
}
}
Describe "Rust" {
BeforeAll {
$env:PATH = "/etc/skel/.cargo/bin:/etc/skel/.rustup/bin:$($env:PATH)"
$env:RUSTUP_HOME = "/etc/skel/.rustup"
$env:CARGO_HOME = "/etc/skel/.cargo"
}
It "Rustup is installed" {
"rustup --version" | Should -ReturnZeroExitCode
}
It "Rustc is installed" {
"rustc --version" | Should -ReturnZeroExitCode
}
It "Rustdoc is installed" {
"rustdoc --version" | Should -ReturnZeroExitCode
}
It "Rustfmt is installed" {
"rustfmt --version" | Should -ReturnZeroExitCode
}
Context "Cargo dependencies" {
It "bindgen" {
"bindgen --version" | Should -ReturnZeroExitCode
}
It "cbindgen" {
"cbindgen --version" | Should -ReturnZeroExitCode
}
It "cargo" {
"cargo --version" | Should -ReturnZeroExitCode
}
It "cargo-clippy" {
"cargo-clippy --version" | Should -ReturnZeroExitCode
}
It "Cargo audit" {
"cargo audit --version" | Should -ReturnZeroExitCode
}
It "Cargo outdated" {
"cargo outdated --version" | Should -ReturnZeroExitCode
}
}
}
Describe "Docker" {
It "docker" {
"docker --version" | Should -ReturnZeroExitCode
}
It "docker buildx" {
"docker buildx" | Should -ReturnZeroExitCode
}
It "docker compose v2" {
"docker compose" | Should -ReturnZeroExitCode
}
It "docker-credential-ecr-login" {
"docker-credential-ecr-login -v" | Should -ReturnZeroExitCode
}
}
Describe "Docker images" {
$testCases = (Get-ToolsetContent).docker.images | ForEach-Object { @{ ImageName = $_ } }
It "<ImageName>" -TestCases $testCases {
sudo docker images "$ImageName" --format "{{.Repository}}" | Should -Not -BeNullOrEmpty
}
}
Describe "Docker-compose v1" {
It "docker-compose" {
"docker-compose --version"| Should -ReturnZeroExitCode
}
}
Describe "Ansible" {
It "Ansible" {
"ansible --version" | Should -ReturnZeroExitCode
}
}
Describe "Bazel" {
It "<ToolName>" -TestCases @(
@{ ToolName = "bazel" }
@{ ToolName = "bazelisk" }
) {
"$ToolName --version"| Should -ReturnZeroExitCode
}
}
Describe "clang" {
[array]$testCases = (Get-ToolsetContent).clang.Versions | ForEach-Object { @{ClangVersion = $_} }
It "clang <ClangVersion>" -TestCases $testCases {
param (
[string] $ClangVersion
)
"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
}
}
Describe "Cmake" {
It "cmake" {
"cmake --version" | Should -ReturnZeroExitCode
}
}
Describe "erlang" -Skip:(Test-IsUbuntu22) {
$testCases = @("erl -version", "erlc -v", "rebar3 -v") | ForEach-Object { @{ErlangCommand = $_} }
It "erlang <ErlangCommand>" -TestCases $testCases {
param (
[string] $ErlangCommand
)
"$ErlangCommand" | Should -ReturnZeroExitCode
}
}
Describe "gcc" {
[array]$testCases = (Get-ToolsetContent).gcc.Versions | ForEach-Object { @{GccVersion = $_} }
It "gcc <GccVersion>" -TestCases $testCases {
param (
[string] $GccVersion
)
"$GccVersion --version" | Should -ReturnZeroExitCode
}
}
Describe "gfortran" {
[array]$testCases = (Get-ToolsetContent).gfortran.Versions | ForEach-Object { @{GfortranVersion = $_} }
It "gfortran <GfortranVersion>" -TestCases $testCases {
param (
[string] $GfortranVersion
)
"$GfortranVersion --version" | Should -ReturnZeroExitCode
}
}
Describe "Mono" {
It "mono" {
"mono --version" | Should -ReturnZeroExitCode
}
It "msbuild" {
"msbuild -version" | Should -ReturnZeroExitCode
}
It "nuget" {
"nuget" | Should -ReturnZeroExitCode
}
}
Describe "MSSQLCommandLineTools" {
It "sqlcmd" {
"sqlcmd -?" | Should -ReturnZeroExitCode
}
}
Describe "SqlPackage" {
It "sqlpackage" {
"sqlpackage /version" | Should -ReturnZeroExitCode
}
}
Describe "R" {
It "r" {
"R --version" | Should -ReturnZeroExitCode
}
}
Describe "Sbt" {
It "sbt" {
"sbt --version" | Should -ReturnZeroExitCode
}
}
Describe "Selenium" {
It "Selenium is installed" {
$seleniumBinaryName = (Get-ToolsetContent).selenium.binary_name
$seleniumPath = Join-Path "/usr/share/java" "$seleniumBinaryName.jar"
$seleniumPath | Should -Exist
}
}
Describe "Terraform" {
It "terraform" {
"terraform --version" | Should -ReturnZeroExitCode
}
}
Describe "Zstd" {
It "zstd" {
"zstd --version" | Should -ReturnZeroExitCode
}
It "pzstd" {
"pzstd --version" | Should -ReturnZeroExitCode
}
}
Describe "Vcpkg" {
It "vcpkg" {
"vcpkg version" | Should -ReturnZeroExitCode
}
}
Describe "Git" {
It "git" {
"git --version" | Should -ReturnZeroExitCode
}
It "git-ftp" {
"git-ftp --version" | Should -ReturnZeroExitCode
}
}
Describe "Git-lfs" {
It "git-lfs" {
"git-lfs --version" | Should -ReturnZeroExitCode
}
}
Describe "Heroku" {
It "heroku" {
"heroku --version" | Should -ReturnZeroExitCode
}
}
Describe "HHVM" -Skip:(Test-IsUbuntu22) {
It "hhvm" {
"hhvm --version" | Should -ReturnZeroExitCode
}
}
Describe "Homebrew" {
It "homebrew" {
"/home/linuxbrew/.linuxbrew/bin/brew --version" | Should -ReturnZeroExitCode
}
}
Describe "Julia" {
It "julia" {
"julia --version" | Should -ReturnZeroExitCode
}
}
Describe "Kubernetes tools" {
It "kind" {
"kind version" | Should -ReturnZeroExitCode
}
It "kubectl" {
"kubectl version --client=true" | Should -MatchCommandOutput "Client Version: v"
}
It "helm" {
"helm version --short" | Should -ReturnZeroExitCode
}
It "minikube" {
"minikube version --short" | Should -ReturnZeroExitCode
}
It "kustomize" {
"kustomize version" | Should -ReturnZeroExitCode
}
}
Describe "Leiningen" {
It "leiningen" {
"lein --version" | Should -ReturnZeroExitCode
}
}
Describe "Conda" {
It "conda" {
"conda --version" | Should -ReturnZeroExitCode
}
}
Describe "Packer" {
It "packer" {
"packer --version" | Should -ReturnZeroExitCode
}
}
Describe "Pulumi" {
It "pulumi" {
"pulumi version" | Should -ReturnZeroExitCode
}
}
Describe "Phantomjs" -Skip:(Test-IsUbuntu22) {
It "phantomjs" {
$env:OPENSSL_CONF="/etc/ssl"; phantomjs --version
"phantomjs --version" | Should -ReturnZeroExitCode
}
}
Describe "Containers" {
$testCases = @("podman", "buildah", "skopeo") | ForEach-Object { @{ContainerCommand = $_} }
It "<ContainerCommand>" -TestCases $testCases {
param (
[string] $ContainerCommand
)
"$ContainerCommand -v" | Should -ReturnZeroExitCode
}
# https://github.com/actions/runner-images/issues/7753
It "podman networking" -TestCases "podman CNI plugins" {
"podman network create -d bridge test-net && podman network ls" | Should -Not -MatchCommandOutput "Error"
}
}
Describe "nvm" {
It "nvm" {
"source /etc/skel/.nvm/nvm.sh && nvm --version" | Should -ReturnZeroExitCode
}
}
Describe "Python" {
$testCases = @("python", "pip", "python3", "pip3") | ForEach-Object { @{PythonCommand = $_} }
It "<PythonCommand>" -TestCases $testCases {
param (
[string] $PythonCommand
)
"$PythonCommand --version" | Should -ReturnZeroExitCode
}
}
Describe "Ruby" {
$testCases = @("ruby", "gem") | ForEach-Object { @{RubyCommand = $_} }
It "<RubyCommand>" -TestCases $testCases {
param (
[string] $RubyCommand
)
"$RubyCommand --version" | Should -ReturnZeroExitCode
}
$gemTestCases = (Get-ToolsetContent).rubygems | ForEach-Object {
@{gemName = $_.name}
}
if ($gemTestCases)
{
It "Gem <gemName> is installed" -TestCases $gemTestCases {
"gem list -i '^$gemName$'" | Should -MatchCommandOutput "true"
}
}
}
Describe "yq" {
It "yq" {
"yq -V" | Should -ReturnZeroExitCode
}
}
Describe "Kotlin" {
It "kapt" {
"kapt -version"| Should -ReturnZeroExitCode
}
It "kotlin" {
"kotlin -version"| Should -ReturnZeroExitCode
}
It "kotlinc" {
"kotlinc -version"| Should -ReturnZeroExitCode
}
It "kotlinc-jvm" {
"kotlinc-jvm -version"| Should -ReturnZeroExitCode
}
It "kotlin-dce-js" {
"kotlin-dce-js -version"| Should -ReturnZeroExitCode
}
}

View File

@@ -0,0 +1,66 @@
Describe "Toolset" {
$tools = (Get-ToolsetContent).toolcache
$toolsExecutables = @{
Python = @{
tools = @("python", "bin/pip")
command = "--version"
}
node = @{
tools = @("bin/node", "bin/npm")
command = "--version"
}
PyPy = @{
tools = @("bin/python", "bin/pip")
command = "--version"
}
go = @{
tools = @("bin/go")
command = "version"
}
Ruby = @{
tools = @("bin/ruby")
command = "--version"
}
CodeQL = @{
tools = @("codeql/codeql")
command = "version"
}
}
foreach($tool in $tools) {
$toolName = $tool.Name
Context "$toolName" {
$toolExecs = $toolsExecutables[$toolName]
foreach ($version in $tool.versions) {
# Add wildcard if missing
if ($version.Split(".").Length -lt 3) {
$version += ".*"
}
$expectedVersionPath = Join-Path $env:AGENT_TOOLSDIRECTORY $toolName $version
It "$version version folder exists" -TestCases @{ ExpectedVersionPath = $expectedVersionPath} {
$ExpectedVersionPath | Should -Exist
}
$toolExecs = $toolsExecutables[$toolName]
$foundVersion = Get-Item $expectedVersionPath `
| Sort-Object -Property {[SemVer]$_.name} -Descending `
| Select-Object -First 1
$foundVersionPath = Join-Path $foundVersion $tool.arch
if($toolExecs) {
foreach ($executable in $toolExecs["tools"]) {
$executablePath = Join-Path $foundVersionPath $executable
It "Validate $executable" -TestCases @{ExecutablePath = $executablePath} {
$ExecutablePath | Should -Exist
}
}
}
}
}
}
}

View File

@@ -0,0 +1,23 @@
Describe "Apache" {
It "Apache CLI" {
"apache2 -v" | Should -ReturnZeroExitCode
}
It "Apache Service" {
"sudo systemctl start apache2" | Should -ReturnZeroExitCode
"apachectl configtest" | Should -ReturnZeroExitCode
"sudo systemctl stop apache2" | Should -ReturnZeroExitCode
}
}
Describe "Nginx" {
It "Nginx CLI" {
"nginx -v" | Should -ReturnZeroExitCode
}
It "Nginx Service" {
"sudo systemctl start nginx" | Should -ReturnZeroExitCode
"sudo nginx -t" | Should -ReturnZeroExitCode
"sudo systemctl stop nginx" | Should -ReturnZeroExitCode
}
}