Merge ead76a044c
into 2216f56ae1
This commit is contained in:
commit
3dfa873938
|
@ -51,7 +51,9 @@ describe('installer tests', () => {
|
|||
});
|
||||
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
inputVersion,
|
||||
await new installer.DotnetVersionResolver(
|
||||
inputVersion
|
||||
).createDotnetVersion(),
|
||||
inputQuality
|
||||
);
|
||||
await expect(dotnetInstaller.installDotnet()).rejects.toThrow(
|
||||
|
@ -73,7 +75,9 @@ describe('installer tests', () => {
|
|||
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
inputVersion,
|
||||
await new installer.DotnetVersionResolver(
|
||||
inputVersion
|
||||
).createDotnetVersion(),
|
||||
inputQuality
|
||||
);
|
||||
const installedVersion = await dotnetInstaller.installDotnet();
|
||||
|
@ -96,7 +100,9 @@ describe('installer tests', () => {
|
|||
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
inputVersion,
|
||||
await new installer.DotnetVersionResolver(
|
||||
inputVersion
|
||||
).createDotnetVersion(),
|
||||
inputQuality
|
||||
);
|
||||
|
||||
|
@ -119,6 +125,48 @@ describe('installer tests', () => {
|
|||
expect(scriptArguments).toContain(expectedArgument);
|
||||
});
|
||||
|
||||
it(`should supply 'runtime' argument to the installation script if runtimeOnly parameter is true`, async () => {
|
||||
const inputVersion = '6.0.300';
|
||||
const inputQuality = '' as QualityOptions;
|
||||
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;
|
||||
|
||||
const resolvedVersion = await new installer.DotnetVersionResolver(
|
||||
inputVersion
|
||||
).createDotnetVersion();
|
||||
|
||||
getExecOutputSpy.mockImplementation(() => {
|
||||
return Promise.resolve({
|
||||
exitCode: 0,
|
||||
stdout: `${stdout}`,
|
||||
stderr: ''
|
||||
});
|
||||
});
|
||||
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
resolvedVersion,
|
||||
inputQuality,
|
||||
true
|
||||
);
|
||||
|
||||
await dotnetInstaller.installDotnet();
|
||||
|
||||
/**
|
||||
* First time script would be called to
|
||||
* install runtime of the latest version in order
|
||||
* to provide latest CLI, here we are checking only the
|
||||
* second one that installs actual requested runtime
|
||||
*/
|
||||
const callIndex = 1;
|
||||
|
||||
const scriptArguments = (
|
||||
getExecOutputSpy.mock.calls[callIndex][1] as string[]
|
||||
).join(' ');
|
||||
const expectedArgument = IS_WINDOWS ? `-Runtime` : `--runtime`;
|
||||
|
||||
expect(scriptArguments).toContain(expectedArgument);
|
||||
});
|
||||
|
||||
it(`should warn if the 'quality' input is set and the supplied version is in A.B.C syntax`, async () => {
|
||||
const inputVersion = '6.0.300';
|
||||
const inputQuality = 'ga' as QualityOptions;
|
||||
|
@ -133,7 +181,9 @@ describe('installer tests', () => {
|
|||
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
inputVersion,
|
||||
await new installer.DotnetVersionResolver(
|
||||
inputVersion
|
||||
).createDotnetVersion(),
|
||||
inputQuality
|
||||
);
|
||||
|
||||
|
@ -159,7 +209,9 @@ describe('installer tests', () => {
|
|||
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
inputVersion,
|
||||
await new installer.DotnetVersionResolver(
|
||||
inputVersion
|
||||
).createDotnetVersion(),
|
||||
inputQuality
|
||||
);
|
||||
|
||||
|
@ -186,7 +238,9 @@ describe('installer tests', () => {
|
|||
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
inputVersion,
|
||||
await new installer.DotnetVersionResolver(
|
||||
inputVersion
|
||||
).createDotnetVersion(),
|
||||
inputQuality
|
||||
);
|
||||
|
||||
|
@ -226,7 +280,9 @@ describe('installer tests', () => {
|
|||
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
inputVersion,
|
||||
await new installer.DotnetVersionResolver(
|
||||
inputVersion
|
||||
).createDotnetVersion(),
|
||||
inputQuality
|
||||
);
|
||||
|
||||
|
@ -267,7 +323,9 @@ describe('installer tests', () => {
|
|||
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
inputVersion,
|
||||
await new installer.DotnetVersionResolver(
|
||||
inputVersion
|
||||
).createDotnetVersion(),
|
||||
inputQuality
|
||||
);
|
||||
|
||||
|
@ -305,7 +363,9 @@ describe('installer tests', () => {
|
|||
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||
|
||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||
inputVersion,
|
||||
await new installer.DotnetVersionResolver(
|
||||
inputVersion
|
||||
).createDotnetVersion(),
|
||||
inputQuality
|
||||
);
|
||||
|
||||
|
|
|
@ -9,6 +9,10 @@ inputs:
|
|||
description: 'Optional SDK version(s) to use. If not provided, will install global.json version when available. Examples: 2.2.104, 3.1, 3.1.x, 3.x, 6.0.2xx'
|
||||
dotnet-quality:
|
||||
description: 'Optional quality of the build. The possible values are: daily, signed, validated, preview, ga.'
|
||||
runtime-only:
|
||||
description: 'Optional input to install only the runtime, not the SDK.'
|
||||
required: false
|
||||
default: false
|
||||
global-json-file:
|
||||
description: 'Optional global.json location, if your global.json isn''t located in the root of the repo.'
|
||||
source-url:
|
||||
|
|
|
@ -73035,14 +73035,13 @@ DotnetInstallDir.dirPath = process.env['DOTNET_INSTALL_DIR']
|
|||
? DotnetInstallDir.convertInstallPathToAbsolute(process.env['DOTNET_INSTALL_DIR'])
|
||||
: DotnetInstallDir.default[utils_1.PLATFORM];
|
||||
class DotnetCoreInstaller {
|
||||
constructor(version, quality) {
|
||||
this.version = version;
|
||||
constructor(dotnetVersion, quality, runtimeOnly = false) {
|
||||
this.dotnetVersion = dotnetVersion;
|
||||
this.quality = quality;
|
||||
this.runtimeOnly = runtimeOnly;
|
||||
}
|
||||
installDotnet() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const versionResolver = new DotnetVersionResolver(this.version);
|
||||
const dotnetVersion = yield versionResolver.createDotnetVersion();
|
||||
/**
|
||||
* Install dotnet runitme first in order to get
|
||||
* the latest stable version of dotnet CLI
|
||||
|
@ -73066,12 +73065,15 @@ class DotnetCoreInstaller {
|
|||
* Install dotnet over the latest version of
|
||||
* dotnet CLI
|
||||
*/
|
||||
const dotnetInstallOutput = yield new DotnetInstallScript()
|
||||
const dotnetInstallScript = new DotnetInstallScript()
|
||||
// Don't overwrite CLI because it should be already installed
|
||||
.useArguments(utils_1.IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files')
|
||||
// Use version provided by user
|
||||
.useVersion(dotnetVersion, this.quality)
|
||||
.execute();
|
||||
.useVersion(this.dotnetVersion, this.quality);
|
||||
if (this.runtimeOnly) {
|
||||
dotnetInstallScript.useArguments(utils_1.IS_WINDOWS ? '-Runtime' : '--runtime', 'dotnet');
|
||||
}
|
||||
const dotnetInstallOutput = yield dotnetInstallScript.execute();
|
||||
if (dotnetInstallOutput.exitCode) {
|
||||
throw new Error(`Failed to install dotnet, exit code: ${dotnetInstallOutput.exitCode}. ${dotnetInstallOutput.stderr}`);
|
||||
}
|
||||
|
@ -73194,9 +73196,11 @@ function run() {
|
|||
throw new Error(`Value '${quality}' is not supported for the 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`);
|
||||
}
|
||||
let dotnetInstaller;
|
||||
let dotnetVersionResolver;
|
||||
const uniqueVersions = new Set(versions);
|
||||
for (const version of uniqueVersions) {
|
||||
dotnetInstaller = new installer_1.DotnetCoreInstaller(version, quality);
|
||||
dotnetVersionResolver = new installer_1.DotnetVersionResolver(version);
|
||||
dotnetInstaller = new installer_1.DotnetCoreInstaller(yield dotnetVersionResolver.createDotnetVersion(), quality, core.getBooleanInput('runtime-only'));
|
||||
const installedVersion = yield dotnetInstaller.installDotnet();
|
||||
installedDotnetVersions.push(installedVersion);
|
||||
}
|
||||
|
|
|
@ -253,12 +253,13 @@ export class DotnetCoreInstaller {
|
|||
DotnetInstallDir.setEnvironmentVariable();
|
||||
}
|
||||
|
||||
constructor(private version: string, private quality: QualityOptions) {}
|
||||
constructor(
|
||||
private readonly dotnetVersion: DotnetVersion,
|
||||
private readonly quality: QualityOptions,
|
||||
private readonly runtimeOnly = false
|
||||
) {}
|
||||
|
||||
public async installDotnet(): Promise<string | null> {
|
||||
const versionResolver = new DotnetVersionResolver(this.version);
|
||||
const dotnetVersion = await versionResolver.createDotnetVersion();
|
||||
|
||||
/**
|
||||
* Install dotnet runitme first in order to get
|
||||
* the latest stable version of dotnet CLI
|
||||
|
@ -288,14 +289,22 @@ export class DotnetCoreInstaller {
|
|||
* Install dotnet over the latest version of
|
||||
* dotnet CLI
|
||||
*/
|
||||
const dotnetInstallOutput = await new DotnetInstallScript()
|
||||
const dotnetInstallScript = new DotnetInstallScript()
|
||||
// Don't overwrite CLI because it should be already installed
|
||||
.useArguments(
|
||||
IS_WINDOWS ? '-SkipNonVersionedFiles' : '--skip-non-versioned-files'
|
||||
)
|
||||
// Use version provided by user
|
||||
.useVersion(dotnetVersion, this.quality)
|
||||
.execute();
|
||||
.useVersion(this.dotnetVersion, this.quality);
|
||||
|
||||
if (this.runtimeOnly) {
|
||||
dotnetInstallScript.useArguments(
|
||||
IS_WINDOWS ? '-Runtime' : '--runtime',
|
||||
'dotnet'
|
||||
);
|
||||
}
|
||||
|
||||
const dotnetInstallOutput = await dotnetInstallScript.execute();
|
||||
|
||||
if (dotnetInstallOutput.exitCode) {
|
||||
throw new Error(
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
import * as core from '@actions/core';
|
||||
import {DotnetCoreInstaller, DotnetInstallDir} from './installer';
|
||||
import {
|
||||
DotnetCoreInstaller,
|
||||
DotnetInstallDir,
|
||||
DotnetVersionResolver
|
||||
} from './installer';
|
||||
import * as fs from 'fs';
|
||||
import path from 'path';
|
||||
import semver from 'semver';
|
||||
|
@ -67,9 +71,16 @@ export async function run() {
|
|||
}
|
||||
|
||||
let dotnetInstaller: DotnetCoreInstaller;
|
||||
let dotnetVersionResolver: DotnetVersionResolver;
|
||||
|
||||
const uniqueVersions = new Set<string>(versions);
|
||||
for (const version of uniqueVersions) {
|
||||
dotnetInstaller = new DotnetCoreInstaller(version, quality);
|
||||
dotnetVersionResolver = new DotnetVersionResolver(version);
|
||||
dotnetInstaller = new DotnetCoreInstaller(
|
||||
await dotnetVersionResolver.createDotnetVersion(),
|
||||
quality,
|
||||
core.getBooleanInput('runtime-only')
|
||||
);
|
||||
const installedVersion = await dotnetInstaller.installDotnet();
|
||||
installedDotnetVersions.push(installedVersion);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue