Skip to content
Merged
3 changes: 3 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ jobs:
- os: windows-latest
swift: '5.9' # 2nd installation approach
development: false
- os: windows-2019
swift: '5.3'
development: false
- os: ubuntu-latest
swift: '5.3.0' # oldest
development: false
Expand Down
26 changes: 22 additions & 4 deletions __tests__/installer/windows.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as os from 'os'
import * as path from 'path'
import {promises as fs} from 'fs'
import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as cache from '@actions/cache'
import * as toolCache from '@actions/tool-cache'
import os from 'os'
import {coerce as parseSemVer} from 'semver'
import {WindowsToolchainInstaller} from '../../src/installer/windows'
import {VisualStudio} from '../../src/utils/visual_studio'
Expand All @@ -24,15 +24,15 @@ describe('windows toolchain installation verification', () => {
}
const visualStudio = VisualStudio.createFromJSON({
installationPath: path.join('C:', 'Visual Studio'),
installationVersion: '16',
catalog: {productDisplayVersion: '16'},
installationVersion: '17',
catalog: {productDisplayVersion: '17'},
properties: {
setupEngineFilePath: path.join('C:', 'Visual Studio', 'setup.exe')
}
})
const vsEnvs = [
`UniversalCRTSdkDir=${path.join('C:', 'Windows Kits')}`,
`UCRTVersion=10.0.17063`,
`UCRTVersion=10.0.22000`,
`VCToolsInstallDir=${path.join('C:', 'Visual Studio', 'Tools')}`
]

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

it('tests setting up on Windows 10', async () => {
jest.spyOn(os, 'release').mockReturnValue('10.0.17063')
const installer = new WindowsToolchainInstaller(toolchain)
expect(installer['vsRequirement'].components).toStrictEqual([
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
'Microsoft.VisualStudio.Component.Windows10SDK.17763'
])
})

it('tests setting up on Windows 11', async () => {
jest.spyOn(os, 'release').mockReturnValue('10.0.22621')
const installer = new WindowsToolchainInstaller(toolchain)
expect(installer['vsRequirement'].components).toStrictEqual([
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
'Microsoft.VisualStudio.Component.Windows11SDK.22621'
])
})

it('tests download without caching', async () => {
const installer = new WindowsToolchainInstaller(toolchain)
expect(installer['version']).toStrictEqual(parseSemVer('5.8'))
Expand Down
4 changes: 2 additions & 2 deletions __tests__/utils/visual_studio/setup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe('visual studio setup validation', () => {
const env = process.env
const visualStudio = VisualStudio.createFromJSON({
installationPath: path.join('C:', 'Visual Studio'),
installationVersion: '16',
catalog: {productDisplayVersion: '16'},
installationVersion: '17',
catalog: {productDisplayVersion: '17'},
properties: {
setupEngineFilePath: path.join('C:', 'Visual Studio', 'setup.exe')
}
Expand Down
16 changes: 11 additions & 5 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions src/installer/windows/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,24 @@ import {VisualStudio} from '../../utils'
import {Installation, CustomInstallation} from './installation'

export class WindowsToolchainInstaller extends VerifyingToolchainInstaller<WindowsToolchainSnapshot> {
private get vsRequirement() {
const reccommended = '10.0.17763'
private get winsdk() {
const recommended = '10.0.17763'
const win11Semver = '10.0.22000'
const current = os.release()
const version = semver.gte(current, reccommended) ? current : reccommended
const winsdk = semver.patch(version)
const version = semver.gte(current, recommended) ? current : recommended
const major = semver.lt(version, win11Semver) ? semver.major(version) : 11
const minor = semver.patch(version)
return `Microsoft.VisualStudio.Component.Windows${major}SDK.${minor}`
}

private get vsRequirement() {
const componentsStr = core.getInput('visual-studio-components')
const providedComponents = componentsStr ? componentsStr.split(';') : []
return {
version: '16',
components: [
'Microsoft.VisualStudio.Component.VC.Tools.x86.x64',
`Microsoft.VisualStudio.Component.Windows10SDK.${winsdk}`,
this.winsdk,
...providedComponents
]
}
Expand Down Expand Up @@ -82,6 +88,7 @@ export class WindowsToolchainInstaller extends VerifyingToolchainInstaller<Windo
}

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