Ensure locale is set correctly on Ubuntu 20.04 in CI (#16067)

This commit is contained in:
Robert Holt 2021-09-08 14:30:44 -07:00 committed by Aditya Patwardhan
parent af19120251
commit 2fd2dfce12
3 changed files with 27 additions and 10 deletions

View file

@ -122,6 +122,9 @@ stages:
condition: succeededOrFailed()
- pwsh: |
Import-Module .\build.psm1
Set-CorrectLocale
Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
Invoke-CITest -Purpose UnelevatedPesterTests -TagSet Others
@ -129,6 +132,9 @@ stages:
condition: succeededOrFailed()
- pwsh: |
Import-Module .\build.psm1
Set-CorrectLocale
Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'
Invoke-CITest -Purpose ElevatedPesterTests -TagSet Others

View file

@ -64,16 +64,7 @@ jobs:
- 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
Set-CorrectLocale
Import-Module .\tools\ci.psm1
Restore-PSOptions -PSOptionsPath '$(System.ArtifactsDirectory)\build\psoptions.json'

View file

@ -3386,3 +3386,23 @@ function New-NugetConfigFile
Set-Content -Path (Join-Path $Destination 'nuget.config') -Value $content -Force
}
function Set-CorrectLocale
{
if (-not $IsLinux)
{
return
}
$environment = Get-EnvironmentInformation
if ($environment.IsUbuntu -and $environment.IsUbuntu20)
{
$env:LC_ALL = 'en_US.UTF-8'
$env:LANG = 'en_US.UTF-8'
sudo locale-gen $env:LANG
sudo update-locale
}
# Output the locale to log it
locale
}