diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4259efd..4480c25 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/__tests__/installer/windows.test.ts b/__tests__/installer/windows.test.ts index 1b8f636..9c06d6d 100644 --- a/__tests__/installer/windows.test.ts +++ b/__tests__/installer/windows.test.ts @@ -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' @@ -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')}` ] @@ -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')) diff --git a/__tests__/utils/visual_studio/setup.test.ts b/__tests__/utils/visual_studio/setup.test.ts index 2ed7f32..555fbdd 100644 --- a/__tests__/utils/visual_studio/setup.test.ts +++ b/__tests__/utils/visual_studio/setup.test.ts @@ -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') } diff --git a/dist/index.js b/dist/index.js index 77a500c..4232e7e 100644 --- a/dist/index.js +++ b/dist/index.js @@ -450,18 +450,23 @@ const verify_1 = __nccwpck_require__(6298); const utils_1 = __nccwpck_require__(1750); const installation_1 = __nccwpck_require__(4694); class WindowsToolchainInstaller extends verify_1.VerifyingToolchainInstaller { - get vsRequirement() { - const reccommended = '10.0.17763'; + 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}`; + } + 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 ] }; @@ -518,6 +523,7 @@ class WindowsToolchainInstaller extends verify_1.VerifyingToolchainInstaller { return; } const visualStudio = await utils_1.VisualStudio.setup(this.vsRequirement); + // FIXME(stevapple): This is no longer required for Swift 5.9+ await visualStudio.update(sdkroot); const swiftFlags = [ '-sdk', diff --git a/src/installer/windows/index.ts b/src/installer/windows/index.ts index e9f1cd5..7a84dd0 100644 --- a/src/installer/windows/index.ts +++ b/src/installer/windows/index.ts @@ -9,18 +9,24 @@ import {VisualStudio} from '../../utils' import {Installation, CustomInstallation} from './installation' export class WindowsToolchainInstaller extends VerifyingToolchainInstaller { - 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 ] } @@ -82,6 +88,7 @@ export class WindowsToolchainInstaller extends VerifyingToolchainInstaller