Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerless windows #67

Merged
merged 12 commits into from
Dec 3, 2024
43 changes: 43 additions & 0 deletions .github/workflows/scripts/windows/install-vsb.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
##===----------------------------------------------------------------------===##
##
## 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
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
17 changes: 17 additions & 0 deletions .github/workflows/scripts/windows/swift/install-swift-5.10.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
##===----------------------------------------------------------------------===##
##
## 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'
$SWIFT_SHA256='3027762138ACFA1BBE3050FF6613BBE754332E84C9EFA5C23984646009297286'

Install-Swift -Url $SWIFT -Sha256 $SWIFT_SHA256
17 changes: 17 additions & 0 deletions .github/workflows/scripts/windows/swift/install-swift-5.9.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
##===----------------------------------------------------------------------===##
##
## 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'
$SWIFT_SHA256='D78A717551C78E824C9B74B0CFB1AD86060FC286EA071FDDB26DF18F56DC7212'

Install-Swift -Url $SWIFT -Sha256 $SWIFT_SHA256
17 changes: 17 additions & 0 deletions .github/workflows/scripts/windows/swift/install-swift-6.0.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
##===----------------------------------------------------------------------===##
##
## 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'
$SWIFT_SHA256='516FE8E64713BD92F03C01E5198011B74A27F8C1C88627607A2F421718636126'

Install-Swift -Url $SWIFT -Sha256 $SWIFT_SHA256
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
##===----------------------------------------------------------------------===##
##
## 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'
$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 ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
##===----------------------------------------------------------------------===##
##
## 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'
$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 ""
42 changes: 42 additions & 0 deletions .github/workflows/scripts/windows/swift/install-swift.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
##===----------------------------------------------------------------------===##
##
## 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,
[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
}
54 changes: 51 additions & 3 deletions .github/workflows/swift_package_test.yml
Original file line number Diff line number Diff line change
@@ -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
@@ -87,14 +99,22 @@ 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:
- 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,9 +123,27 @@ jobs:
}
docker pull $Image
echo "image=$Image" >> "$env:GITHUB_OUTPUT"
- name: Install Visual Studio Build Tools
if: ${{ !inputs.enable_windows_docker }}
run: |
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/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
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
@@ -119,11 +157,21 @@ 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
- name: Build / Test
# Docker build
- name: Docker 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: |
Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
RefreshEnv
powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1; exit $LastExitCode