Skip to content
8 changes: 8 additions & 0 deletions .github/workflows/actions/install-vsb/action.yml
Original file line number Diff line number Diff line change
@@ -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

Check failure on line 8 in .github/workflows/actions/install-vsb/action.yml

View workflow job for this annotation

GitHub Actions / Soundness / YAML lint check

8:29 [new-line-at-end-of-file] no new line character at the end of file
32 changes: 32 additions & 0 deletions .github/workflows/actions/install-vsb/install-vsb.ps1
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions .github/workflows/scripts/windows/install-vsb.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
$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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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 ""
Original file line number Diff line number Diff line change
@@ -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 ""
31 changes: 31 additions & 0 deletions .github/workflows/scripts/windows/swift/install-swift.ps1
Original file line number Diff line number Diff line change
@@ -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
}
54 changes: 51 additions & 3 deletions .github/workflows/swift_package_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,26 @@
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
Expand Down Expand Up @@ -87,14 +99,22 @@
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"
Expand All @@ -103,9 +123,27 @@
}
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/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 $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

Expand All @@ -119,11 +157,21 @@
}
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

Check failure on line 177 in .github/workflows/swift_package_test.yml

View workflow job for this annotation

GitHub Actions / Soundness / YAML lint check

177:89 [new-line-at-end-of-file] no new line character at the end of file
Loading