Skip to content

Commit 6efadfd

Browse files
feat: support Windows 11 SDK (#334)
* feat: support Windows 11 SDK * feat: update Visual Studio and Windows SDK * fix: fixme for support file setup * fix: run linter * fix: update test to use Visual Studio 2022 * fix: Windows version judgement was accidentally inverted * fix: revert some Visual Studio requirement changes * build: update `dist/index.js` * test: mock Windows 10 and 11 for SDK resolution * chore: integration test for Windows Server 2019 --------- Co-authored-by: YR Chen <[email protected]>
1 parent 1cab733 commit 6efadfd

File tree

5 files changed

+50
-16
lines changed

5 files changed

+50
-16
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ jobs:
168168
- os: windows-latest
169169
swift: '5.9' # 2nd installation approach
170170
development: false
171+
- os: windows-2019
172+
swift: '5.3'
173+
development: false
171174
- os: ubuntu-latest
172175
swift: '5.3.0' # oldest
173176
development: false

__tests__/installer/windows.test.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import * as os from 'os'
21
import * as path from 'path'
32
import {promises as fs} from 'fs'
43
import * as core from '@actions/core'
54
import * as exec from '@actions/exec'
65
import * as cache from '@actions/cache'
76
import * as toolCache from '@actions/tool-cache'
7+
import os from 'os'
88
import {coerce as parseSemVer} from 'semver'
99
import {WindowsToolchainInstaller} from '../../src/installer/windows'
1010
import {VisualStudio} from '../../src/utils/visual_studio'
@@ -24,15 +24,15 @@ describe('windows toolchain installation verification', () => {
2424
}
2525
const visualStudio = VisualStudio.createFromJSON({
2626
installationPath: path.join('C:', 'Visual Studio'),
27-
installationVersion: '16',
28-
catalog: {productDisplayVersion: '16'},
27+
installationVersion: '17',
28+
catalog: {productDisplayVersion: '17'},
2929
properties: {
3030
setupEngineFilePath: path.join('C:', 'Visual Studio', 'setup.exe')
3131
}
3232
})
3333
const vsEnvs = [
3434
`UniversalCRTSdkDir=${path.join('C:', 'Windows Kits')}`,
35-
`UCRTVersion=10.0.17063`,
35+
`UCRTVersion=10.0.22000`,
3636
`VCToolsInstallDir=${path.join('C:', 'Visual Studio', 'Tools')}`
3737
]
3838

@@ -59,6 +59,24 @@ describe('windows toolchain installation verification', () => {
5959
])
6060
})
6161

62+
it('tests setting up on Windows 10', async () => {
63+
jest.spyOn(os, 'release').mockReturnValue('10.0.17063')
64+
const installer = new WindowsToolchainInstaller(toolchain)
65+
expect(installer['vsRequirement'].components).toStrictEqual([
66+
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
67+
'Microsoft.VisualStudio.Component.Windows10SDK.17763'
68+
])
69+
})
70+
71+
it('tests setting up on Windows 11', async () => {
72+
jest.spyOn(os, 'release').mockReturnValue('10.0.22621')
73+
const installer = new WindowsToolchainInstaller(toolchain)
74+
expect(installer['vsRequirement'].components).toStrictEqual([
75+
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
76+
'Microsoft.VisualStudio.Component.Windows11SDK.22621'
77+
])
78+
})
79+
6280
it('tests download without caching', async () => {
6381
const installer = new WindowsToolchainInstaller(toolchain)
6482
expect(installer['version']).toStrictEqual(parseSemVer('5.8'))

__tests__/utils/visual_studio/setup.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ describe('visual studio setup validation', () => {
77
const env = process.env
88
const visualStudio = VisualStudio.createFromJSON({
99
installationPath: path.join('C:', 'Visual Studio'),
10-
installationVersion: '16',
11-
catalog: {productDisplayVersion: '16'},
10+
installationVersion: '17',
11+
catalog: {productDisplayVersion: '17'},
1212
properties: {
1313
setupEngineFilePath: path.join('C:', 'Visual Studio', 'setup.exe')
1414
}

dist/index.js

Lines changed: 11 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/installer/windows/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,24 @@ import {VisualStudio} from '../../utils'
99
import {Installation, CustomInstallation} from './installation'
1010

1111
export class WindowsToolchainInstaller extends VerifyingToolchainInstaller<WindowsToolchainSnapshot> {
12-
private get vsRequirement() {
13-
const reccommended = '10.0.17763'
12+
private get winsdk() {
13+
const recommended = '10.0.17763'
14+
const win11Semver = '10.0.22000'
1415
const current = os.release()
15-
const version = semver.gte(current, reccommended) ? current : reccommended
16-
const winsdk = semver.patch(version)
16+
const version = semver.gte(current, recommended) ? current : recommended
17+
const major = semver.lt(version, win11Semver) ? semver.major(version) : 11
18+
const minor = semver.patch(version)
19+
return `Microsoft.VisualStudio.Component.Windows${major}SDK.${minor}`
20+
}
21+
22+
private get vsRequirement() {
1723
const componentsStr = core.getInput('visual-studio-components')
1824
const providedComponents = componentsStr ? componentsStr.split(';') : []
1925
return {
2026
version: '16',
2127
components: [
2228
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
23-
`Microsoft.VisualStudio.Component.Windows10SDK.${winsdk}`,
29+
this.winsdk,
2430
...providedComponents
2531
]
2632
}
@@ -82,6 +88,7 @@ export class WindowsToolchainInstaller extends VerifyingToolchainInstaller<Windo
8288
}
8389

8490
const visualStudio = await VisualStudio.setup(this.vsRequirement)
91+
// FIXME(stevapple): This is no longer required for Swift 5.9+
8592
await visualStudio.update(sdkroot)
8693
const swiftFlags = [
8794
'-sdk',

0 commit comments

Comments
 (0)