Skip to content

Commit

Permalink
Add windows 2025 image
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexey-Ayupov committed Nov 25, 2024
1 parent 75e2e79 commit 4abd3c2
Show file tree
Hide file tree
Showing 25 changed files with 983 additions and 80 deletions.
6 changes: 5 additions & 1 deletion images/windows/scripts/build/Configure-ImageDataFile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ $imageMinorVersion = $imageVersionComponents[1]
$imageDataFile = $env:IMAGEDATA_FILE
$githubUrl = "https://github.com/actions/runner-images/blob"

if (Test-IsWin22) {
if (Test-IsWin25) {
$imageLabel = "windows-2025"
$softwareUrl = "${githubUrl}/win25/$imageMajorVersion.$imageMinorVersion/images/windows/Windows2025-Readme.md"
$releaseUrl = "https://github.com/actions/runner-images/releases/tag/win25%2F$imageMajorVersion.$imageMinorVersion"
} elseif (Test-IsWin22) {
$imageLabel = "windows-2022"
$softwareUrl = "${githubUrl}/win22/$imageMajorVersion.$imageMinorVersion/images/windows/Windows2022-Readme.md"
$releaseUrl = "https://github.com/actions/runner-images/releases/tag/win22%2F$imageMajorVersion.$imageMinorVersion"
Expand Down
23 changes: 23 additions & 0 deletions images/windows/scripts/build/Configure-System.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,27 @@ $disableTaskNames | ForEach-Object {
Disable-ScheduledTask @PSItem -ErrorAction Ignore
} | Out-Null

if (Test-IsWin25) {
$directoriesToCompact = @(
'C:\ProgramData\Microsoft\VisualStudio\Packages',
'C:\ProgramData\Package Cache',
'C:\Windows\assembly',
'C:\Windows\WinSxS'
)
Write-Host "Starting Image slimming process"
$start = get-date
$ErrorActionPreviousValue = $ErrorActionPreference
$ErrorActionPreference = 'SilentlyContinue'
Write-Host "Removing 'C:\Windows\Installer' directory"
Remove-Item "$env:windir\Installer" -Recurse -Force | Out-Null
foreach ($directory in $directoriesToCompact) {
Write-Host "Compressing '$directory' directory"
& compact /s:"$directory" /c /a /i /EXE:LZX * | Out-Null
}
$ErrorActionPreference = $ErrorActionPreviousValue
$finish = get-date
$time = "$(($finish - $start).Minutes):$(($finish - $start).Seconds)"
Write-Host "The process took a total of $time (in minutes:seconds)"
}

Write-Host "Configure-System.ps1 - completed"
28 changes: 18 additions & 10 deletions images/windows/scripts/build/Configure-User.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,26 @@ if ($LASTEXITCODE -ne 0) {
throw "Failed to copy HKCU\Software\Microsoft\VisualStudio to HKLM\DEFAULT\Software\Microsoft\VisualStudio"
}

# disable TSVNCache.exe
$registryKeyPath = 'HKCU:\Software\TortoiseSVN'
if (-not(Test-Path -Path $registryKeyPath)) {
New-Item -Path $registryKeyPath -ItemType Directory -Force
# TortoiseSVN not installed on Windows 2025 image due to Sysprep issues
if (-not (Test-IsWin25)) {
# disable TSVNCache.exe
$registryKeyPath = 'HKCU:\Software\TortoiseSVN'
if (-not(Test-Path -Path $registryKeyPath)) {
New-Item -Path $registryKeyPath -ItemType Directory -Force
}

New-ItemProperty -Path $registryKeyPath -Name CacheType -PropertyType DWORD -Value 0
reg.exe copy HKCU\Software\TortoiseSVN HKLM\DEFAULT\Software\TortoiseSVN /s
if ($LASTEXITCODE -ne 0) {
throw "Failed to copy HKCU\Software\TortoiseSVN to HKLM\DEFAULT\Software\TortoiseSVN"
}
}
Dismount-RegistryHive "HKLM\DEFAULT"

New-ItemProperty -Path $registryKeyPath -Name CacheType -PropertyType DWORD -Value 0
reg.exe copy HKCU\Software\TortoiseSVN HKLM\DEFAULT\Software\TortoiseSVN /s
if ($LASTEXITCODE -ne 0) {
throw "Failed to copy HKCU\Software\TortoiseSVN to HKLM\DEFAULT\Software\TortoiseSVN"
# Remove the "installer" (var.install_user) user profile for Windows 2025 image
if (Test-IsWin25) {
Get-CimInstance -ClassName Win32_UserProfile | where-object {$_.LocalPath -match $env:INSTALL_USER} | Remove-CimInstance -Confirm:$false
& net user $env:INSTALL_USER /DELETE
}

Dismount-RegistryHive "HKLM\DEFAULT"

Write-Host "Configure-User.ps1 - completed"
20 changes: 11 additions & 9 deletions images/windows/scripts/build/Install-Docker.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ if ($LastExitCode -ne 0) {
# https://github.com/Azure/azure-cli/issues/18766
New-Item -ItemType SymbolicLink -Path "C:\Windows\SysWOW64\docker.exe" -Target "C:\Windows\System32\docker.exe"

Write-Host "Download docker images"
$dockerImages = (Get-ToolsetContent).docker.images
foreach ($dockerImage in $dockerImages) {
Write-Host "Pulling docker image $dockerImage ..."
docker pull $dockerImage

if (!$?) {
throw "Docker pull failed with a non-zero exit code ($LastExitCode)"
if (-not (Test-IsWin25)) {
Write-Host "Download docker images"
$dockerImages = (Get-ToolsetContent).docker.images
foreach ($dockerImage in $dockerImages) {
Write-Host "Pulling docker image $dockerImage ..."
docker pull $dockerImage

if (!$?) {
throw "Docker pull failed with a non-zero exit code ($LastExitCode)"
}
}
Invoke-PesterTests -TestFile "Docker" -TestName "DockerImages"
}

Invoke-PesterTests -TestFile "Docker" -TestName "Docker"
Invoke-PesterTests -TestFile "Docker" -TestName "DockerImages"
9 changes: 7 additions & 2 deletions images/windows/scripts/build/Install-Haskell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ Add-MachinePathItem "$ghcupPrefix\ghcup\bin"
Add-MachinePathItem "$cabalDir\bin"
Update-Environment

# Get 3 latest versions of GHC
# Get 1 or 3 latest versions of GHC depending on the OS version
If (Test-IsWin25) {
$numberOfVersions = 1
} else {
$numberOfVersions = 3
}
$versions = ghcup list -t ghc -r | Where-Object { $_ -notlike "prerelease" }
$versionsOutput = [version[]]($versions | ForEach-Object { $_.Split(' ')[1]; })
$latestMajorMinor = $versionsOutput | Group-Object { $_.ToString(2) } | Sort-Object { [Version] $_.Name } | Select-Object -last 3
$latestMajorMinor = $versionsOutput | Group-Object { $_.ToString(2) } | Sort-Object { [Version] $_.Name } | Select-Object -last $numberOfVersions
$versionsList = $latestMajorMinor | ForEach-Object { $_.Group | Select-Object -Last 1 } | Sort-Object

# The latest version will be installed as a default
Expand Down
6 changes: 3 additions & 3 deletions images/windows/scripts/build/Install-Mingw64.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ if (Test-IsWin19) {
$path = "C:\$_\bin\mingw32-make.exe" | Get-Item
Copy-Item -Path $path -Destination (Join-Path $path.Directory 'make.exe')
}

Add-MachinePathItem "C:\mingw64\bin"

}

if (Test-IsWin22) {
# If Windows 2022, install version specified in the toolset
if (-not (Test-IsWin19)) {
# If Windows 2022 0r 2025 install version specified in the toolset
$version = (Get-ToolsetContent).mingw.version
$runtime = (Get-ToolsetContent).mingw.runtime

Expand Down
14 changes: 14 additions & 0 deletions images/windows/scripts/build/Install-MongoDB.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,18 @@ $mongodbService.WaitForStatus('Running', '00:01:00')
Stop-Service $mongodbService
$mongodbService | Set-Service -StartupType Disabled

# Install mongodb shell for mongodb > 5 version
if (Test-IsWin25) {
$mongoshVersion = (Get-GithubReleasesByVersion -Repo "mongodb-js/mongosh" -Version "latest").version

$mongoshDownloadUrl = Resolve-GithubReleaseAssetUrl `
-Repo "mongodb-js/mongosh" `
-Version $mongoshVersion `
-UrlMatchPattern "mongosh-*-x64.msi"

Install-Binary -Type MSI `
-Url $mongoshDownloadUrl `
-ExpectedSignature 'F2D7C28591847BB2CB2B1C2A0C59459FDC728A38'
}

Invoke-PesterTests -TestFile "Databases" -TestName "MongoDB"
14 changes: 7 additions & 7 deletions images/windows/scripts/build/Install-Rust.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ rustup component add rustfmt clippy
if ($LASTEXITCODE -ne 0) {
throw "Rust component installation failed with exit code $LASTEXITCODE"
}

cargo install bindgen-cli cbindgen cargo-audit cargo-outdated
if ($LASTEXITCODE -ne 0) {
throw "Rust tools installation failed with exit code $LASTEXITCODE"
if (-not (Test-IsWin25)) {
cargo install bindgen-cli cbindgen cargo-audit cargo-outdated
if ($LASTEXITCODE -ne 0) {
throw "Rust tools installation failed with exit code $LASTEXITCODE"
}
# Cleanup Cargo crates cache
Remove-Item "${env:CARGO_HOME}\registry\*" -Recurse -Force
}

# Cleanup Cargo crates cache
Remove-Item "${env:CARGO_HOME}\registry\*" -Recurse -Force

Invoke-PesterTests -TestFile "Rust"
13 changes: 8 additions & 5 deletions images/windows/scripts/build/Install-VisualStudio.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,18 @@ if (Test-IsWin19) {
Install-Binary -Type EXE `
-Url 'https://go.microsoft.com/fwlink/p/?linkid=2196241' `
-InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64") `
-ExpectedSignature 'E4C5C5FCDB68B930EE4E19BC25D431EF6D864C51'
-ExpectedSignature 'E4C5C5FCDB68B930EE4E19BC25D431EF6D864C51'
}

if (Test-IsWin22) {
if (Test-IsWin22) {
# Install Windows 10 SDK version 10.0.17763
Install-Binary -Type EXE `
-Url 'https://go.microsoft.com/fwlink/p/?LinkID=2033908' `
-InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64") `
-ExpectedSignature '7535269B94C1FEA4A5EF6D808E371DA242F27936'
-Url 'https://go.microsoft.com/fwlink/p/?LinkID=2033908' `
-InstallArgs @("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64") `
-ExpectedSignature '7535269B94C1FEA4A5EF6D808E371DA242F27936'
}

if (-not (Test-IsWin19)) {
# Install Windows 11 SDK version 10.0.26100
Install-Binary -Type EXE `
-Url 'https://go.microsoft.com/fwlink/?linkid=2286561' `
Expand Down
37 changes: 27 additions & 10 deletions images/windows/scripts/docs-gen/Generate-SoftwareReport.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,16 +80,22 @@ if (Test-IsWin19) {
$tools.AddToolVersion("Google Cloud CLI", $(Get-GoogleCloudCLIVersion))
}
$tools.AddToolVersion("ImageMagick", $(Get-ImageMagickVersion))
$tools.AddToolVersion("InnoSetup", $(Get-InnoSetupVersion))
if (-not (Test-IsWin25)) {
$tools.AddToolVersion("InnoSetup", $(Get-InnoSetupVersion))
}
$tools.AddToolVersion("jq", $(Get-JQVersion))
$tools.AddToolVersion("Kind", $(Get-KindVersion))
$tools.AddToolVersion("Kubectl", $(Get-KubectlVersion))
$tools.AddToolVersion("Mercurial", $(Get-MercurialVersion))
if (-not (Test-IsWin25)) {
$tools.AddToolVersion("Mercurial", $(Get-MercurialVersion))
}
$tools.AddToolVersion("gcc", $(Get-GCCVersion))
$tools.AddToolVersion("gdb", $(Get-GDBVersion))
$tools.AddToolVersion("GNU Binutils", $(Get-GNUBinutilsVersion))
$tools.AddToolVersion("Newman", $(Get-NewmanVersion))
$tools.AddToolVersion("NSIS", $(Get-NSISVersion))
if (-not (Test-IsWin25)) {
$tools.AddToolVersion("NSIS", $(Get-NSISVersion))
}
$tools.AddToolVersion("OpenSSL", $(Get-OpenSSLVersion))
$tools.AddToolVersion("Packer", $(Get-PackerVersion))
if (Test-IsWin19) {
Expand All @@ -109,7 +115,9 @@ $tools.AddToolVersion("zstd", $(Get-ZstdVersion))

# CLI Tools
$cliTools = $installedSoftware.AddHeader("CLI Tools")
$cliTools.AddToolVersion("Alibaba Cloud CLI", $(Get-AlibabaCLIVersion))
if (-not (Test-IsWin25)) {
$cliTools.AddToolVersion("Alibaba Cloud CLI", $(Get-AlibabaCLIVersion))
}
$cliTools.AddToolVersion("AWS CLI", $(Get-AWSCLIVersion))
$cliTools.AddToolVersion("AWS SAM CLI", $(Get-AWSSAMVersion))
$cliTools.AddToolVersion("AWS Session Manager CLI", $(Get-AWSSessionManagerVersion))
Expand All @@ -129,10 +137,12 @@ $rustTools.AddToolVersion("Rustdoc", $(Get-RustdocVersion))
$rustTools.AddToolVersion("Rustup", $(Get-RustupVersion))

$rustToolsPackages = $rustTools.AddHeader("Packages")
$rustToolsPackages.AddToolVersion("bindgen", $(Get-BindgenVersion))
$rustToolsPackages.AddToolVersion("cargo-audit", $(Get-CargoAuditVersion))
$rustToolsPackages.AddToolVersion("cargo-outdated", $(Get-CargoOutdatedVersion))
$rustToolsPackages.AddToolVersion("cbindgen", $(Get-CbindgenVersion))
if (-not (Test-IsWin25)) {
$rustToolsPackages.AddToolVersion("bindgen", $(Get-BindgenVersion))
$rustToolsPackages.AddToolVersion("cargo-audit", $(Get-CargoAuditVersion))
$rustToolsPackages.AddToolVersion("cargo-outdated", $(Get-CargoOutdatedVersion))
$rustToolsPackages.AddToolVersion("cbindgen", $(Get-CbindgenVersion))
}
$rustToolsPackages.AddToolVersion("Clippy", $(Get-RustClippyVersion))
$rustToolsPackages.AddToolVersion("Rustfmt", $(Get-RustfmtVersion))

Expand Down Expand Up @@ -179,6 +189,9 @@ $databaseTools.AddToolVersion("DacFx", $(Get-DacFxVersion))
$databaseTools.AddToolVersion("MySQL", $(Get-MySQLVersion))
$databaseTools.AddToolVersion("SQL OLEDB Driver", $(Get-SQLOLEDBDriverVersion))
$databaseTools.AddToolVersion("SQLPS", $(Get-SQLPSVersion))
if (Test-IsWin25) {
$databaseTools.AddToolVersion("MongoDB Shell (mongosh)", $(Get-MongoshVersion))
}

# Web Servers
$installedSoftware.AddHeader("Web Servers").AddTable($(Build-WebServersSection))
Expand Down Expand Up @@ -222,7 +235,9 @@ Azure PowerShell module 2.1.0 and AzureRM PowerShell module 2.1.0 are installed
and are available via 'Get-Module -ListAvailable'.
All other versions are saved but not installed.
'@
$psModules.AddNote($azPsNotes)
if (-not (Test-IsWin25)) {
$psModules.AddNote($azPsNotes)
}

# Android
$android = $installedSoftware.AddHeader("Android")
Expand All @@ -231,7 +246,9 @@ $android.AddTable($(Build-AndroidTable))
$android.AddHeader("Environment variables").AddTable($(Build-AndroidEnvironmentTable))

# Cached Docker images
$installedSoftware.AddHeader("Cached Docker images").AddTable($(Get-CachedDockerImagesTableData))
if (-not (Test-IsWin25)) {
$installedSoftware.AddHeader("Cached Docker images").AddTable($(Get-CachedDockerImagesTableData))
}

# Generate reports
$softwareReport.ToJson() | Out-File -FilePath "C:\software-report.json" -Encoding UTF8NoBOM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ function Get-PostgreSQLTable
function Get-MongoDBTable
{
$name = "MongoDB"
if (Test-IsWin25) {
$command = "mongod"
} else {
$command = "mongo"
}
$mongoService = Get-Service -Name $name
$mongoVersion = (Get-Command -Name 'mongo').Version.ToString()
$mongoVersion = (Get-Command -Name $command).Version.ToString()
return [PSCustomObject]@{
Version = $mongoVersion
ServiceName = $name
Expand Down
4 changes: 4 additions & 0 deletions images/windows/scripts/docs-gen/SoftwareReport.Tools.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,7 @@ function Get-ImageMagickVersion {
$magickVersion = $Matches.Version
return $magickVersion
}

function Get-MongoshVersion {
return $(mongosh --version)
}
1 change: 1 addition & 0 deletions images/windows/scripts/helpers/ImageHelpers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Export-ModuleMember -Function @(
'Get-ToolsetContent'
'Get-TCToolPath'
'Get-TCToolVersionPath'
'Test-IsWin25'
'Test-IsWin22'
'Test-IsWin19'
'Expand-7ZipArchive'
Expand Down
16 changes: 16 additions & 0 deletions images/windows/scripts/helpers/InstallHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,22 @@ function Get-TCToolVersionPath {
return Join-Path $foundVersion $Arch
}

function Test-IsWin25 {
<#
.SYNOPSIS
Checks if the current Windows operating system is Windows Server 2025.
.DESCRIPTION
This function uses the Get-CimInstance cmdlet to retrieve information
about the current Windows operating system. It then checks if the Caption
property of the Win32_OperatingSystem class contains the string "2025",
indicating that the operating system is Windows Server 2025.
.OUTPUTS
Returns $true if the current Windows operating system is Windows Server 2025.
Otherwise, returns $false.
#>
(Get-CimInstance -ClassName Win32_OperatingSystem).Caption -match "2025"
}

function Test-IsWin22 {
<#
.SYNOPSIS
Expand Down
4 changes: 2 additions & 2 deletions images/windows/scripts/tests/CLI.Tools.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Describe "Azure DevOps CLI" {
}
}

Describe "Aliyun CLI" {
Describe "Aliyun CLI" -Skip:(Test-IsWin25) {
It "Aliyun CLI" {
"aliyun version" | Should -ReturnZeroExitCode
}
Expand Down Expand Up @@ -39,7 +39,7 @@ Describe "GitHub CLI" {
}
}

Describe "CloudFoundry CLI" -Skip:(Test-IsWin22) {
Describe "CloudFoundry CLI" -Skip:(-not (Test-IsWin19)) {
It "cf is located in C:\cf-cli" {
"C:\cf-cli\cf.exe" | Should -Exist
}
Expand Down
8 changes: 4 additions & 4 deletions images/windows/scripts/tests/ChocoPackages.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ Describe "Bicep" {
}
}

Describe "GitVersion" -Skip:(Test-IsWin22) {
Describe "GitVersion" -Skip:(-not (Test-IsWin19)) {
It "gitversion is installed" {
"gitversion /version" | Should -ReturnZeroExitCode
}
}

Describe "InnoSetup" {
Describe "InnoSetup" -Skip:(Test-IsWin25) {
It "InnoSetup" {
(Get-Command -Name iscc).CommandType | Should -BeExactly "Application"
}
Expand Down Expand Up @@ -64,7 +64,7 @@ Describe "Pulumi" {
}
}

Describe "Svn" {
Describe "Svn" -Skip:(Test-IsWin25) {
It "svn" {
"svn --version --quiet" | Should -ReturnZeroExitCode
}
Expand Down Expand Up @@ -102,4 +102,4 @@ Describe "ImageMagick" {
It "ImageMagick" {
"magick -version" | Should -ReturnZeroExitCode
}
}
}
Loading

0 comments on commit 4abd3c2

Please sign in to comment.