45
45
linux_env_vars :
46
46
description : " List of environment variables"
47
47
type : string
48
+ windows_env_vars :
49
+ description : " List of environment variables"
50
+ type : string
51
+ enable_linux_checks :
52
+ type : boolean
53
+ description : " Boolean to enable linux testing. Defaults to true"
54
+ default : true
48
55
enable_windows_checks :
49
56
type : boolean
50
57
description : " Boolean to enable windows testing. Defaults to true"
51
58
default : true
59
+ enable_windows_docker :
60
+ type : boolean
61
+ description : " Boolean to enable running build in windows docker container. Defaults to true"
62
+ default : true
52
63
53
64
jobs :
54
65
linux-build :
55
66
name : Linux (${{ matrix.swift_version }} - ${{ matrix.os_version }})
67
+ if : ${{ inputs.enable_linux_checks }}
56
68
runs-on : ubuntu-latest
57
69
strategy :
58
70
fail-fast : false
@@ -87,14 +99,22 @@ jobs:
87
99
strategy :
88
100
fail-fast : false
89
101
matrix :
90
- swift_version : ['5.9', '6.0', 'nightly', 'nightly-6.0']
102
+ swift_version : ['5.9', '5.10', ' 6.0', 'nightly', 'nightly-6.0']
91
103
exclude :
92
104
- ${{ fromJson(inputs.windows_exclude_swift_versions) }}
93
105
steps :
94
106
- name : Checkout repository
95
107
uses : actions/checkout@v4
108
+ - name : Set environment variables
109
+ if : ${{ inputs.windows_env_vars }}
110
+ run : |
111
+ $lines = "${{ inputs.windows_env_vars }}" -split "`r`n"
112
+ foreach ($line in $lines) {
113
+ echo $line | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
114
+ }
96
115
- name : Pull Docker image
97
116
id : pull_docker_image
117
+ if : ${{ inputs.enable_windows_docker }}
98
118
run : |
99
119
if ("${{ matrix.swift_version }}".Contains("nightly")) {
100
120
$Image = "swiftlang/swift:${{ matrix.swift_version }}-windowsservercore-1809"
@@ -103,9 +123,27 @@ jobs:
103
123
}
104
124
docker pull $Image
105
125
echo "image=$Image" >> "$env:GITHUB_OUTPUT"
126
+ - name : Install Visual Studio Build Tools
127
+ if : ${{ !inputs.enable_windows_docker }}
128
+ run : |
129
+ 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
130
+ . $env:TEMP\install-vsb.ps1
131
+ del $env:TEMP\install-vsb.ps1
132
+ - name : Install Swift
133
+ if : ${{ !inputs.enable_windows_docker }}
134
+ run : |
135
+ 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
136
+ 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
137
+ . $env:TEMP\install-swift-${{ matrix.swift_version }}.ps1
138
+ del $env:TEMP\install-swift*.ps1
106
139
- name : Create test script
107
140
run : |
108
141
mkdir $env:TEMP\test-script
142
+ if ("${{ inputs.enable_windows_docker }}" -eq "true") {
143
+ $Source = C:\source
144
+ } else {
145
+ $Source = $env:GITHUB_WORKSPACE
146
+ }
109
147
echo @'
110
148
Set-PSDebug -Trace 1
111
149
@@ -119,11 +157,21 @@ jobs:
119
157
}
120
158
Invoke-Program swift --version
121
159
Invoke-Program swift test --version
122
- Invoke-Program cd C:\source\
160
+ Invoke-Program cd $Source
123
161
${{ inputs.windows_pre_build_command }}
124
162
Invoke-Program ${{ inputs.windows_build_command }} ${{ (contains(matrix.swift_version, 'nightly') && inputs.swift_nightly_flags) || inputs.swift_flags }}
125
163
'@ >> $env:TEMP\test-script\run.ps1
126
- - name : Build / Test
164
+ # Docker build
165
+ - name : Docker Build / Test
127
166
timeout-minutes : 60
167
+ if : ${{ inputs.enable_windows_docker }}
128
168
run : |
129
169
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
170
+ # Docker-less build
171
+ - name : Build / Test
172
+ timeout-minutes : 60
173
+ if : ${{ !inputs.enable_windows_docker }}
174
+ run : |
175
+ Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
176
+ RefreshEnv
177
+ powershell.exe -NoLogo -File $env:TEMP\test-script\run.ps1; exit $LastExitCode
0 commit comments