Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install runtime only #476

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 69 additions & 9 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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();
Expand All @@ -96,7 +100,9 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion(),
inputQuality
);

Expand All @@ -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;
Expand All @@ -133,7 +181,9 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion(),
inputQuality
);

Expand All @@ -159,7 +209,9 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion(),
inputQuality
);

Expand All @@ -186,7 +238,9 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion(),
inputQuality
);

Expand Down Expand Up @@ -226,7 +280,9 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion(),
inputQuality
);

Expand Down Expand Up @@ -267,7 +323,9 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion(),
inputQuality
);

Expand Down Expand Up @@ -305,7 +363,9 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion(),
inputQuality
);

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading
Loading