From 73bdc1e0de3e0ac5924f0288fed30177e8dd46bd Mon Sep 17 00:00:00 2001 From: Dan Hensby Date: Sun, 3 Sep 2023 23:47:22 +0100 Subject: [PATCH 1/2] fix: make sure default version of sqlserver-version is used --- src/utils.ts | 2 +- test/utils.ts | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 732b025..d1ca923 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -56,7 +56,7 @@ export interface Inputs { * @returns {Inputs} */ export function gatherInputs(): Inputs { - const version = core.getInput('sqlserver-version').replace(/sql-/i, ''); + const version = core.getInput('sqlserver-version').replace(/sql-/i, '') || 'latest'; return { version: version.toLowerCase() === 'latest' ? '2022' : version, password: core.getInput('sa-password'), diff --git a/test/utils.ts b/test/utils.ts index 65ef305..a9db45b 100644 --- a/test/utils.ts +++ b/test/utils.ts @@ -234,6 +234,23 @@ describe('utils', () => { skipOsCheck: false, }); }); + it('constructs input object with default version', () => { + coreStub.getInput.withArgs('sqlserver-version').returns(''); + coreStub.getInput.withArgs('sa-password').returns('secret password'); + coreStub.getInput.withArgs('db-collation').returns('SQL_Latin1_General_CP1_CI_AS'); + coreStub.getMultilineInput.withArgs('install-arguments').returns([]); + coreStub.getBooleanInput.withArgs('wait-for-ready').returns(true); + coreStub.getBooleanInput.withArgs('skip-os-check').returns(false); + const res = utils.gatherInputs(); + expect(res).to.deep.equal({ + version: '2022', + password: 'secret password', + collation: 'SQL_Latin1_General_CP1_CI_AS', + installArgs: [], + wait: true, + skipOsCheck: false, + }); + }); }); describe('.downloadTool()', () => { let downloadStub: SinonStubbedMember; From 75578c8a48c44e574a8965bd4f952d79f852af4d Mon Sep 17 00:00:00 2001 From: Dan Hensby Date: Mon, 4 Sep 2023 00:13:11 +0100 Subject: [PATCH 2/2] fix: dont look for summary files if install not attempted --- src/install.ts | 68 +++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/src/install.ts b/src/install.ts index 9fa3bf5..fd26389 100644 --- a/src/install.ts +++ b/src/install.ts @@ -32,44 +32,44 @@ function findOrDownloadTool(config: VersionConfig): Promise { } export default async function install() { - try { - const { version, password, collation, installArgs, wait, skipOsCheck } = gatherInputs(); - // we only support windows for now. But allow crazy people to skip this check if they like... - if (!skipOsCheck && os.platform() !== 'win32') { - throw new Error(`setup-sqlserver only supports Windows runners, got: ${os.platform()}`); - } - const osVersion = await getOsVersion(); - if (!VERSIONS.has(version)) { - throw new Error(`Unsupported SQL Version, supported versions are ${Array.from(VERSIONS.keys()).join(', ')}, got: ${version}`); - } - const config = VERSIONS.get(version)!; - // try to fail fast if the OS is not supported - if (config.osSupport) { - const { min, max } = config.osSupport; - // allow checks to be skipped - if (skipOsCheck) { - core.info('Skipping OS checks'); - } else if (!osVersion) { - core.notice('Unable to determine OS version, continuing tentatively'); - } else if ((min && min > osVersion) || (max && max < osVersion)) { - // construct a helpful error - let message = 'Please use '; + const { version, password, collation, installArgs, wait, skipOsCheck } = gatherInputs(); + // we only support windows for now. But allow crazy people to skip this check if they like... + if (!skipOsCheck && os.platform() !== 'win32') { + throw new Error(`setup-sqlserver only supports Windows runners, got: ${os.platform()}`); + } + const osVersion = await getOsVersion(); + if (!VERSIONS.has(version)) { + throw new Error(`Unsupported SQL Version, supported versions are ${Array.from(VERSIONS.keys()).join(', ')}, got: ${version}`); + } + const config = VERSIONS.get(version)!; + // try to fail fast if the OS is not supported + if (config.osSupport) { + const { min, max } = config.osSupport; + // allow checks to be skipped + if (skipOsCheck) { + core.info('Skipping OS checks'); + } else if (!osVersion) { + core.notice('Unable to determine OS version, continuing tentatively'); + } else if ((min && min > osVersion) || (max && max < osVersion)) { + // construct a helpful error + let message = 'Please use '; + if (min) { + message += `windows-${min}`; + } + if (max) { if (min) { - message += `windows-${min}`; - } - if (max) { - if (min) { - message += ' to '; - } - message += `windows-${max}`; + message += ' to '; } - message += '.'; - throw new Error(`Runner version windows-${osVersion} is not supported for SQL Server ${version}. ${message}`); + message += `windows-${max}`; } + message += '.'; + throw new Error(`Runner version windows-${osVersion} is not supported for SQL Server ${version}. ${message}`); } - // Initial checks complete - fetch the installer - const toolPath = await core.group(`Fetching install media for ${version}`, () => findOrDownloadTool(config)); - const instanceName = 'MSSQLSERVER'; + } + // Initial checks complete - fetch the installer + const toolPath = await core.group(`Fetching install media for ${version}`, () => findOrDownloadTool(config)); + const instanceName = 'MSSQLSERVER'; + try { // @todo - make sure that the arguments are unique / don't conflict await core.group('Installing SQL Server', () => exec.exec(`"${toolPath}"`, [ '/q',