From b2fa3d6d4d224e89eca5bdb6fea51e619dfdfb2f Mon Sep 17 00:00:00 2001 From: Adam Ward Date: Thu, 7 Nov 2024 10:04:25 -0500 Subject: [PATCH 01/11] Allow running windows tests in docker-less environment The vscode-swift extension needs to open the VS Code UI to run tests. As such we cannot run these tests under a docker container as there is no tool like xvfb for Windows. This PR provides powershell scripts to install the VS Build Tools and apporpirate version of Swift. Projects can use this workflow by setting the input enable_windows_docker: false --- .../scripts/swift/install-swift-5.10.ps1 | 6 ++++ .../scripts/swift/install-swift-5.9.ps1 | 6 ++++ .../scripts/swift/install-swift-6.0.ps1 | 6 ++++ .../swift/install-swift-nightly-6.0.ps1 | 7 ++++ .../scripts/swift/install-swift-nightly.ps1 | 7 ++++ .../workflows/scripts/swift/install-swift.ps1 | 31 +++++++++++++++++ .../workflows/scripts/windows/install-vsb.ps1 | 32 ++++++++++++++++++ .github/workflows/swift_package_test.yml | 33 +++++++++++++++++++ 8 files changed, 128 insertions(+) create mode 100644 .github/workflows/scripts/swift/install-swift-5.10.ps1 create mode 100644 .github/workflows/scripts/swift/install-swift-5.9.ps1 create mode 100644 .github/workflows/scripts/swift/install-swift-6.0.ps1 create mode 100644 .github/workflows/scripts/swift/install-swift-nightly-6.0.ps1 create mode 100644 .github/workflows/scripts/swift/install-swift-nightly.ps1 create mode 100644 .github/workflows/scripts/swift/install-swift.ps1 create mode 100644 .github/workflows/scripts/windows/install-vsb.ps1 diff --git a/.github/workflows/scripts/swift/install-swift-5.10.ps1 b/.github/workflows/scripts/swift/install-swift-5.10.ps1 new file mode 100644 index 0000000..85daf4b --- /dev/null +++ b/.github/workflows/scripts/swift/install-swift-5.10.ps1 @@ -0,0 +1,6 @@ +. $PSScriptRoot\install-swift.ps1 + +$SWIFT='https://download.swift.org/swift-5.10.1-release/windows10/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-windows10.exe' +$SWIFT_SHA256='3027762138ACFA1BBE3050FF6613BBE754332E84C9EFA5C23984646009297286' + +Install-Swift -Url $SWIFT -Sha256 $SWIFT_SHA256 diff --git a/.github/workflows/scripts/swift/install-swift-5.9.ps1 b/.github/workflows/scripts/swift/install-swift-5.9.ps1 new file mode 100644 index 0000000..c34c02a --- /dev/null +++ b/.github/workflows/scripts/swift/install-swift-5.9.ps1 @@ -0,0 +1,6 @@ +. $PSScriptRoot\install-swift.ps1 + +$SWIFT='https://download.swift.org/swift-5.9.2-release/windows10/swift-5.9.2-RELEASE/swift-5.9.2-RELEASE-windows10.exe' +$SWIFT_SHA256='D78A717551C78E824C9B74B0CFB1AD86060FC286EA071FDDB26DF18F56DC7212' + +Install-Swift -Url $SWIFT -Sha256 $SWIFT_SHA256 \ No newline at end of file diff --git a/.github/workflows/scripts/swift/install-swift-6.0.ps1 b/.github/workflows/scripts/swift/install-swift-6.0.ps1 new file mode 100644 index 0000000..82cbd14 --- /dev/null +++ b/.github/workflows/scripts/swift/install-swift-6.0.ps1 @@ -0,0 +1,6 @@ +. $PSScriptRoot\install-swift.ps1 + +$SWIFT='https://download.swift.org/swift-6.0.2-release/windows10/swift-6.0.2-RELEASE/swift-6.0.2-RELEASE-windows10.exe' +$SWIFT_SHA256='516FE8E64713BD92F03C01E5198011B74A27F8C1C88627607A2F421718636126' + +Install-Swift -Url $SWIFT -Sha256 $SWIFT_SHA256 \ No newline at end of file diff --git a/.github/workflows/scripts/swift/install-swift-nightly-6.0.ps1 b/.github/workflows/scripts/swift/install-swift-nightly-6.0.ps1 new file mode 100644 index 0000000..6641f38 --- /dev/null +++ b/.github/workflows/scripts/swift/install-swift-nightly-6.0.ps1 @@ -0,0 +1,7 @@ +. $PSScriptRoot\install-swift.ps1 + +$SWIFT_RELEASE_METADATA='http://download.swift.org/swift-6.0-branch/windows10/latest-build.json' +$Release = curl.exe -sL ${SWIFT_RELEASE_METADATA} +$SWIFT_URL = "https://download.swift.org/swift-6.0-branch/windows10/$($($Release | ConvertFrom-JSON).dir)/$($($Release | ConvertFrom-JSON).download)" + +Install-Swift -Url $SWIFT_URL -Sha256 "" \ No newline at end of file diff --git a/.github/workflows/scripts/swift/install-swift-nightly.ps1 b/.github/workflows/scripts/swift/install-swift-nightly.ps1 new file mode 100644 index 0000000..d8e8ad4 --- /dev/null +++ b/.github/workflows/scripts/swift/install-swift-nightly.ps1 @@ -0,0 +1,7 @@ +. $PSScriptRoot\install-swift.ps1 + +$SWIFT_RELEASE_METADATA='http://download.swift.org/development/windows10/latest-build.json' +$Release = curl.exe -sL ${SWIFT_RELEASE_METADATA} +$SWIFT_URL = "https://download.swift.org/development/windows10/$($($Release | ConvertFrom-JSON).dir)/$($($Release | ConvertFrom-JSON).download)" + +Install-Swift -Url $SWIFT_URL -Sha256 "" \ No newline at end of file diff --git a/.github/workflows/scripts/swift/install-swift.ps1 b/.github/workflows/scripts/swift/install-swift.ps1 new file mode 100644 index 0000000..f81c5d8 --- /dev/null +++ b/.github/workflows/scripts/swift/install-swift.ps1 @@ -0,0 +1,31 @@ +function Install-Swift { + param ( + [string]$Url, + [string]$Sha256 + ) + Set-Variable ErrorActionPreference Stop + Set-Variable ProgressPreference SilentlyContinue + Write-Host -NoNewLine ('Downloading {0} ... ' -f $url) + Invoke-WebRequest -Uri $url -OutFile installer.exe + Write-Host 'SUCCESS' + Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f $Sha256) + $Hash = Get-FileHash installer.exe -Algorithm sha256 + if ($Hash.Hash -eq $Sha256 -or $Sha256 -eq "") { + Write-Host 'SUCCESS' + } else { + Write-Host ('FAILED ({0})' -f $Hash.Hash) + exit 1 + } + Write-Host -NoNewLine 'Installing Swift ... ' + $Process = Start-Process installer.exe -Wait -PassThru -NoNewWindow -ArgumentList @( + '/quiet', + '/norestart' + ) + if ($Process.ExitCode -eq 0) { + Write-Host 'SUCCESS' + } else { + Write-Host ('FAILED ({0})' -f $Process.ExitCode) + exit 1 + } + Remove-Item -Force installer.exe +} \ No newline at end of file diff --git a/.github/workflows/scripts/windows/install-vsb.ps1 b/.github/workflows/scripts/windows/install-vsb.ps1 new file mode 100644 index 0000000..5529a6e --- /dev/null +++ b/.github/workflows/scripts/windows/install-vsb.ps1 @@ -0,0 +1,32 @@ +$VSB='https://aka.ms/vs/17/release/vs_buildtools.exe' +$VSB_SHA256='99C7677154366062A43082921F40F3CE00EF2614DBF94DB23B244DD13DC9443D' +Set-Variable ErrorActionPreference Stop +Set-Variable ProgressPreference SilentlyContinue +Write-Host -NoNewLine ('Downloading {0} ... ' -f ${VSB}) +Invoke-WebRequest -Uri $VSB -OutFile $env:TEMP\vs_buildtools.exe +Write-Host 'SUCCESS' +Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f $VSB_SHA256) +$Hash = Get-FileHash $env:TEMP\vs_buildtools.exe -Algorithm sha256 +if ($Hash.Hash -eq $VSB_SHA256) { + Write-Host 'SUCCESS' +} else { + Write-Host ('FAILED ({0})' -f $Hash.Hash) + exit 1 +} +Write-Host -NoNewLine 'Installing Visual Studio Build Tools ... ' +$Process = + Start-Process $env:TEMP\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 'SUCCESS' +} else { + Write-Host ('FAILED ({0})' -f $Process.ExitCode) + exit 1 +} +Remove-Item -Force $env:TEMP\vs_buildtools.exe \ No newline at end of file diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 4b5c5ab..72555b5 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -45,14 +45,26 @@ on: linux_env_vars: description: "List of environment variables" type: string + windows_env_vars: + description: "List of environment variables" + type: string + enable_linux_checks: + type: boolean + description: "Boolean to enable linux testing. Defaults to true" + default: true enable_windows_checks: type: boolean description: "Boolean to enable windows testing. Defaults to true" default: true + enable_windows_docker: + type: boolean + description: "Boolean to enable running build in windows docker container. Defaults to true" + default: true jobs: linux-build: name: Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }}) + if: ${{ inputs.enable_linux_checks }} runs-on: ubuntu-latest strategy: fail-fast: false @@ -93,8 +105,16 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 + - name: Set environment variables + if: ${{ inputs.windows_env_vars }} + run: | + $lines = "${{ inputs.windows_env_vars }}" -split "`r`n" + foreach ($line in $lines) { + echo $line | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append + } - name: Pull Docker image id: pull_docker_image + if: ${{ inputs.enable_windows_docker }} run: | if ("${{ matrix.swift_version }}".Contains("nightly")) { $Image = "swiftlang/swift:${{ matrix.swift_version }}-windowsservercore-1809" @@ -103,6 +123,12 @@ jobs: } docker pull $Image echo "image=$Image" >> "$env:GITHUB_OUTPUT" + - name: Install Visual Studio Build Tools + if: ${{ !inputs.enable_windows_docker }} + run: . .github\workflows\scripts\windows\install-vsb.ps1 + - name: Install Swift + if: ${{ !inputs.enable_windows_docker }} + run: . .github\workflows\scripts\windows\swift\install-swift-${{ matrix.swift_version }}.ps1 - name: Create test script run: | mkdir $env:TEMP\test-script @@ -123,7 +149,14 @@ jobs: ${{ inputs.windows_pre_build_command }} Invoke-Program ${{ inputs.windows_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} '@ >> $env:TEMP\test-script\run.ps1 + # Docker build - name: Build / Test timeout-minutes: 60 + if: ${{ !inputs.enable_windows_docker }} run: | docker run -v ${{ github.workspace }}:C:\source -v $env:TEMP\test-script:C:\test-script ${{ steps.pull_docker_image.outputs.image }} powershell.exe -NoLogo -File C:\test-script\run.ps1 + # Docker-less build + - name: Build / Test + timeout-minutes: 60 + if: ${{ inputs.enable_windows_docker }} + run: powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1 \ No newline at end of file From e7e8110cac53299607b708f9754561c957190206 Mon Sep 17 00:00:00 2001 From: Adam Ward Date: Thu, 7 Nov 2024 10:59:13 -0500 Subject: [PATCH 02/11] Move swift scripts to right directory --- .../workflows/scripts/{ => windows}/swift/install-swift-5.10.ps1 | 0 .../workflows/scripts/{ => windows}/swift/install-swift-5.9.ps1 | 0 .../workflows/scripts/{ => windows}/swift/install-swift-6.0.ps1 | 0 .../scripts/{ => windows}/swift/install-swift-nightly-6.0.ps1 | 0 .../scripts/{ => windows}/swift/install-swift-nightly.ps1 | 0 .github/workflows/scripts/{ => windows}/swift/install-swift.ps1 | 0 6 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/scripts/{ => windows}/swift/install-swift-5.10.ps1 (100%) rename .github/workflows/scripts/{ => windows}/swift/install-swift-5.9.ps1 (100%) rename .github/workflows/scripts/{ => windows}/swift/install-swift-6.0.ps1 (100%) rename .github/workflows/scripts/{ => windows}/swift/install-swift-nightly-6.0.ps1 (100%) rename .github/workflows/scripts/{ => windows}/swift/install-swift-nightly.ps1 (100%) rename .github/workflows/scripts/{ => windows}/swift/install-swift.ps1 (100%) diff --git a/.github/workflows/scripts/swift/install-swift-5.10.ps1 b/.github/workflows/scripts/windows/swift/install-swift-5.10.ps1 similarity index 100% rename from .github/workflows/scripts/swift/install-swift-5.10.ps1 rename to .github/workflows/scripts/windows/swift/install-swift-5.10.ps1 diff --git a/.github/workflows/scripts/swift/install-swift-5.9.ps1 b/.github/workflows/scripts/windows/swift/install-swift-5.9.ps1 similarity index 100% rename from .github/workflows/scripts/swift/install-swift-5.9.ps1 rename to .github/workflows/scripts/windows/swift/install-swift-5.9.ps1 diff --git a/.github/workflows/scripts/swift/install-swift-6.0.ps1 b/.github/workflows/scripts/windows/swift/install-swift-6.0.ps1 similarity index 100% rename from .github/workflows/scripts/swift/install-swift-6.0.ps1 rename to .github/workflows/scripts/windows/swift/install-swift-6.0.ps1 diff --git a/.github/workflows/scripts/swift/install-swift-nightly-6.0.ps1 b/.github/workflows/scripts/windows/swift/install-swift-nightly-6.0.ps1 similarity index 100% rename from .github/workflows/scripts/swift/install-swift-nightly-6.0.ps1 rename to .github/workflows/scripts/windows/swift/install-swift-nightly-6.0.ps1 diff --git a/.github/workflows/scripts/swift/install-swift-nightly.ps1 b/.github/workflows/scripts/windows/swift/install-swift-nightly.ps1 similarity index 100% rename from .github/workflows/scripts/swift/install-swift-nightly.ps1 rename to .github/workflows/scripts/windows/swift/install-swift-nightly.ps1 diff --git a/.github/workflows/scripts/swift/install-swift.ps1 b/.github/workflows/scripts/windows/swift/install-swift.ps1 similarity index 100% rename from .github/workflows/scripts/swift/install-swift.ps1 rename to .github/workflows/scripts/windows/swift/install-swift.ps1 From 0dd0505861ff25e116d616192de4ae206540cb58 Mon Sep 17 00:00:00 2001 From: Adam Ward Date: Thu, 7 Nov 2024 11:51:15 -0500 Subject: [PATCH 03/11] Fetch scripts for installing vsb and swift --- .../workflows/actions/install-vsb/action.yml | 8 +++++ .../actions/install-vsb/install-vsb.ps1 | 32 +++++++++++++++++++ .github/workflows/swift_package_test.yml | 11 +++++-- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/actions/install-vsb/action.yml create mode 100644 .github/workflows/actions/install-vsb/install-vsb.ps1 diff --git a/.github/workflows/actions/install-vsb/action.yml b/.github/workflows/actions/install-vsb/action.yml new file mode 100644 index 0000000..35c9bbc --- /dev/null +++ b/.github/workflows/actions/install-vsb/action.yml @@ -0,0 +1,8 @@ +name: Install Visual Studio Tools +description: Installs Visual Studio Tools +runs: + using: composite + steps: + - name: Run Script + shell: powershell + run: .\install-vsb.ps1 \ No newline at end of file diff --git a/.github/workflows/actions/install-vsb/install-vsb.ps1 b/.github/workflows/actions/install-vsb/install-vsb.ps1 new file mode 100644 index 0000000..5529a6e --- /dev/null +++ b/.github/workflows/actions/install-vsb/install-vsb.ps1 @@ -0,0 +1,32 @@ +$VSB='https://aka.ms/vs/17/release/vs_buildtools.exe' +$VSB_SHA256='99C7677154366062A43082921F40F3CE00EF2614DBF94DB23B244DD13DC9443D' +Set-Variable ErrorActionPreference Stop +Set-Variable ProgressPreference SilentlyContinue +Write-Host -NoNewLine ('Downloading {0} ... ' -f ${VSB}) +Invoke-WebRequest -Uri $VSB -OutFile $env:TEMP\vs_buildtools.exe +Write-Host 'SUCCESS' +Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f $VSB_SHA256) +$Hash = Get-FileHash $env:TEMP\vs_buildtools.exe -Algorithm sha256 +if ($Hash.Hash -eq $VSB_SHA256) { + Write-Host 'SUCCESS' +} else { + Write-Host ('FAILED ({0})' -f $Hash.Hash) + exit 1 +} +Write-Host -NoNewLine 'Installing Visual Studio Build Tools ... ' +$Process = + Start-Process $env:TEMP\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 'SUCCESS' +} else { + Write-Host ('FAILED ({0})' -f $Process.ExitCode) + exit 1 +} +Remove-Item -Force $env:TEMP\vs_buildtools.exe \ No newline at end of file diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 72555b5..3fc76a3 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -125,10 +125,17 @@ jobs: echo "image=$Image" >> "$env:GITHUB_OUTPUT" - name: Install Visual Studio Build Tools if: ${{ !inputs.enable_windows_docker }} - run: . .github\workflows\scripts\windows\install-vsb.ps1 + run: | + Invoke-WebRequest -Uri https://raw.githubusercontent.com/award999/github-workflows/refs/heads/dockerless-windows/.github/workflows/scripts/windows/install-vsb.ps1 -OutFile install-vsb.ps1 + . .\install-vsb.ps1 + del .\install-vsb.ps1 - name: Install Swift if: ${{ !inputs.enable_windows_docker }} - run: . .github\workflows\scripts\windows\swift\install-swift-${{ matrix.swift_version }}.ps1 + run: | + Invoke-WebRequest -Uri https://raw.githubusercontent.com/award999/github-workflows/refs/heads/dockerless-windows/.github/workflows/scripts/windows/swift/install-swift.ps1 -OutFile install-swift.ps1 + Invoke-WebRequest -Uri https://raw.githubusercontent.com/award999/github-workflows/refs/heads/dockerless-windows/.github/workflows/scripts/windows/swift/install-swift-${{ matrix.swift_version }}.ps1 -OutFile install-swift-${{ matrix.swift_version }}.ps1 + . .\install-swift-${{ matrix.swift_version }}.ps1 + del .\install-swift*.ps1 - name: Create test script run: | mkdir $env:TEMP\test-script From e2753fadf9185682b0d3c289c65e2333a34d0286 Mon Sep 17 00:00:00 2001 From: Adam Ward Date: Thu, 7 Nov 2024 13:39:54 -0500 Subject: [PATCH 04/11] Fix docker enablement --- .github/workflows/swift_package_test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 3fc76a3..f6d73ea 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -159,11 +159,11 @@ jobs: # Docker build - name: Build / Test timeout-minutes: 60 - if: ${{ !inputs.enable_windows_docker }} + if: ${{ inputs.enable_windows_docker }} run: | docker run -v ${{ github.workspace }}:C:\source -v $env:TEMP\test-script:C:\test-script ${{ steps.pull_docker_image.outputs.image }} powershell.exe -NoLogo -File C:\test-script\run.ps1 # Docker-less build - name: Build / Test timeout-minutes: 60 - if: ${{ inputs.enable_windows_docker }} + if: ${{ !inputs.enable_windows_docker }} run: powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1 \ No newline at end of file From f400e00a42c5c007decf073b094ea94b8ccd2f6b Mon Sep 17 00:00:00 2001 From: Adam Ward Date: Thu, 7 Nov 2024 14:54:30 -0500 Subject: [PATCH 05/11] Fix docker-less script execution --- .github/workflows/swift_package_test.yml | 28 +++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index f6d73ea..ea23564 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -126,19 +126,24 @@ jobs: - name: Install Visual Studio Build Tools if: ${{ !inputs.enable_windows_docker }} run: | - Invoke-WebRequest -Uri https://raw.githubusercontent.com/award999/github-workflows/refs/heads/dockerless-windows/.github/workflows/scripts/windows/install-vsb.ps1 -OutFile install-vsb.ps1 - . .\install-vsb.ps1 - del .\install-vsb.ps1 + Invoke-WebRequest -Uri https://raw.githubusercontent.com/award999/github-workflows/refs/heads/dockerless-windows/.github/workflows/scripts/windows/install-vsb.ps1 -OutFile $env:TEMP\install-vsb.ps1 + . $env:TEMP\install-vsb.ps1 + del $env:TEMP\install-vsb.ps1 - name: Install Swift if: ${{ !inputs.enable_windows_docker }} run: | - Invoke-WebRequest -Uri https://raw.githubusercontent.com/award999/github-workflows/refs/heads/dockerless-windows/.github/workflows/scripts/windows/swift/install-swift.ps1 -OutFile install-swift.ps1 - Invoke-WebRequest -Uri https://raw.githubusercontent.com/award999/github-workflows/refs/heads/dockerless-windows/.github/workflows/scripts/windows/swift/install-swift-${{ matrix.swift_version }}.ps1 -OutFile install-swift-${{ matrix.swift_version }}.ps1 - . .\install-swift-${{ matrix.swift_version }}.ps1 - del .\install-swift*.ps1 + Invoke-WebRequest -Uri https://raw.githubusercontent.com/award999/github-workflows/refs/heads/dockerless-windows/.github/workflows/scripts/windows/swift/install-swift.ps1 -OutFile $env:TEMP\install-swift.ps1 + Invoke-WebRequest -Uri https://raw.githubusercontent.com/award999/github-workflows/refs/heads/dockerless-windows/.github/workflows/scripts/windows/swift/install-swift-${{ matrix.swift_version }}.ps1 -OutFile $env:TEMP\install-swift-${{ matrix.swift_version }}.ps1 + . $env:TEMP\install-swift-${{ matrix.swift_version }}.ps1 + del $env:TEMP\install-swift*.ps1 - name: Create test script run: | mkdir $env:TEMP\test-script + if ("${{ inputs.enable_windows_docker }}" -eq "true") { + $Source = C:\source + } else { + $Source = $env:GITHUB_WORKSPACE + } echo @' Set-PSDebug -Trace 1 @@ -152,12 +157,12 @@ jobs: } Invoke-Program swift --version Invoke-Program swift test --version - Invoke-Program cd C:\source\ + Invoke-Program cd $Source ${{ inputs.windows_pre_build_command }} Invoke-Program ${{ inputs.windows_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }} '@ >> $env:TEMP\test-script\run.ps1 # Docker build - - name: Build / Test + - name: Docker Build / Test timeout-minutes: 60 if: ${{ inputs.enable_windows_docker }} run: | @@ -166,4 +171,7 @@ jobs: - name: Build / Test timeout-minutes: 60 if: ${{ !inputs.enable_windows_docker }} - run: powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1 \ No newline at end of file + run: | + Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 + RefreshEnv + powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1; exit $LastExitCode \ No newline at end of file From e629e3705d3581acded1044f577c5ce0fb3fb4d8 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Tue, 12 Nov 2024 15:25:37 -0500 Subject: [PATCH 06/11] Use fixed vs_buildtols permalink --- .github/workflows/scripts/windows/install-vsb.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scripts/windows/install-vsb.ps1 b/.github/workflows/scripts/windows/install-vsb.ps1 index 5529a6e..e155006 100644 --- a/.github/workflows/scripts/windows/install-vsb.ps1 +++ b/.github/workflows/scripts/windows/install-vsb.ps1 @@ -1,5 +1,5 @@ -$VSB='https://aka.ms/vs/17/release/vs_buildtools.exe' -$VSB_SHA256='99C7677154366062A43082921F40F3CE00EF2614DBF94DB23B244DD13DC9443D' +$VSB='https://download.visualstudio.microsoft.com/download/pr/5536698c-711c-4834-876f-2817d31a2ef2/c792bdb0fd46155de19955269cac85d52c4c63c23db2cf43d96b9390146f9390/vs_BuildTools.exe' +$VSB_SHA256='C792BDB0FD46155DE19955269CAC85D52C4C63C23DB2CF43D96B9390146F9390' Set-Variable ErrorActionPreference Stop Set-Variable ProgressPreference SilentlyContinue Write-Host -NoNewLine ('Downloading {0} ... ' -f ${VSB}) From ed973bd5e5e61bbb1c234e7b7c19aa12b8bba225 Mon Sep 17 00:00:00 2001 From: Paul LeMarquand Date: Tue, 12 Nov 2024 22:10:45 -0500 Subject: [PATCH 07/11] Add Windows 5.10 to compatibility matrix --- .github/workflows/swift_package_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index ea23564..1051391 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -99,7 +99,7 @@ jobs: strategy: fail-fast: false matrix: - swift_version: ['5.9', '6.0', 'nightly', 'nightly-6.0'] + swift_version: ['5.9', '5.10', '6.0', 'nightly', 'nightly-6.0'] exclude: - ${{ fromJson(inputs.windows_exclude_swift_versions) }} steps: From bd4321fa0bc9ea7ae44991847d09096e8db77b3f Mon Sep 17 00:00:00 2001 From: Adam Ward Date: Tue, 3 Dec 2024 08:39:17 -0500 Subject: [PATCH 08/11] Add license headers --- .github/workflows/scripts/windows/install-vsb.ps1 | 11 +++++++++++ .../scripts/windows/swift/install-swift-5.10.ps1 | 11 +++++++++++ .../scripts/windows/swift/install-swift-5.9.ps1 | 11 +++++++++++ .../scripts/windows/swift/install-swift-6.0.ps1 | 11 +++++++++++ .../windows/swift/install-swift-nightly-6.0.ps1 | 11 +++++++++++ .../scripts/windows/swift/install-swift-nightly.ps1 | 11 +++++++++++ .../workflows/scripts/windows/swift/install-swift.ps1 | 11 +++++++++++ 7 files changed, 77 insertions(+) diff --git a/.github/workflows/scripts/windows/install-vsb.ps1 b/.github/workflows/scripts/windows/install-vsb.ps1 index e155006..931cbbb 100644 --- a/.github/workflows/scripts/windows/install-vsb.ps1 +++ b/.github/workflows/scripts/windows/install-vsb.ps1 @@ -1,3 +1,14 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2024 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## $VSB='https://download.visualstudio.microsoft.com/download/pr/5536698c-711c-4834-876f-2817d31a2ef2/c792bdb0fd46155de19955269cac85d52c4c63c23db2cf43d96b9390146f9390/vs_BuildTools.exe' $VSB_SHA256='C792BDB0FD46155DE19955269CAC85D52C4C63C23DB2CF43D96B9390146F9390' Set-Variable ErrorActionPreference Stop diff --git a/.github/workflows/scripts/windows/swift/install-swift-5.10.ps1 b/.github/workflows/scripts/windows/swift/install-swift-5.10.ps1 index 85daf4b..7775354 100644 --- a/.github/workflows/scripts/windows/swift/install-swift-5.10.ps1 +++ b/.github/workflows/scripts/windows/swift/install-swift-5.10.ps1 @@ -1,3 +1,14 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2024 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## . $PSScriptRoot\install-swift.ps1 $SWIFT='https://download.swift.org/swift-5.10.1-release/windows10/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-windows10.exe' diff --git a/.github/workflows/scripts/windows/swift/install-swift-5.9.ps1 b/.github/workflows/scripts/windows/swift/install-swift-5.9.ps1 index c34c02a..2d6ae97 100644 --- a/.github/workflows/scripts/windows/swift/install-swift-5.9.ps1 +++ b/.github/workflows/scripts/windows/swift/install-swift-5.9.ps1 @@ -1,3 +1,14 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2024 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## . $PSScriptRoot\install-swift.ps1 $SWIFT='https://download.swift.org/swift-5.9.2-release/windows10/swift-5.9.2-RELEASE/swift-5.9.2-RELEASE-windows10.exe' diff --git a/.github/workflows/scripts/windows/swift/install-swift-6.0.ps1 b/.github/workflows/scripts/windows/swift/install-swift-6.0.ps1 index 82cbd14..da32267 100644 --- a/.github/workflows/scripts/windows/swift/install-swift-6.0.ps1 +++ b/.github/workflows/scripts/windows/swift/install-swift-6.0.ps1 @@ -1,3 +1,14 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2024 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## . $PSScriptRoot\install-swift.ps1 $SWIFT='https://download.swift.org/swift-6.0.2-release/windows10/swift-6.0.2-RELEASE/swift-6.0.2-RELEASE-windows10.exe' diff --git a/.github/workflows/scripts/windows/swift/install-swift-nightly-6.0.ps1 b/.github/workflows/scripts/windows/swift/install-swift-nightly-6.0.ps1 index 6641f38..df8f224 100644 --- a/.github/workflows/scripts/windows/swift/install-swift-nightly-6.0.ps1 +++ b/.github/workflows/scripts/windows/swift/install-swift-nightly-6.0.ps1 @@ -1,3 +1,14 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2024 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## . $PSScriptRoot\install-swift.ps1 $SWIFT_RELEASE_METADATA='http://download.swift.org/swift-6.0-branch/windows10/latest-build.json' diff --git a/.github/workflows/scripts/windows/swift/install-swift-nightly.ps1 b/.github/workflows/scripts/windows/swift/install-swift-nightly.ps1 index d8e8ad4..9c0c154 100644 --- a/.github/workflows/scripts/windows/swift/install-swift-nightly.ps1 +++ b/.github/workflows/scripts/windows/swift/install-swift-nightly.ps1 @@ -1,3 +1,14 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2024 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## . $PSScriptRoot\install-swift.ps1 $SWIFT_RELEASE_METADATA='http://download.swift.org/development/windows10/latest-build.json' diff --git a/.github/workflows/scripts/windows/swift/install-swift.ps1 b/.github/workflows/scripts/windows/swift/install-swift.ps1 index f81c5d8..811a53d 100644 --- a/.github/workflows/scripts/windows/swift/install-swift.ps1 +++ b/.github/workflows/scripts/windows/swift/install-swift.ps1 @@ -1,3 +1,14 @@ +##===----------------------------------------------------------------------===## +## +## This source file is part of the Swift.org open source project +## +## Copyright (c) 2024 Apple Inc. and the Swift project authors +## Licensed under Apache License v2.0 with Runtime Library Exception +## +## See https://swift.org/LICENSE.txt for license information +## See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +## +##===----------------------------------------------------------------------===## function Install-Swift { param ( [string]$Url, From 3caeb39a6e622c3eea6a239ca4b49ec484c3a335 Mon Sep 17 00:00:00 2001 From: Adam Ward Date: Tue, 3 Dec 2024 08:41:54 -0500 Subject: [PATCH 09/11] Remove unneeded action --- .../workflows/actions/install-vsb/action.yml | 8 ----- .../actions/install-vsb/install-vsb.ps1 | 32 ------------------- 2 files changed, 40 deletions(-) delete mode 100644 .github/workflows/actions/install-vsb/action.yml delete mode 100644 .github/workflows/actions/install-vsb/install-vsb.ps1 diff --git a/.github/workflows/actions/install-vsb/action.yml b/.github/workflows/actions/install-vsb/action.yml deleted file mode 100644 index 35c9bbc..0000000 --- a/.github/workflows/actions/install-vsb/action.yml +++ /dev/null @@ -1,8 +0,0 @@ -name: Install Visual Studio Tools -description: Installs Visual Studio Tools -runs: - using: composite - steps: - - name: Run Script - shell: powershell - run: .\install-vsb.ps1 \ No newline at end of file diff --git a/.github/workflows/actions/install-vsb/install-vsb.ps1 b/.github/workflows/actions/install-vsb/install-vsb.ps1 deleted file mode 100644 index 5529a6e..0000000 --- a/.github/workflows/actions/install-vsb/install-vsb.ps1 +++ /dev/null @@ -1,32 +0,0 @@ -$VSB='https://aka.ms/vs/17/release/vs_buildtools.exe' -$VSB_SHA256='99C7677154366062A43082921F40F3CE00EF2614DBF94DB23B244DD13DC9443D' -Set-Variable ErrorActionPreference Stop -Set-Variable ProgressPreference SilentlyContinue -Write-Host -NoNewLine ('Downloading {0} ... ' -f ${VSB}) -Invoke-WebRequest -Uri $VSB -OutFile $env:TEMP\vs_buildtools.exe -Write-Host 'SUCCESS' -Write-Host -NoNewLine ('Verifying SHA256 ({0}) ... ' -f $VSB_SHA256) -$Hash = Get-FileHash $env:TEMP\vs_buildtools.exe -Algorithm sha256 -if ($Hash.Hash -eq $VSB_SHA256) { - Write-Host 'SUCCESS' -} else { - Write-Host ('FAILED ({0})' -f $Hash.Hash) - exit 1 -} -Write-Host -NoNewLine 'Installing Visual Studio Build Tools ... ' -$Process = - Start-Process $env:TEMP\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 'SUCCESS' -} else { - Write-Host ('FAILED ({0})' -f $Process.ExitCode) - exit 1 -} -Remove-Item -Force $env:TEMP\vs_buildtools.exe \ No newline at end of file From 0c25c6cda0972826f5637b9286d927366d4082c4 Mon Sep 17 00:00:00 2001 From: Adam Ward Date: Tue, 3 Dec 2024 08:44:07 -0500 Subject: [PATCH 10/11] Update urls for swiftlang repo --- .github/workflows/swift_package_test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 1051391..312eac4 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -126,14 +126,14 @@ jobs: - name: Install Visual Studio Build Tools if: ${{ !inputs.enable_windows_docker }} run: | - Invoke-WebRequest -Uri https://raw.githubusercontent.com/award999/github-workflows/refs/heads/dockerless-windows/.github/workflows/scripts/windows/install-vsb.ps1 -OutFile $env:TEMP\install-vsb.ps1 + Invoke-WebRequest -Uri https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/windows/install-vsb.ps1 -OutFile $env:TEMP\install-vsb.ps1 . $env:TEMP\install-vsb.ps1 del $env:TEMP\install-vsb.ps1 - name: Install Swift if: ${{ !inputs.enable_windows_docker }} run: | - Invoke-WebRequest -Uri https://raw.githubusercontent.com/award999/github-workflows/refs/heads/dockerless-windows/.github/workflows/scripts/windows/swift/install-swift.ps1 -OutFile $env:TEMP\install-swift.ps1 - Invoke-WebRequest -Uri https://raw.githubusercontent.com/award999/github-workflows/refs/heads/dockerless-windows/.github/workflows/scripts/windows/swift/install-swift-${{ matrix.swift_version }}.ps1 -OutFile $env:TEMP\install-swift-${{ matrix.swift_version }}.ps1 + Invoke-WebRequest -Uri https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/windows/swift/install-swift.ps1 -OutFile $env:TEMP\install-swift.ps1 + Invoke-WebRequest -Uri https://raw.githubusercontent.com/swiftlang/github-workflows/refs/heads/main/.github/workflows/scripts/windows/swift/install-swift-${{ matrix.swift_version }}.ps1 -OutFile $env:TEMP\install-swift-${{ matrix.swift_version }}.ps1 . $env:TEMP\install-swift-${{ matrix.swift_version }}.ps1 del $env:TEMP\install-swift*.ps1 - name: Create test script From 948d7c6de17310173b156131491c5eb96d25a888 Mon Sep 17 00:00:00 2001 From: Adam Ward Date: Tue, 3 Dec 2024 08:45:29 -0500 Subject: [PATCH 11/11] Fix YAML lint --- .github/workflows/swift_package_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/swift_package_test.yml b/.github/workflows/swift_package_test.yml index 312eac4..92135bd 100644 --- a/.github/workflows/swift_package_test.yml +++ b/.github/workflows/swift_package_test.yml @@ -174,4 +174,4 @@ jobs: run: | Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1 RefreshEnv - powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1; exit $LastExitCode \ No newline at end of file + powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1; exit $LastExitCode