diff --git a/.vsts-ci/linux-daily.yml b/.vsts-ci/linux-daily.yml index 6ab1832df..e6a5375b0 100644 --- a/.vsts-ci/linux-daily.yml +++ b/.vsts-ci/linux-daily.yml @@ -47,7 +47,7 @@ stages: jobs: - template: templates/ci-build.yml parameters: - pool: ubuntu-16.04 + pool: ubuntu-20.04 jobName: linux_build displayName: linux Build @@ -56,7 +56,7 @@ stages: jobs: - job: linux_test pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-20.04 displayName: Linux Test steps: @@ -149,7 +149,7 @@ stages: - job: CodeCovTestPackage displayName: CodeCoverage and Test Packages pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-20.04 steps: - pwsh: | Import-Module .\tools\ci.psm1 diff --git a/.vsts-ci/linux.yml b/.vsts-ci/linux.yml index bed0c4fd2..0cc592848 100644 --- a/.vsts-ci/linux.yml +++ b/.vsts-ci/linux.yml @@ -52,7 +52,7 @@ stages: jobs: - template: templates/ci-build.yml parameters: - pool: ubuntu-16.04 + pool: ubuntu-20.04 jobName: linux_build displayName: linux Build @@ -62,34 +62,34 @@ stages: - template: templates/nix-test.yml parameters: name: Linux - pool: ubuntu-16.04 + pool: ubuntu-20.04 purpose: UnelevatedPesterTests tagSet: CI - template: templates/nix-test.yml parameters: name: Linux - pool: ubuntu-16.04 + pool: ubuntu-20.04 purpose: ElevatedPesterTests tagSet: CI - template: templates/nix-test.yml parameters: name: Linux - pool: ubuntu-16.04 + pool: ubuntu-20.04 purpose: UnelevatedPesterTests tagSet: Others - template: templates/nix-test.yml parameters: name: Linux - pool: ubuntu-16.04 + pool: ubuntu-20.04 purpose: ElevatedPesterTests tagSet: Others - template: templates/verify-xunit.yml parameters: - pool: ubuntu-16.04 + pool: ubuntu-20.04 - stage: PackageLinux displayName: Package Linux @@ -97,7 +97,7 @@ stages: jobs: - template: linux/templates/packaging.yml parameters: - pool: ubuntu-16.04 + pool: ubuntu-20.04 - stage: CodeCovTestPackage displayName: CodeCoverage and Test Packages @@ -106,7 +106,7 @@ stages: - job: CodeCovTestPackage displayName: CodeCoverage and Test Packages pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-20.04 steps: - pwsh: | Import-Module .\tools\ci.psm1 diff --git a/.vsts-ci/linux/templates/packaging.yml b/.vsts-ci/linux/templates/packaging.yml index 530232cbf..74a234aff 100644 --- a/.vsts-ci/linux/templates/packaging.yml +++ b/.vsts-ci/linux/templates/packaging.yml @@ -1,5 +1,5 @@ parameters: - pool: 'ubuntu-16.04' + pool: 'ubuntu-20.04' parentJobs: [] name: 'Linux' diff --git a/.vsts-ci/misc-analysis.yml b/.vsts-ci/misc-analysis.yml index d760a6e49..5de5e2826 100644 --- a/.vsts-ci/misc-analysis.yml +++ b/.vsts-ci/misc-analysis.yml @@ -51,7 +51,7 @@ jobs: displayName: Markdown and Common Tests pool: - vmImage: ubuntu-16.04 + vmImage: ubuntu-20.04 variables: - name: repoPath diff --git a/.vsts-ci/templates/nix-test.yml b/.vsts-ci/templates/nix-test.yml index 6a1b6e6f9..89c1a39dd 100644 --- a/.vsts-ci/templates/nix-test.yml +++ b/.vsts-ci/templates/nix-test.yml @@ -63,6 +63,18 @@ jobs: continueOnError: true - pwsh: | + Import-Module .\build.psm1 -Force + $environment = Get-EnvironmentInformation + $isUbuntu20 = $environment.IsUbuntu -and $environment.IsUbuntu20 + if ($isUbuntu20) { + $env:LC_ALL='en_US.UTF-8' + $env:LANG='en_US.UTF-8' + sudo locale-gen $LANG + sudo update-locale + } + + locale + Import-Module .\tools\ci.psm1 Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json' $options = (Get-PSOptions) diff --git a/build.psm1 b/build.psm1 index f98872504..c87e11475 100644 --- a/build.psm1 +++ b/build.psm1 @@ -1223,7 +1223,13 @@ function Start-PSPester { if ($Unelevate) { - $outputBufferFilePath = [System.IO.Path]::GetTempFileName() + if ($environment.IsWindows) { + $outputBufferFilePath = [System.IO.Path]::GetTempFileName() + } + else { + # Azure DevOps agents do not have Temp folder setup on Ubuntu 20.04, hence using HOME directory + $outputBufferFilePath = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName())) + } } $command += "Invoke-Pester " @@ -1305,7 +1311,14 @@ function Start-PSPester { $PSFlags = @("-noprofile") if (-not [string]::IsNullOrEmpty($ExperimentalFeatureName)) { - $configFile = [System.IO.Path]::GetTempFileName() + + if ($environment.IsWindows) { + $configFile = [System.IO.Path]::GetTempFileName() + } + else { + $configFile = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName())) + } + $configFile = [System.IO.Path]::ChangeExtension($configFile, ".json") ## Create the config.json file to enable the given experimental feature. @@ -1384,7 +1397,13 @@ function Start-PSPester { { if ($PassThru.IsPresent) { - $passThruFile = [System.IO.Path]::GetTempFileName() + if ($environment.IsWindows) { + $passThruFile = [System.IO.Path]::GetTempFileName() + } + else { + $passThruFile = Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName()) + } + try { $command += "| Export-Clixml -Path '$passThruFile' -Force" diff --git a/test/powershell/Language/Parser/ParameterBinding.Tests.ps1 b/test/powershell/Language/Parser/ParameterBinding.Tests.ps1 index 7fd26912e..493ea9083 100644 --- a/test/powershell/Language/Parser/ParameterBinding.Tests.ps1 +++ b/test/powershell/Language/Parser/ParameterBinding.Tests.ps1 @@ -168,7 +168,13 @@ Describe "Custom type conversion in parameter binding" -Tags 'Feature' { } } '@ - $asmFile = [System.IO.Path]::GetTempFileName() + ".dll" + if ($IsWindows) { + $asmFile = [System.IO.Path]::GetTempFileName() + ".dll" + } + else { + $asmFile = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName() + ".dll")) + } + Add-Type -TypeDefinition $code -OutputAssembly $asmFile ## Helper function to execute script diff --git a/test/powershell/Language/Scripting/ScriptHelp.Tests.ps1 b/test/powershell/Language/Scripting/ScriptHelp.Tests.ps1 index 8824d9620..7553fc962 100644 --- a/test/powershell/Language/Scripting/ScriptHelp.Tests.ps1 +++ b/test/powershell/Language/Scripting/ScriptHelp.Tests.ps1 @@ -180,7 +180,12 @@ Describe 'get-help HelpFunc1' -Tags "Feature" { Describe 'get-help file' -Tags "CI" { BeforeAll { try { - $tmpfile = [IO.Path]::ChangeExtension([IO.Path]::GetTempFileName(), "ps1") + if ($IsWindows) { + $tmpfile = [IO.Path]::ChangeExtension([IO.Path]::GetTempFileName(), "ps1") + } + else { + $tmpfile = Join-Path $env:HOME $([IO.Path]::ChangeExtension([IO.Path]::GetRandomFileName(), "ps1")) + } } catch { return } @@ -233,7 +238,12 @@ Describe 'get-help file' -Tags "CI" { Describe 'get-help other tests' -Tags "CI" { BeforeAll { try { - $tempFile = [IO.Path]::ChangeExtension([IO.Path]::GetTempFileName(), "ps1") + if ($IsWindows) { + $tempFile = [IO.Path]::ChangeExtension([IO.Path]::GetTempFileName(), "ps1") + } + else { + $tempFile = Join-Path $env:HOME $([IO.Path]::ChangeExtension([IO.Path]::GetRandomFileName(), "ps1")) + } } catch { return } diff --git a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 index fc5cf7a69..c41b60c3e 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Management/Test-Connection.Tests.ps1 @@ -96,7 +96,8 @@ Describe "Test-Connection" -tags "CI" { { Test-Connection "fakeHost" -Count 1 -ErrorAction Stop } | Should -Throw -ErrorId "TestConnectionException,Microsoft.PowerShell.Commands.TestConnectionCommand" # Error code = 11001 - Host not found. - if ((Get-PlatformInfo).Platform -match "raspbian") { + $platform = Get-PlatformInfo + if ($platform.Platform -match "raspbian" -or ( $platform.Platform -match 'ubuntu' -and $platform.Version -eq '20.04')) { $code = 11 } elseif (!$IsWindows) { $code = -131073 diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Add-Type.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Add-Type.Tests.ps1 index b818dc640..72d42af1d 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Add-Type.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Add-Type.Tests.ps1 @@ -155,7 +155,13 @@ public class SMAAttributeTest$guid : PSCmdlet ## The assembly files cannot be removed once they are loaded, unless the current PowerShell session exits. ## If we use $TestDrive here, then Pester will try to remove them afterward and result in errors. - $TempPath = [System.IO.Path]::GetTempFileName() + if ($IsWindows) { + $TempPath = [System.IO.Path]::GetTempFileName() + } + else { + $TempPath = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName())) + } + if (Test-Path $TempPath) { Remove-Item -Path $TempPath -Force -Recurse } New-Item -Path $TempPath -ItemType Directory -Force > $null diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-PSBreakpoint.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-PSBreakpoint.Tests.ps1 index 21c84fe47..a5b809d8f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-PSBreakpoint.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-PSBreakpoint.Tests.ps1 @@ -154,7 +154,14 @@ set-psbreakpoint -command foo } It "Fail to set psbreakpoints when script is a file of wrong type" { - $tempFile = [System.IO.Path]::GetTempFileName() + + if ($IsWindows) { + $tempFile = [System.IO.Path]::GetTempFileName() + } + else { + $tempFile = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName())) + } + $ErrorActionPreference = "Stop" { Set-PSBreakpoint -Script $tempFile -Line 1 diff --git a/test/powershell/engine/Basic/Assembly.LoadFrom.Tests.ps1 b/test/powershell/engine/Basic/Assembly.LoadFrom.Tests.ps1 index 67ee0677c..383f20bfb 100644 --- a/test/powershell/engine/Basic/Assembly.LoadFrom.Tests.ps1 +++ b/test/powershell/engine/Basic/Assembly.LoadFrom.Tests.ps1 @@ -35,7 +35,14 @@ Describe "Assembly.LoadFrom Validation Test" -Tags "CI" { ## The assembly files cannot be removed once they are loaded, unless the current PowerShell session exits. ## If we use $TestDrive here, then Pester will try to remove them afterward and result in errors. - $TempPath = [System.IO.Path]::GetTempFileName() + + if ($IsWindows) { + $TempPath = [System.IO.Path]::GetTempFileName() + } + else { + $TempPath = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName())) + } + if (Test-Path $TempPath) { Remove-Item -Path $TempPath -Force -Recurse } New-Item -Path $TempPath -ItemType Directory -Force > $null diff --git a/test/powershell/engine/Basic/Assembly.LoadNative.Tests.ps1 b/test/powershell/engine/Basic/Assembly.LoadNative.Tests.ps1 index bb3835736..9196ccc0e 100644 --- a/test/powershell/engine/Basic/Assembly.LoadNative.Tests.ps1 +++ b/test/powershell/engine/Basic/Assembly.LoadNative.Tests.ps1 @@ -6,7 +6,13 @@ Describe "Can load a native assembly" -Tags "CI" { BeforeAll { ## The assembly files cannot be removed once they are loaded, unless the current PowerShell session exits. ## If we use $TestDrive here, then Pester will try to remove them afterward and result in errors. - $TempPath = [System.IO.Path]::GetTempFileName() + if ($IsWindows) { + $TempPath = [System.IO.Path]::GetTempFileName() + } + else { + $TempPath = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName())) + } + if (Test-Path $TempPath) { Remove-Item -Path $TempPath -Force -Recurse } New-Item -Path $TempPath -ItemType Directory -Force > $null diff --git a/test/powershell/engine/Remoting/PSSession.Tests.ps1 b/test/powershell/engine/Remoting/PSSession.Tests.ps1 index 3b8259f37..25c7ab9c5 100644 --- a/test/powershell/engine/Remoting/PSSession.Tests.ps1 +++ b/test/powershell/engine/Remoting/PSSession.Tests.ps1 @@ -83,7 +83,8 @@ Describe "SkipCACheck and SkipCNCheck PSSession options are required for New-PSS if ( ($platformInfo.Platform -match "alpine|raspbian") -or ($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID - ($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') + ($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or + ($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04') ) { Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, and CentOS 8" return diff --git a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 index a8054b471..d56ed1999 100644 --- a/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 +++ b/test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 @@ -15,6 +15,7 @@ Describe "New-PSSession basic test" -Tag @("CI") { ($platformInfo.Platform -match "alpine|raspbian") -or ($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID ($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or + ($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04') -or ($IsMacOS) ) { Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, CentOS 8, and not compatible with macOS" @@ -33,6 +34,7 @@ Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") { ($platformInfo.Platform -match "alpine|raspbian") -or ($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID ($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or + ($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04') -or ($IsMacOS) ) { Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, CentOS 8, and not compatible with macOS" @@ -56,6 +58,7 @@ Describe "Basic Auth over HTTP not allowed on Unix" -Tag @("CI") { ($platformInfo.Platform -match "alpine|raspbian") -or ($platformInfo.Platform -eq "debian" -and ($platformInfo.Version -eq '10' -or $platformInfo.Version -eq '')) -or # debian 11 has empty Version ID ($platformInfo.Platform -eq 'centos' -and $platformInfo.Version -eq '8') -or + ($platformInfo.Platform -eq 'ubuntu' -and $platformInfo.Version -eq '20.04') -or ($IsMacOS) ) { Set-ItResult -Skipped -Because "MI library not available for Alpine, Raspberry Pi, Debian 10 and 11, CentOS 8, and not compatible with macOS" diff --git a/test/tools/Modules/WebListener/WebListener.psm1 b/test/tools/Modules/WebListener/WebListener.psm1 index 6436da97d..655b4cdd6 100644 --- a/test/tools/Modules/WebListener/WebListener.psm1 +++ b/test/tools/Modules/WebListener/WebListener.psm1 @@ -102,7 +102,7 @@ function Start-WebListener [int]$HttpPort = 8083, [ValidateRange(1,65535)] - [int]$HttpsPort = 8084, + [int]$HttpsPort = 9084, [ValidateRange(1,65535)] [int]$Tls11Port = 8085, diff --git a/tools/packaging/packaging.psm1 b/tools/packaging/packaging.psm1 index 9b1602a09..000d48067 100644 --- a/tools/packaging/packaging.psm1 +++ b/tools/packaging/packaging.psm1 @@ -1351,21 +1351,21 @@ function New-AfterScripts Write-Verbose -Message "AfterScript Distribution: $Distribution" -Verbose if ($Environment.IsRedHatFamily) { - $AfterInstallScript = [io.path]::GetTempFileName() - $AfterRemoveScript = [io.path]::GetTempFileName() + $AfterInstallScript = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName())) + $AfterRemoveScript = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName())) $packagingStrings.RedHatAfterInstallScript -f "$Link", $Destination | Out-File -FilePath $AfterInstallScript -Encoding ascii $packagingStrings.RedHatAfterRemoveScript -f "$Link", $Destination | Out-File -FilePath $AfterRemoveScript -Encoding ascii } elseif ($Environment.IsDebianFamily -or $Environment.IsSUSEFamily) { - $AfterInstallScript = [io.path]::GetTempFileName() - $AfterRemoveScript = [io.path]::GetTempFileName() + $AfterInstallScript = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName())) + $AfterRemoveScript = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName())) $packagingStrings.UbuntuAfterInstallScript -f "$Link", $Destination | Out-File -FilePath $AfterInstallScript -Encoding ascii $packagingStrings.UbuntuAfterRemoveScript -f "$Link", $Destination | Out-File -FilePath $AfterRemoveScript -Encoding ascii } elseif ($Environment.IsMacOS) { # NOTE: The macos pkgutil doesn't support uninstall actions so we did not implement it. # Handling uninstall can be done in Homebrew so we'll take advantage of that in the brew formula. - $AfterInstallScript = [io.path]::GetTempFileName() + $AfterInstallScript = (Join-Path $env:HOME $([System.IO.Path]::GetRandomFileName())) $packagingStrings.MacOSAfterInstallScript -f "$Link" | Out-File -FilePath $AfterInstallScript -Encoding ascii }