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 #6

Open
wants to merge 5 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
99 changes: 90 additions & 9 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ describe('installer tests', () => {
const inputQuality = '' as QualityOptions;
const errorMessage = 'fictitious error message!';

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: 1,
Expand All @@ -51,7 +55,7 @@ describe('installer tests', () => {
});

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);
await expect(dotnetInstaller.installDotnet()).rejects.toThrow(
Expand All @@ -63,6 +67,11 @@ describe('installer tests', () => {
const inputVersion = '3.1.100';
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,
Expand All @@ -73,7 +82,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);
const installedVersion = await dotnetInstaller.installDotnet();
Expand All @@ -86,6 +95,10 @@ describe('installer tests', () => {
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,
Expand All @@ -96,7 +109,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand All @@ -119,10 +132,57 @@ 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;
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: 0,
Expand All @@ -133,7 +193,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand All @@ -149,6 +209,10 @@ describe('installer tests', () => {
const inputQuality = 'ga' as QualityOptions;
const stdout = `Fictitious dotnet version 3.1.100 is installed`;

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: 0,
Expand All @@ -159,7 +223,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand All @@ -173,6 +237,10 @@ describe('installer tests', () => {
each(['6', '6.0', '6.0.x', '6.0.*', '6.0.X']).test(
`should supply 'quality' argument to the installation script if quality input is set and version (%s) is not in A.B.C syntax`,
async inputVersion => {
const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

const inputQuality = 'ga' as QualityOptions;
const exitCode = 0;
const stdout = `Fictitious dotnet version 6.0.0 is installed`;
Expand All @@ -186,7 +254,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand Down Expand Up @@ -216,6 +284,11 @@ describe('installer tests', () => {
const inputQuality = '' as QualityOptions;
const exitCode = 0;
const stdout = `Fictitious dotnet version 6.0.0 is installed`;

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: exitCode,
Expand All @@ -226,7 +299,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand Down Expand Up @@ -257,6 +330,10 @@ describe('installer tests', () => {
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,
Expand All @@ -267,7 +344,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
inputQuality
);

Expand Down Expand Up @@ -295,6 +372,10 @@ describe('installer tests', () => {
const inputQuality = '' as QualityOptions;
const stdout = `Fictitious dotnet version 6.0.0 is installed`;

const resolvedVersion = await new installer.DotnetVersionResolver(
inputVersion
).createDotnetVersion();

getExecOutputSpy.mockImplementation(() => {
return Promise.resolve({
exitCode: 0,
Expand All @@ -305,7 +386,7 @@ describe('installer tests', () => {
maxSatisfyingSpy.mockImplementation(() => inputVersion);

const dotnetInstaller = new installer.DotnetCoreInstaller(
inputVersion,
resolvedVersion,
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