-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add SQL Native Client 11.0 installer
- Loading branch information
Showing
10 changed files
with
170 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as core from '@actions/core'; | ||
import * as tc from '@actions/tool-cache'; | ||
import * as exec from '@actions/exec'; | ||
import { downloadTool } from './utils'; | ||
import { join as joinPaths } from 'path'; | ||
|
||
const x64_URL = 'https://download.microsoft.com/download/B/E/D/BED73AAC-3C8A-43F5-AF4F-EB4FEA6C8F3A/ENU/x64/sqlncli.msi'; | ||
const x86_URL = 'https://download.microsoft.com/download/B/E/D/BED73AAC-3C8A-43F5-AF4F-EB4FEA6C8F3A/ENU/x86/sqlncli.msi'; | ||
|
||
export default async function installNativeClient(version: number) { | ||
if (version !== 11) { | ||
throw new Error('Unsupported Native Client version, only 11 is valid.'); | ||
} | ||
const arch = process.arch === 'x64' ? 'x64' : 'x86'; | ||
let path = tc.find('sqlncli', '11.0', arch); | ||
if (!path) { | ||
core.info(`Downloading client installer for ${arch}.`); | ||
path = await downloadTool(arch === 'x64' ? x64_URL : x86_URL).then((tmp) => { | ||
return tc.cacheFile(tmp, 'sqlncli.msi', 'sqlncli', '11.0', arch); | ||
}); | ||
} else { | ||
core.info('Loaded client installer from cache.'); | ||
} | ||
path = joinPaths(path, 'sqlncli.msi'); | ||
core.info('Installing SQL Native Client 11.0'); | ||
// see https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2012/ms131321(v=sql.110) | ||
await exec.exec('msiexec', [ | ||
'/passive', | ||
'/i', | ||
path, | ||
'APPGUID={0CC618CE-F36A-415E-84B4-FB1BFF6967E1}', | ||
'IACCEPTSQLNCLILICENSETERMS=YES', | ||
], { | ||
windowsVerbatimArguments: true, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { match, restore, SinonStubbedInstance, stub } from 'sinon'; | ||
import * as core from '@actions/core'; | ||
import * as tc from '@actions/tool-cache'; | ||
import * as exec from '@actions/exec'; | ||
import * as utils from '../src/utils'; | ||
import installNativeClient from '../src/install-native-client'; | ||
import { expect, use } from 'chai'; | ||
import sinonChai from 'sinon-chai'; | ||
use(sinonChai); | ||
|
||
describe('install-native-client', () => { | ||
// let coreStub: SinonStubbedInstance<typeof core>; | ||
let tcStub: SinonStubbedInstance<typeof tc>; | ||
let execStub: SinonStubbedInstance<typeof exec>; | ||
let utilsStub: SinonStubbedInstance<typeof utils>; | ||
let arch: PropertyDescriptor; | ||
beforeEach('stub deps', () => { | ||
stub(core); | ||
arch = Object.getOwnPropertyDescriptor(process, 'arch')!; | ||
tcStub = stub(tc); | ||
tcStub.find.returns(''); | ||
execStub = stub(exec); | ||
execStub.exec.resolves(); | ||
utilsStub = stub(utils); | ||
utilsStub.downloadTool.resolves('c:/tmp/downloads'); | ||
}); | ||
afterEach('restore stubs', () => { | ||
Object.defineProperty(process, 'arch', arch); | ||
restore(); | ||
}); | ||
describe('.installNativeClient()', () => { | ||
it('throws for bad version', async () => { | ||
try { | ||
await installNativeClient(10); | ||
} catch (e) { | ||
expect(e).to.have.property('message', 'Unsupported Native Client version, only 11 is valid.'); | ||
return; | ||
} | ||
expect.fail('expected to throw'); | ||
}); | ||
it('installs from cache', async () => { | ||
tcStub.find.returns('C:/tmp/'); | ||
await installNativeClient(11); | ||
expect(utilsStub.downloadTool).to.have.callCount(0); | ||
expect(execStub.exec).to.have.been.calledOnceWith('msiexec', match.array, { | ||
windowsVerbatimArguments: true, | ||
}); | ||
expect(execStub.exec.firstCall.args[1]).to.contain('C:/tmp/sqlncli.msi'); | ||
}); | ||
it('installs from web (x64)', async () => { | ||
Object.defineProperty(process, 'arch', { | ||
value: 'x64', | ||
}); | ||
tcStub.cacheFile.resolves('C:/tmp/cache/'); | ||
await installNativeClient(11); | ||
expect(utilsStub.downloadTool).to.have.been.calledOnceWith('https://download.microsoft.com/download/B/E/D/BED73AAC-3C8A-43F5-AF4F-EB4FEA6C8F3A/ENU/x64/sqlncli.msi'); | ||
expect(tcStub.cacheFile).to.have.callCount(1); | ||
expect(execStub.exec).to.have.been.calledOnceWith('msiexec', match.array, { | ||
windowsVerbatimArguments: true, | ||
}); | ||
expect(execStub.exec.firstCall.args[1]).to.contain('C:/tmp/cache/sqlncli.msi'); | ||
}); | ||
it('installs from web (x32)', async () => { | ||
Object.defineProperty(process, 'arch', { | ||
value: 'x32', | ||
}); | ||
tcStub.cacheFile.resolves('C:/tmp/cache/'); | ||
await installNativeClient(11); | ||
expect(utilsStub.downloadTool).to.have.been.calledOnceWith('https://download.microsoft.com/download/B/E/D/BED73AAC-3C8A-43F5-AF4F-EB4FEA6C8F3A/ENU/x86/sqlncli.msi'); | ||
expect(tcStub.cacheFile).to.have.callCount(1); | ||
expect(execStub.exec).to.have.been.calledOnceWith('msiexec', match.array, { | ||
windowsVerbatimArguments: true, | ||
}); | ||
expect; | ||
expect(execStub.exec.firstCall.args[1]).to.contain('C:/tmp/cache/sqlncli.msi'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters