From 7233a550f7154fe308bbe455a122e427a14f1380 Mon Sep 17 00:00:00 2001 From: Leonard Grey Date: Thu, 16 Oct 2025 12:08:18 -0400 Subject: [PATCH 1/2] Windows: add Dockerfile to smoke test arbitrary installers --- swift-ci/main/windows/smoketest/Dockerfile | 119 +++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 swift-ci/main/windows/smoketest/Dockerfile diff --git a/swift-ci/main/windows/smoketest/Dockerfile b/swift-ci/main/windows/smoketest/Dockerfile new file mode 100644 index 00000000..427227c0 --- /dev/null +++ b/swift-ci/main/windows/smoketest/Dockerfile @@ -0,0 +1,119 @@ +# Builds an arbitrary Swift installer and runs smoke tests on it from the provided script. +# +# Required build args: +# SWIFT_INSTALLER_PATH: Path to the Swift installer exe. +# ENTRY_POINT: Path to the entry point PowerShell script. + +FROM mcr.microsoft.com/windows/servercore:ltsc2022 + +SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"] + +# Install Git. +ARG GIT=https://github.com/git-for-windows/git/releases/download/v2.42.0.windows.2/Git-2.42.0.2-64-bit.exe +ARG GIT_SHA256=BD9B41641A258FD16D99BEECEC66132160331D685DFB4C714CEA2BCC78D63BDB +RUN Write-Host -NoNewLine ('Downloading {0} ... ' -f ${env:GIT}); \ + Invoke-WebRequest -Uri ${env:GIT} -OutFile git.exe; \ + Write-Host '✓'; \ + Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f ${env:GIT_SHA256}); \ + $Hash = Get-FileHash git.exe -Algorithm sha256; \ + if ($Hash.Hash -eq ${env:GIT_SHA256}) { \ + Write-Host '✓'; \ + } else { \ + Write-Host ('✘ ({0})' -f $Hash.Hash); \ + exit 1; \ + } \ + Write-Host -NoNewLine 'Installing git ... '; \ + $Process = \ + Start-Process git.exe -Wait -PassThru -NoNewWindow -ArgumentList @( \ + '/SP-', \ + '/VERYSILENT', \ + '/SUPPRESSMSGBOXES', \ + '/NOCANCEL', \ + '/NORESTART', \ + '/CLOSEAPPLICATIONS', \ + '/FORCECLOSEAPPLICATIONS', \ + '/NOICONS', \ + '/COMPONENTS="gitlfs"', \ + '/EditorOption=VIM', \ + '/PathOption=Cmd', \ + '/SSHOption=OpenSSH', \ + '/CURLOption=WinSSL', \ + '/UseCredentialManager=Enabled', \ + '/EnableSymlinks=Enabled', \ + '/EnableFSMonitor=Enabled' \ + ); \ + if ($Process.ExitCode -eq 0) { \ + Write-Host '✓'; \ + } else { \ + Write-Host ('✘ ({0})' -f $Process.ExitCode); \ + exit 1; \ + } \ + Remove-Item -Force git.exe; \ + Remove-Item -ErrorAction SilentlyContinue -Force -Recurse ${env:TEMP}\* + +# Install Visual Studio Build Tools +ARG VSB=https://download.visualstudio.microsoft.com/download/pr/5536698c-711c-4834-876f-2817d31a2ef2/c792bdb0fd46155de19955269cac85d52c4c63c23db2cf43d96b9390146f9390/vs_BuildTools.exe +ARG VSB_SHA256=C792BDB0FD46155DE19955269CAC85D52C4C63C23DB2CF43D96B9390146F9390 +RUN Write-Host -NoNewLine ('Downloading {0} ... ' -f ${env:VSB}); \ + Invoke-WebRequest -Uri ${env:VSB} -OutFile vs_buildtools.exe; \ + Write-Host '✓'; \ + Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f ${env:VSB_SHA256}); \ + $Hash = Get-FileHash vs_buildtools.exe -Algorithm sha256; \ + if ($Hash.Hash -eq ${env:VSB_SHA256}) { \ + Write-Host '✓'; \ + } else { \ + Write-Host ('✘ ({0})' -f $Hash.Hash); \ + exit 1; \ + } \ + Write-Host -NoNewLine 'Installing Visual Studio Build Tools ... '; \ + $Process = \ + Start-Process vs_buildtools.exe -Wait -PassThru -NoNewWindow -ArgumentList @( \ + '--quiet', \ + '--wait', \ + '--norestart', \ + '--nocache', \ + '--add', 'Microsoft.VisualStudio.Component.Windows11SDK.22000', \ + '--add', 'Microsoft.VisualStudio.Component.VC.Tools.x86.x64' \ + ); \ + if ($Process.ExitCode -eq 0 -or $Process.ExitCode -eq 3010) { \ + Write-Host '✓'; \ + } else { \ + Write-Host ('✘ ({0})' -f $Process.ExitCode); \ + exit 1; \ + } \ + Remove-Item -Force vs_buildtools.exe; \ + Remove-Item -ErrorAction SilentlyContinue -Force -Recurse ${env:TEMP}\* + +# Build argument for the Swift installer path +ARG SWIFT_INSTALLER_PATH + +# Copy the Swift installer from the build context +COPY ${SWIFT_INSTALLER_PATH} installer.exe + +# Install Swift toolchain +RUN Write-Host -NoNewLine 'Installing Swift ... '; \ + $Process = \ + Start-Process installer.exe -Wait -PassThru -NoNewWindow -ArgumentList @( \ + '/quiet', \ + '/norestart' \ + ); \ + if ($Process.ExitCode -eq 0) { \ + Write-Host '✓'; \ + } else { \ + Write-Host ('✘ ({0})' -f $Process.ExitCode); \ + exit 1; \ + } \ + Remove-Item -Force installer.exe; \ + Remove-Item -ErrorAction SilentlyContinue -Force -Recurse ${env:TEMP}\* + +# Build argument for entr +ARG ENTRY_POINT + +RUN if (-not ${env:ENTRY_POINT}.EndsWith('.ps1')) { \ + Write-Host ('✘ ENTRY_POINT must be a PowerShell script (.ps1), got: {0}' -f ${env:ENTRY_POINT}); \ + exit 1; \ + } + +COPY ${ENTRY_POINT} entry_point.ps1 + +ENTRYPOINT ["powershell", "-File", "./entry_point.ps1"] \ No newline at end of file From b722b629875a53c1b6d2cce809774c36f9c48c39 Mon Sep 17 00:00:00 2001 From: Leonard Grey Date: Thu, 16 Oct 2025 12:12:47 -0400 Subject: [PATCH 2/2] Fix comment --- swift-ci/main/windows/smoketest/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swift-ci/main/windows/smoketest/Dockerfile b/swift-ci/main/windows/smoketest/Dockerfile index 427227c0..fb5a46ef 100644 --- a/swift-ci/main/windows/smoketest/Dockerfile +++ b/swift-ci/main/windows/smoketest/Dockerfile @@ -106,7 +106,7 @@ RUN Write-Host -NoNewLine 'Installing Swift ... '; Remove-Item -Force installer.exe; \ Remove-Item -ErrorAction SilentlyContinue -Force -Recurse ${env:TEMP}\* -# Build argument for entr +# Build argument for entry point script. ARG ENTRY_POINT RUN if (-not ${env:ENTRY_POINT}.EndsWith('.ps1')) { \