From 99835f76f039250dfb389ab544a21e3b8f4dc79a Mon Sep 17 00:00:00 2001 From: Matthew Bastien Date: Thu, 27 Nov 2025 14:33:35 -0500 Subject: [PATCH 1/2] install Python 3.10 in dockerless Windows builds --- .github/workflows/swift_package_test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 82978ae..58020cb 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -677,6 +677,12 @@ jobs: } docker pull $Image echo "image=$Image" >> "$env:GITHUB_OUTPUT" + - name: "Install Python 3.10" + if: ${{ !inputs.enable_windows_docker }} + uses: actions/setup-python@v6 + with: + python-version: "3.10" + architecture: "x86" - name: Install Visual Studio Build Tools if: ${{ !inputs.enable_windows_docker }} run: . ${{ steps.script_path.outputs.root }}/.github/workflows/scripts/windows/install-vsb.ps1 From 81009e86f69034beeab1832ad7ab00ac79f6c7dc Mon Sep 17 00:00:00 2001 From: Matthew Bastien Date: Thu, 4 Dec 2025 11:14:02 -0500 Subject: [PATCH 2/2] update environment variables after installing Swift on Windows --- .../scripts/windows/swift/install-swift.ps1 | 48 ++++++++++++++++++- .github/workflows/swift_package_test.yml | 5 +- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/.github/workflows/scripts/windows/swift/install-swift.ps1 b/.github/workflows/scripts/windows/swift/install-swift.ps1 index 23e06a3..63da0b7 100644 --- a/.github/workflows/scripts/windows/swift/install-swift.ps1 +++ b/.github/workflows/scripts/windows/swift/install-swift.ps1 @@ -175,4 +175,50 @@ function Install-Swift { exit 1 } Remove-FileWithRetry -Path installer.exe -} \ No newline at end of file + + Write-Host -NoNewLine 'Adding Swift to PATH ... ' + # Older toolchains modify the Machine PATH to include \Library\Developer\Toolchains + foreach ($Item in [Environment]::GetEnvironmentVariables('Machine')['Path'].Split(';')) { + if ($Item.Contains('Swift') -or $Item.Contains('Library\Developer\Toolchains')) { + GitHubActions-AddPath -Item $Item + } + } + # Newer toolchains modify the User PATH to include a path to a Swift directory + foreach ($Item in [Environment]::GetEnvironmentVariables('User')['Path'].Split(';')) { + if ($Item.Contains('Swift')) { + GitHubActions-AddPath -Item $Item + } + } + # Find and export the SDKROOT environment variable + $MachineSDKROOT = [Environment]::GetEnvironmentVariables('Machine')['SDKROOT'] + $UserSDKROOT = [Environment]::GetEnvironmentVariables('User')['SDKROOT'] + if ($MachineSDKROOT) { + GitHubActions-ExportVariable -Name "SDKROOT" -Value $MachineSDKROOT + } elseif ($UserSDKROOT) { + GitHubActions-ExportVariable -Name "SDKROOT" -Value $UserSDKROOT + } + Write-Host 'SUCCESS' +} + +function GitHubActions-AddPath { + param ( + [string]$Item + ) + $FilePath = $env:GITHUB_PATH + if ($FilePath) { + Add-Content -Path "$FilePath" -Value "$Item`r`n" + } + $env:Path = $Item + ";" + $env:Path +} + +function GitHubActions-ExportVariable { + param ( + [string]$Name, + [string]$Value + ) + $FilePath = $env:GITHUB_ENV + if ($FilePath) { + Add-Content -Path "$FilePath" -Value "$Name=$Value`r`n" + } + Set-Content env:\$Name $Value +} diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 58020cb..574cc11 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -736,7 +736,4 @@ jobs: - name: Build / Test timeout-minutes: 60 if: ${{ !inputs.enable_windows_docker }} - run: | - Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 - RefreshEnv - powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1; exit $LastExitCode + run: powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1; exit $LastExitCode