Merge pull request #1 from IvanZosimov/nuget-cache/update-unit-tests
Nuget cache/update unit tests
This commit is contained in:
commit
499093f364
|
@ -24,7 +24,7 @@ jobs:
|
||||||
- name: Clear toolcache
|
- name: Clear toolcache
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
- name: Setup dotnet 2.2.402 and 3.1.404
|
- name: Setup dotnet 2.2.402, 3.1.404 and 3.0.x
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
dotnet-version: |
|
dotnet-version: |
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`authutil tests Existing config not in repo root, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
exports[`authutil tests existing config not in repo root, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
||||||
"<?xml version=\\"1.0\\"?>
|
"<?xml version=\\"1.0\\"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<config>
|
<config>
|
||||||
|
@ -15,7 +15,7 @@ exports[`authutil tests Existing config not in repo root, sets up a partial NuGe
|
||||||
</configuration>"
|
</configuration>"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`authutil tests Existing config w/ Azure Artifacts source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
exports[`authutil tests existing config w/ Azure Artifacts source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
||||||
"<?xml version=\\"1.0\\"?>
|
"<?xml version=\\"1.0\\"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<config>
|
<config>
|
||||||
|
@ -30,7 +30,7 @@ exports[`authutil tests Existing config w/ Azure Artifacts source and NuGet.org,
|
||||||
</configuration>"
|
</configuration>"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`authutil tests Existing config w/ GPR source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
exports[`authutil tests existing config w/ GPR source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
||||||
"<?xml version=\\"1.0\\"?>
|
"<?xml version=\\"1.0\\"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<config>
|
<config>
|
||||||
|
@ -45,7 +45,7 @@ exports[`authutil tests Existing config w/ GPR source and NuGet.org, sets up a p
|
||||||
</configuration>"
|
</configuration>"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`authutil tests Existing config w/ no GPR sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = `
|
exports[`authutil tests existing config w/ no GPR sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = `
|
||||||
"<?xml version=\\"1.0\\"?>
|
"<?xml version=\\"1.0\\"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<config>
|
<config>
|
||||||
|
@ -63,7 +63,7 @@ exports[`authutil tests Existing config w/ no GPR sources, sets up a full NuGet.
|
||||||
</configuration>"
|
</configuration>"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`authutil tests Existing config w/ no sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = `
|
exports[`authutil tests existing config w/ no sources, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = `
|
||||||
"<?xml version=\\"1.0\\"?>
|
"<?xml version=\\"1.0\\"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<config>
|
<config>
|
||||||
|
@ -81,7 +81,7 @@ exports[`authutil tests Existing config w/ no sources, sets up a full NuGet.conf
|
||||||
</configuration>"
|
</configuration>"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`authutil tests Existing config w/ only Azure Artifacts source, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
exports[`authutil tests existing config w/ only Azure Artifacts source, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
||||||
"<?xml version=\\"1.0\\"?>
|
"<?xml version=\\"1.0\\"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<config>
|
<config>
|
||||||
|
@ -96,7 +96,7 @@ exports[`authutil tests Existing config w/ only Azure Artifacts source, sets up
|
||||||
</configuration>"
|
</configuration>"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`authutil tests Existing config w/ only GPR source, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
exports[`authutil tests existing config w/ only GPR source, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
||||||
"<?xml version=\\"1.0\\"?>
|
"<?xml version=\\"1.0\\"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<config>
|
<config>
|
||||||
|
@ -111,7 +111,7 @@ exports[`authutil tests Existing config w/ only GPR source, sets up a partial Nu
|
||||||
</configuration>"
|
</configuration>"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`authutil tests Existing config w/ two GPR sources, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
exports[`authutil tests existing config w/ two GPR sources, sets up a partial NuGet.config user/PAT for GPR 1`] = `
|
||||||
"<?xml version=\\"1.0\\"?>
|
"<?xml version=\\"1.0\\"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<config>
|
<config>
|
||||||
|
@ -130,7 +130,7 @@ exports[`authutil tests Existing config w/ two GPR sources, sets up a partial Nu
|
||||||
</configuration>"
|
</configuration>"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`authutil tests No existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR 1`] = `
|
exports[`authutil tests no existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR 1`] = `
|
||||||
"<?xml version=\\"1.0\\"?>
|
"<?xml version=\\"1.0\\"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<config>
|
<config>
|
||||||
|
@ -148,7 +148,7 @@ exports[`authutil tests No existing config, sets up a full NuGet.config with URL
|
||||||
</configuration>"
|
</configuration>"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`authutil tests No existing config, sets up a full NuGet.config with URL and token for other source 1`] = `
|
exports[`authutil tests no existing config, sets up a full NuGet.config with URL and token for other source 1`] = `
|
||||||
"<?xml version=\\"1.0\\"?>
|
"<?xml version=\\"1.0\\"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<config>
|
<config>
|
||||||
|
@ -166,7 +166,7 @@ exports[`authutil tests No existing config, sets up a full NuGet.config with URL
|
||||||
</configuration>"
|
</configuration>"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`authutil tests No existing config, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = `
|
exports[`authutil tests no existing config, sets up a full NuGet.config with URL and user/PAT for GPR 1`] = `
|
||||||
"<?xml version=\\"1.0\\"?>
|
"<?xml version=\\"1.0\\"?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<config>
|
<config>
|
||||||
|
|
|
@ -91,9 +91,9 @@ describe('authutil tests', () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = '';
|
process.env['NUGET_AUTH_TOKEN'] = '';
|
||||||
});
|
});
|
||||||
|
|
||||||
it('No existing config, sets up a full NuGet.config with URL and user/PAT for GPR', async () => {
|
it('no existing config, sets up a full NuGet.config with URL and user/PAT for GPR', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://nuget.pkg.github.com/OwnerName/index.json',
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -104,10 +104,10 @@ describe('authutil tests', () => {
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('No existing config, auth token environment variable not provided, throws', async () => {
|
it('no existing config, auth token environment variable not provided, throws', async () => {
|
||||||
let thrown = false;
|
let thrown = false;
|
||||||
try {
|
try {
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://nuget.pkg.github.com/OwnerName/index.json',
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -118,10 +118,10 @@ describe('authutil tests', () => {
|
||||||
expect(thrown).toBe(true);
|
expect(thrown).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('No existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR', async () => {
|
it('no existing config, sets up a full NuGet.config with URL and other owner/PAT for GPR', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
process.env['INPUT_OWNER'] = 'otherorg';
|
process.env['INPUT_OWNER'] = 'otherorg';
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://nuget.pkg.github.com/otherorg/index.json',
|
'https://nuget.pkg.github.com/otherorg/index.json',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -132,7 +132,7 @@ describe('authutil tests', () => {
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Existing config (invalid), tries to parse an invalid NuGet.config and throws', async () => {
|
it('existing config (invalid), tries to parse an invalid NuGet.config and throws', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
const inputNuGetConfigPath: string = path.join(
|
const inputNuGetConfigPath: string = path.join(
|
||||||
fakeSourcesDirForTesting,
|
fakeSourcesDirForTesting,
|
||||||
|
@ -141,7 +141,7 @@ describe('authutil tests', () => {
|
||||||
fs.writeFileSync(inputNuGetConfigPath, invalidNuGetConfig);
|
fs.writeFileSync(inputNuGetConfigPath, invalidNuGetConfig);
|
||||||
let thrown = false;
|
let thrown = false;
|
||||||
try {
|
try {
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://nuget.pkg.github.com/OwnerName/index.json',
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -152,14 +152,14 @@ describe('authutil tests', () => {
|
||||||
expect(thrown).toBe(true);
|
expect(thrown).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Existing config w/ no sources, sets up a full NuGet.config with URL and user/PAT for GPR', async () => {
|
it('existing config w/ no sources, sets up a full NuGet.config with URL and user/PAT for GPR', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
const inputNuGetConfigPath: string = path.join(
|
const inputNuGetConfigPath: string = path.join(
|
||||||
fakeSourcesDirForTesting,
|
fakeSourcesDirForTesting,
|
||||||
'nuget.config'
|
'nuget.config'
|
||||||
);
|
);
|
||||||
fs.writeFileSync(inputNuGetConfigPath, emptyNuGetConfig);
|
fs.writeFileSync(inputNuGetConfigPath, emptyNuGetConfig);
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://nuget.pkg.github.com/OwnerName/index.json',
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -170,14 +170,14 @@ describe('authutil tests', () => {
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Existing config w/ no GPR sources, sets up a full NuGet.config with URL and user/PAT for GPR', async () => {
|
it('existing config w/ no GPR sources, sets up a full NuGet.config with URL and user/PAT for GPR', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
const inputNuGetConfigPath: string = path.join(
|
const inputNuGetConfigPath: string = path.join(
|
||||||
fakeSourcesDirForTesting,
|
fakeSourcesDirForTesting,
|
||||||
'nuget.config'
|
'nuget.config'
|
||||||
);
|
);
|
||||||
fs.writeFileSync(inputNuGetConfigPath, nugetorgNuGetConfig);
|
fs.writeFileSync(inputNuGetConfigPath, nugetorgNuGetConfig);
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://nuget.pkg.github.com/OwnerName/index.json',
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -188,14 +188,14 @@ describe('authutil tests', () => {
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Existing config w/ only GPR source, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
it('existing config w/ only GPR source, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
const inputNuGetConfigPath: string = path.join(
|
const inputNuGetConfigPath: string = path.join(
|
||||||
fakeSourcesDirForTesting,
|
fakeSourcesDirForTesting,
|
||||||
'nuget.config'
|
'nuget.config'
|
||||||
);
|
);
|
||||||
fs.writeFileSync(inputNuGetConfigPath, gprNuGetConfig);
|
fs.writeFileSync(inputNuGetConfigPath, gprNuGetConfig);
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://nuget.pkg.github.com/OwnerName/index.json',
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -206,14 +206,14 @@ describe('authutil tests', () => {
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Existing config w/ GPR source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
it('existing config w/ GPR source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
const inputNuGetConfigPath: string = path.join(
|
const inputNuGetConfigPath: string = path.join(
|
||||||
fakeSourcesDirForTesting,
|
fakeSourcesDirForTesting,
|
||||||
'nuget.config'
|
'nuget.config'
|
||||||
);
|
);
|
||||||
fs.writeFileSync(inputNuGetConfigPath, gprnugetorgNuGetConfig);
|
fs.writeFileSync(inputNuGetConfigPath, gprnugetorgNuGetConfig);
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://nuget.pkg.github.com/OwnerName/index.json',
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -224,14 +224,14 @@ describe('authutil tests', () => {
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Existing config w/ two GPR sources, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
it('existing config w/ two GPR sources, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
const inputNuGetConfigPath: string = path.join(
|
const inputNuGetConfigPath: string = path.join(
|
||||||
fakeSourcesDirForTesting,
|
fakeSourcesDirForTesting,
|
||||||
'nuget.config'
|
'nuget.config'
|
||||||
);
|
);
|
||||||
fs.writeFileSync(inputNuGetConfigPath, twogprNuGetConfig);
|
fs.writeFileSync(inputNuGetConfigPath, twogprNuGetConfig);
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://nuget.pkg.github.com',
|
'https://nuget.pkg.github.com',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -242,7 +242,7 @@ describe('authutil tests', () => {
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Existing config w/ spaces in key, throws for now', async () => {
|
it('existing config w/ spaces in key, throws for now', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
const inputNuGetConfigPath: string = path.join(
|
const inputNuGetConfigPath: string = path.join(
|
||||||
fakeSourcesDirForTesting,
|
fakeSourcesDirForTesting,
|
||||||
|
@ -251,7 +251,7 @@ describe('authutil tests', () => {
|
||||||
fs.writeFileSync(inputNuGetConfigPath, spaceNuGetConfig);
|
fs.writeFileSync(inputNuGetConfigPath, spaceNuGetConfig);
|
||||||
let thrown = false;
|
let thrown = false;
|
||||||
try {
|
try {
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://nuget.pkg.github.com/OwnerName/index.json',
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -262,7 +262,7 @@ describe('authutil tests', () => {
|
||||||
expect(thrown).toBe(true);
|
expect(thrown).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Existing config not in repo root, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
it('existing config not in repo root, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
const inputNuGetConfigDirectory: string = path.join(
|
const inputNuGetConfigDirectory: string = path.join(
|
||||||
fakeSourcesDirForTesting,
|
fakeSourcesDirForTesting,
|
||||||
|
@ -274,7 +274,7 @@ describe('authutil tests', () => {
|
||||||
);
|
);
|
||||||
fs.mkdirSync(inputNuGetConfigDirectory, {recursive: true});
|
fs.mkdirSync(inputNuGetConfigDirectory, {recursive: true});
|
||||||
fs.writeFileSync(inputNuGetConfigPath, gprNuGetConfig);
|
fs.writeFileSync(inputNuGetConfigPath, gprNuGetConfig);
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://nuget.pkg.github.com/OwnerName/index.json',
|
'https://nuget.pkg.github.com/OwnerName/index.json',
|
||||||
'subfolder/nuget.config',
|
'subfolder/nuget.config',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -285,14 +285,14 @@ describe('authutil tests', () => {
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Existing config w/ only Azure Artifacts source, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
it('existing config w/ only Azure Artifacts source, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
const inputNuGetConfigPath: string = path.join(
|
const inputNuGetConfigPath: string = path.join(
|
||||||
fakeSourcesDirForTesting,
|
fakeSourcesDirForTesting,
|
||||||
'nuget.config'
|
'nuget.config'
|
||||||
);
|
);
|
||||||
fs.writeFileSync(inputNuGetConfigPath, azureartifactsNuGetConfig);
|
fs.writeFileSync(inputNuGetConfigPath, azureartifactsNuGetConfig);
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json',
|
'https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -303,14 +303,14 @@ describe('authutil tests', () => {
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Existing config w/ Azure Artifacts source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
it('existing config w/ Azure Artifacts source and NuGet.org, sets up a partial NuGet.config user/PAT for GPR', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
const inputNuGetConfigPath: string = path.join(
|
const inputNuGetConfigPath: string = path.join(
|
||||||
fakeSourcesDirForTesting,
|
fakeSourcesDirForTesting,
|
||||||
'nuget.config'
|
'nuget.config'
|
||||||
);
|
);
|
||||||
fs.writeFileSync(inputNuGetConfigPath, azureartifactsnugetorgNuGetConfig);
|
fs.writeFileSync(inputNuGetConfigPath, azureartifactsnugetorgNuGetConfig);
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json',
|
'https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
@ -321,9 +321,9 @@ describe('authutil tests', () => {
|
||||||
).toMatchSnapshot();
|
).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('No existing config, sets up a full NuGet.config with URL and token for other source', async () => {
|
it('no existing config, sets up a full NuGet.config with URL and token for other source', async () => {
|
||||||
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
process.env['NUGET_AUTH_TOKEN'] = 'TEST_FAKE_AUTH_TOKEN';
|
||||||
await auth.configAuthentication(
|
auth.configAuthentication(
|
||||||
'https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json',
|
'https://pkgs.dev.azure.com/amullans/_packaging/GitHubBuilds/nuget/v3/index.json',
|
||||||
'',
|
'',
|
||||||
fakeSourcesDirForTesting
|
fakeSourcesDirForTesting
|
||||||
|
|
|
@ -1,21 +1,45 @@
|
||||||
import cscFile from '../.github/csc.json';
|
import cscFile from '../.github/csc.json';
|
||||||
describe('csc tests', () => {
|
describe('csc tests', () => {
|
||||||
it('Valid regular expression', async () => {
|
test('regular expression in csc.json is valid', async () => {
|
||||||
const regex = cscFile['problemMatcher'][0]['pattern'][0]['regexp'];
|
const regexPattern = cscFile['problemMatcher'][0]['pattern'][0]['regexp'];
|
||||||
|
const regexResultsMap = cscFile['problemMatcher'][0]['pattern'][0];
|
||||||
|
|
||||||
console.log(regex);
|
const regex = new RegExp(regexPattern);
|
||||||
const re = new RegExp(regex);
|
|
||||||
|
|
||||||
// Ideally we would verify that this
|
|
||||||
const stringsToMatch = [
|
const stringsToMatch = [
|
||||||
'Program.cs(10,79): error CS1002: ; expected [/Users/zacharyeisinger/Documents/repo/setup-dotnet/__tests__/sample-broken-csproj/sample.csproj]',
|
'Program.cs(10,79): error CS1002: ; expected [/Users/zacharyeisinger/Documents/repo/setup-dotnet/__tests__/sample-broken-csproj/sample.csproj]',
|
||||||
"S:\\Msbuild\\src\\Build\\Evaluation\\ExpressionShredder.cs(33,7): error CS1003: Syntax error, ',' expected [S:\\msbuild\\src\\Build\\Microsoft.Build.csproj > Properties:prop]"
|
"S:\\Msbuild\\src\\Build\\Evaluation\\ExpressionShredder.cs(33,7): error CS1003: Syntax error, ',' expected [S:\\msbuild\\src\\Build\\Microsoft.Build.csproj > Properties:prop]"
|
||||||
];
|
];
|
||||||
|
// Expected results are calculated according to the csc matcher located in csc.json file
|
||||||
|
const expectedResults = [
|
||||||
|
{
|
||||||
|
file: 'Program.cs',
|
||||||
|
line: '10',
|
||||||
|
severity: 'error',
|
||||||
|
code: 'CS1002',
|
||||||
|
message: '; expected',
|
||||||
|
fromPath:
|
||||||
|
'/Users/zacharyeisinger/Documents/repo/setup-dotnet/__tests__/sample-broken-csproj/sample.csproj'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: 'S:\\Msbuild\\src\\Build\\Evaluation\\ExpressionShredder.cs',
|
||||||
|
line: '33',
|
||||||
|
severity: 'error',
|
||||||
|
code: 'CS1003',
|
||||||
|
message: "Syntax error, ',' expected",
|
||||||
|
fromPath:
|
||||||
|
'S:\\msbuild\\src\\Build\\Microsoft.Build.csproj > Properties:prop'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
stringsToMatch.forEach(string => {
|
stringsToMatch.map((string, index) => {
|
||||||
const matchStr = string.match(re);
|
const matchedResultsArray = string.match(regex);
|
||||||
console.log(matchStr);
|
for (const propName in expectedResults[index]) {
|
||||||
expect(matchStr).toEqual(expect.anything());
|
const propertyIndex = regexResultsMap[propName];
|
||||||
|
const expectedPropValue = expectedResults[index][propName];
|
||||||
|
const matchedPropValue = matchedResultsArray![propertyIndex];
|
||||||
|
expect(matchedPropValue).toEqual(expectedPropValue);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}, 10000);
|
}, 10000);
|
||||||
});
|
});
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
|
import * as hc from '@actions/http-client';
|
||||||
|
|
||||||
|
describe('Dotnet installation scripts tests', () => {
|
||||||
|
it('Uses an up to date bash download script', async () => {
|
||||||
|
const httpCallbackClient = new hc.HttpClient('setup-dotnet-test', [], {
|
||||||
|
allowRetries: true,
|
||||||
|
maxRetries: 3
|
||||||
|
});
|
||||||
|
const response: hc.HttpClientResponse = await httpCallbackClient.get(
|
||||||
|
'https://dot.net/v1/dotnet-install.sh'
|
||||||
|
);
|
||||||
|
expect(response.message.statusCode).toBe(200);
|
||||||
|
const upToDateContents: string = await response.readBody();
|
||||||
|
const currentContents: string = fs
|
||||||
|
.readFileSync(
|
||||||
|
path.join(__dirname, '..', 'externals', 'install-dotnet.sh')
|
||||||
|
)
|
||||||
|
.toString();
|
||||||
|
expect(normalizeFileContents(currentContents)).toBe(
|
||||||
|
normalizeFileContents(upToDateContents)
|
||||||
|
);
|
||||||
|
}, 30000);
|
||||||
|
|
||||||
|
it('Uses an up to date powershell download script', async () => {
|
||||||
|
const httpCallbackClient = new hc.HttpClient('setup-dotnet-test', [], {
|
||||||
|
allowRetries: true,
|
||||||
|
maxRetries: 3
|
||||||
|
});
|
||||||
|
const response: hc.HttpClientResponse = await httpCallbackClient.get(
|
||||||
|
'https://dot.net/v1/dotnet-install.ps1'
|
||||||
|
);
|
||||||
|
expect(response.message.statusCode).toBe(200);
|
||||||
|
const upToDateContents: string = await response.readBody();
|
||||||
|
const currentContents: string = fs
|
||||||
|
.readFileSync(
|
||||||
|
path.join(__dirname, '..', 'externals', 'install-dotnet.ps1')
|
||||||
|
)
|
||||||
|
.toString();
|
||||||
|
expect(normalizeFileContents(currentContents)).toBe(
|
||||||
|
normalizeFileContents(upToDateContents)
|
||||||
|
);
|
||||||
|
}, 30000);
|
||||||
|
});
|
||||||
|
|
||||||
|
function normalizeFileContents(contents: string): string {
|
||||||
|
return contents
|
||||||
|
.trim()
|
||||||
|
.replace(new RegExp('\r\n', 'g'), '\n')
|
||||||
|
.replace(new RegExp('\r', 'g'), '\n');
|
||||||
|
}
|
|
@ -1,298 +1,413 @@
|
||||||
import * as io from '@actions/io';
|
|
||||||
import * as os from 'os';
|
|
||||||
import fs from 'fs';
|
|
||||||
import path from 'path';
|
|
||||||
import each from 'jest-each';
|
import each from 'jest-each';
|
||||||
import * as hc from '@actions/http-client';
|
import semver from 'semver';
|
||||||
|
import fs from 'fs';
|
||||||
|
import fspromises from 'fs/promises';
|
||||||
|
import * as exec from '@actions/exec';
|
||||||
|
import * as core from '@actions/core';
|
||||||
|
import * as io from '@actions/io';
|
||||||
import * as installer from '../src/installer';
|
import * as installer from '../src/installer';
|
||||||
import {QualityOptions} from '../src/setup-dotnet';
|
|
||||||
|
|
||||||
import {IS_WINDOWS} from '../src/utils';
|
import {IS_WINDOWS} from '../src/utils';
|
||||||
import {IS_LINUX} from '../src/utils';
|
import {QualityOptions} from '../src/setup-dotnet';
|
||||||
|
|
||||||
let toolDir: string;
|
describe('installer tests', () => {
|
||||||
|
const env = process.env;
|
||||||
|
|
||||||
if (IS_WINDOWS) {
|
beforeEach(() => {
|
||||||
toolDir = path.join(process.env['PROGRAMFILES'] + '', 'dotnet');
|
jest.resetModules();
|
||||||
} else if (IS_LINUX) {
|
process.env = {...env};
|
||||||
toolDir = '/usr/share/dotnet';
|
});
|
||||||
} else {
|
|
||||||
toolDir = path.join(process.env['HOME'] + '', '.dotnet');
|
|
||||||
}
|
|
||||||
const tempDir = path.join(__dirname, 'runner', 'temp');
|
|
||||||
|
|
||||||
process.env['RUNNER_TOOL_CACHE'] = toolDir;
|
describe('DotnetCoreInstaller tests', () => {
|
||||||
process.env['RUNNER_TEMP'] = tempDir;
|
const getExecOutputSpy = jest.spyOn(exec, 'getExecOutput');
|
||||||
|
const warningSpy = jest.spyOn(core, 'warning');
|
||||||
|
const whichSpy = jest.spyOn(io, 'which');
|
||||||
|
const maxSatisfyingSpy = jest.spyOn(semver, 'maxSatisfying');
|
||||||
|
const chmodSyncSpy = jest.spyOn(fs, 'chmodSync');
|
||||||
|
const readdirSpy = jest.spyOn(fspromises, 'readdir');
|
||||||
|
|
||||||
describe('DotnetCoreInstaller tests', () => {
|
describe('installDotnet() tests', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(() => {
|
||||||
process.env.RUNNER_TOOL_CACHE = toolDir;
|
whichSpy.mockImplementation(() => Promise.resolve('PathToShell'));
|
||||||
process.env.DOTNET_INSTALL_DIR = toolDir;
|
chmodSyncSpy.mockImplementation(() => {});
|
||||||
process.env.RUNNER_TEMP = tempDir;
|
readdirSpy.mockImplementation(() => Promise.resolve([]));
|
||||||
process.env.DOTNET_ROOT = '';
|
});
|
||||||
try {
|
|
||||||
await io.rmRF(`${toolDir}/*`);
|
|
||||||
await io.rmRF(`${tempDir}/*`);
|
|
||||||
} catch (err) {
|
|
||||||
console.log(
|
|
||||||
`Failed to remove test directories, check the error message:${os.EOL}`,
|
|
||||||
err.message
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}, 30000);
|
|
||||||
|
|
||||||
afterEach(async () => {
|
afterAll(() => {
|
||||||
try {
|
jest.resetAllMocks();
|
||||||
await io.rmRF(`${toolDir}/*`);
|
});
|
||||||
await io.rmRF(`${tempDir}/*`);
|
|
||||||
} catch (err) {
|
|
||||||
console.log(
|
|
||||||
`Failed to remove test directories, check the error message:${os.EOL}`,
|
|
||||||
err.message
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}, 30000);
|
|
||||||
|
|
||||||
it('Aquires multiple versions of dotnet', async () => {
|
it('should throw the error in case of non-zero exit code of the installation script. The error message should contain logs.', async () => {
|
||||||
const versions = ['2.2.207', '3.1.120'];
|
const inputVersion = '3.1.100';
|
||||||
|
const inputQuality = '' as QualityOptions;
|
||||||
|
const errorMessage = 'fictitious error message!';
|
||||||
|
|
||||||
for (const version of versions) {
|
getExecOutputSpy.mockImplementation(() => {
|
||||||
await getDotnet(version);
|
return Promise.resolve({
|
||||||
}
|
exitCode: 1,
|
||||||
expect(fs.existsSync(path.join(toolDir, 'sdk', '2.2.207'))).toBe(true);
|
stdout: '',
|
||||||
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.120'))).toBe(true);
|
stderr: errorMessage
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
if (IS_WINDOWS) {
|
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
|
inputVersion,
|
||||||
} else {
|
inputQuality
|
||||||
expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
|
);
|
||||||
}
|
await expect(dotnetInstaller.installDotnet()).rejects.toThrow(
|
||||||
|
`Failed to install dotnet, exit code: 1. ${errorMessage}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
expect(process.env.DOTNET_ROOT).toBeDefined();
|
it('should return version of .NET SDK after installation complete', async () => {
|
||||||
expect(process.env.PATH).toBeDefined();
|
const inputVersion = '3.1.100';
|
||||||
expect(process.env.DOTNET_ROOT).toBe(toolDir);
|
const inputQuality = '' as QualityOptions;
|
||||||
expect(process.env.PATH?.startsWith(toolDir)).toBe(true);
|
getExecOutputSpy.mockImplementation(() => {
|
||||||
}, 600000);
|
return Promise.resolve({exitCode: 0, stdout: '', stderr: ''});
|
||||||
|
});
|
||||||
|
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||||
|
|
||||||
it('Acquires version of dotnet if no matching version is installed', async () => {
|
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
await getDotnet('3.1.201');
|
inputVersion,
|
||||||
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).toBe(true);
|
inputQuality
|
||||||
if (IS_WINDOWS) {
|
);
|
||||||
expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
|
const installedVersion = await dotnetInstaller.installDotnet();
|
||||||
} else {
|
|
||||||
expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(process.env.DOTNET_ROOT).toBeDefined();
|
expect(installedVersion).toBe(inputVersion);
|
||||||
expect(process.env.PATH).toBeDefined();
|
});
|
||||||
expect(process.env.DOTNET_ROOT).toBe(toolDir);
|
|
||||||
expect(process.env.PATH?.startsWith(toolDir)).toBe(true);
|
|
||||||
}, 600000); //This needs some time to download on "slower" internet connections
|
|
||||||
|
|
||||||
it('Acquires generic version of dotnet if no matching version is installed', async () => {
|
it(`should supply 'version' argument to the installation script if supplied version is in A.B.C syntax`, async () => {
|
||||||
await getDotnet('3.1');
|
const inputVersion = '6.0.300';
|
||||||
const directory = fs
|
const inputQuality = '' as QualityOptions;
|
||||||
.readdirSync(path.join(toolDir, 'sdk'))
|
|
||||||
.filter(fn => fn.startsWith('3.1.'));
|
|
||||||
expect(directory.length > 0).toBe(true);
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
|
|
||||||
} else {
|
|
||||||
expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
expect(process.env.DOTNET_ROOT).toBeDefined();
|
getExecOutputSpy.mockImplementation(() => {
|
||||||
expect(process.env.PATH).toBeDefined();
|
return Promise.resolve({exitCode: 0, stdout: '', stderr: ''});
|
||||||
expect(process.env.DOTNET_ROOT).toBe(toolDir);
|
});
|
||||||
expect(process.env.PATH?.startsWith(toolDir)).toBe(true);
|
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||||
}, 600000); //This needs some time to download on "slower" internet connections
|
|
||||||
|
|
||||||
it('Returns string with installed SDK version', async () => {
|
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
const version = '3.1.120';
|
inputVersion,
|
||||||
|
inputQuality
|
||||||
|
);
|
||||||
|
|
||||||
const installedVersion = await getDotnet(version);
|
await dotnetInstaller.installDotnet();
|
||||||
|
|
||||||
expect(installedVersion).toBe('3.1.120');
|
const scriptArguments = (
|
||||||
}, 600000);
|
getExecOutputSpy.mock.calls[0][1] as string[]
|
||||||
|
).join(' ');
|
||||||
|
const expectedArgument = IS_WINDOWS
|
||||||
|
? `-Version ${inputVersion}`
|
||||||
|
: `--version ${inputVersion}`;
|
||||||
|
|
||||||
it('Throws if no location contains correct dotnet version', async () => {
|
expect(scriptArguments).toContain(expectedArgument);
|
||||||
await expect(async () => {
|
});
|
||||||
await getDotnet('1000.0.0');
|
|
||||||
}).rejects.toThrow();
|
|
||||||
}, 30000);
|
|
||||||
|
|
||||||
it('Uses an up to date bash download script', async () => {
|
it(`should warn if the 'quality' input is set and the supplied version is in A.B.C syntax`, async () => {
|
||||||
const httpCallbackClient = new hc.HttpClient('setup-dotnet-test', [], {
|
const inputVersion = '6.0.300';
|
||||||
allowRetries: true,
|
const inputQuality = 'ga' as QualityOptions;
|
||||||
maxRetries: 3
|
|
||||||
});
|
|
||||||
const response: hc.HttpClientResponse = await httpCallbackClient.get(
|
|
||||||
'https://dot.net/v1/dotnet-install.sh'
|
|
||||||
);
|
|
||||||
expect(response.message.statusCode).toBe(200);
|
|
||||||
const upToDateContents: string = await response.readBody();
|
|
||||||
const currentContents: string = fs
|
|
||||||
.readFileSync(
|
|
||||||
path.join(__dirname, '..', 'externals', 'install-dotnet.sh')
|
|
||||||
)
|
|
||||||
.toString();
|
|
||||||
expect(normalizeFileContents(currentContents)).toBe(
|
|
||||||
normalizeFileContents(upToDateContents)
|
|
||||||
);
|
|
||||||
}, 30000);
|
|
||||||
|
|
||||||
it('Uses an up to date powershell download script', async () => {
|
getExecOutputSpy.mockImplementation(() => {
|
||||||
const httpCallbackClient = new hc.HttpClient('setup-dotnet-test', [], {
|
return Promise.resolve({exitCode: 0, stdout: '', stderr: ''});
|
||||||
allowRetries: true,
|
});
|
||||||
maxRetries: 3
|
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||||
});
|
|
||||||
const response: hc.HttpClientResponse = await httpCallbackClient.get(
|
|
||||||
'https://dot.net/v1/dotnet-install.ps1'
|
|
||||||
);
|
|
||||||
expect(response.message.statusCode).toBe(200);
|
|
||||||
const upToDateContents: string = await response.readBody();
|
|
||||||
const currentContents: string = fs
|
|
||||||
.readFileSync(
|
|
||||||
path.join(__dirname, '..', 'externals', 'install-dotnet.ps1')
|
|
||||||
)
|
|
||||||
.toString();
|
|
||||||
expect(normalizeFileContents(currentContents)).toBe(
|
|
||||||
normalizeFileContents(upToDateContents)
|
|
||||||
);
|
|
||||||
}, 30000);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('DotnetVersionResolver tests', () => {
|
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
each([
|
inputVersion,
|
||||||
'3.1',
|
inputQuality
|
||||||
'3.x',
|
);
|
||||||
'3.1.x',
|
|
||||||
'3.1.*',
|
|
||||||
'3.1.X',
|
|
||||||
'3.1.2',
|
|
||||||
'3.1.0-preview1'
|
|
||||||
]).test(
|
|
||||||
"if valid version: '%s' is supplied, it should return version object with some value",
|
|
||||||
async version => {
|
|
||||||
const dotnetVersionResolver = new installer.DotnetVersionResolver(
|
|
||||||
version
|
|
||||||
);
|
|
||||||
const versionObject = await dotnetVersionResolver.createDotNetVersion();
|
|
||||||
|
|
||||||
expect(!!versionObject.value).toBe(true);
|
await dotnetInstaller.installDotnet();
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
each([
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
'.',
|
`'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A and A.x formats where the major tag is higher than 5. You specified: ${inputVersion}. 'dotnet-quality' input is ignored.`
|
||||||
'..',
|
);
|
||||||
' . ',
|
});
|
||||||
'. ',
|
|
||||||
' .',
|
it(`should warn if the 'quality' input is set and version isn't in A.B.C syntax but major tag is lower then 6`, async () => {
|
||||||
' . . ',
|
const inputVersion = '3.1';
|
||||||
' .. ',
|
const inputQuality = 'ga' as QualityOptions;
|
||||||
' . ',
|
|
||||||
'-1.-1',
|
getExecOutputSpy.mockImplementation(() => {
|
||||||
'-1',
|
return Promise.resolve({exitCode: 0, stdout: '', stderr: ''});
|
||||||
'-1.-1.-1',
|
});
|
||||||
'..3',
|
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||||
'1..3',
|
|
||||||
'1..',
|
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
'.2.3',
|
inputVersion,
|
||||||
'.2.x',
|
inputQuality
|
||||||
'*.',
|
);
|
||||||
'1.2.',
|
|
||||||
'1.2.-abc',
|
await dotnetInstaller.installDotnet();
|
||||||
'a.b',
|
|
||||||
'a.b.c',
|
expect(warningSpy).toHaveBeenCalledWith(
|
||||||
'a.b.c-preview',
|
`'dotnet-quality' input can be used only with .NET SDK version in A.B, A.B.x, A and A.x formats where the major tag is higher than 5. You specified: ${inputVersion}. 'dotnet-quality' input is ignored.`
|
||||||
' 0 . 1 . 2 ',
|
);
|
||||||
'invalid'
|
});
|
||||||
]).test(
|
|
||||||
"if invalid version: '%s' is supplied, it should throw",
|
each(['6', '6.0', '6.0.x', '6.0.*', '6.0.X']).test(
|
||||||
async version => {
|
`should supply 'quality' argument to the installation script if quality input is set and version (%s) is not in A.B.C syntax`,
|
||||||
const dotnetVersionResolver = new installer.DotnetVersionResolver(
|
async inputVersion => {
|
||||||
version
|
const inputQuality = 'ga' as QualityOptions;
|
||||||
|
const exitCode = 0;
|
||||||
|
getExecOutputSpy.mockImplementation(() => {
|
||||||
|
return Promise.resolve({
|
||||||
|
exitCode: exitCode,
|
||||||
|
stdout: '',
|
||||||
|
stderr: ''
|
||||||
|
});
|
||||||
|
});
|
||||||
|
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||||
|
|
||||||
|
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
|
inputVersion,
|
||||||
|
inputQuality
|
||||||
|
);
|
||||||
|
|
||||||
|
await dotnetInstaller.installDotnet();
|
||||||
|
|
||||||
|
const scriptArguments = (
|
||||||
|
getExecOutputSpy.mock.calls[0][1] as string[]
|
||||||
|
).join(' ');
|
||||||
|
const expectedArgument = IS_WINDOWS
|
||||||
|
? `-Quality ${inputQuality}`
|
||||||
|
: `--quality ${inputQuality}`;
|
||||||
|
|
||||||
|
expect(scriptArguments).toContain(expectedArgument);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
await expect(
|
each(['6', '6.0', '6.0.x', '6.0.*', '6.0.X']).test(
|
||||||
async () => await dotnetVersionResolver.createDotNetVersion()
|
`should supply 'channel' argument to the installation script if version (%s) isn't in A.B.C syntax`,
|
||||||
).rejects.toThrow();
|
async inputVersion => {
|
||||||
}
|
const inputQuality = '' as QualityOptions;
|
||||||
);
|
const exitCode = 0;
|
||||||
|
getExecOutputSpy.mockImplementation(() => {
|
||||||
|
return Promise.resolve({
|
||||||
|
exitCode: exitCode,
|
||||||
|
stdout: '',
|
||||||
|
stderr: ''
|
||||||
|
});
|
||||||
|
});
|
||||||
|
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||||
|
|
||||||
each(['3.1', '3.1.x', '3.1.*', '3.1.X']).test(
|
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
"if version: '%s' that can be resolved to 'channel' option is supplied, it should set type to 'channel' in version object",
|
inputVersion,
|
||||||
async version => {
|
inputQuality
|
||||||
const dotnetVersionResolver = new installer.DotnetVersionResolver(
|
);
|
||||||
version
|
|
||||||
|
await dotnetInstaller.installDotnet();
|
||||||
|
|
||||||
|
const scriptArguments = (
|
||||||
|
getExecOutputSpy.mock.calls[0][1] as string[]
|
||||||
|
).join(' ');
|
||||||
|
const expectedArgument = IS_WINDOWS
|
||||||
|
? `-Channel 6.0`
|
||||||
|
: `--channel 6.0`;
|
||||||
|
|
||||||
|
expect(scriptArguments).toContain(expectedArgument);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
const versionObject = await dotnetVersionResolver.createDotNetVersion();
|
|
||||||
|
|
||||||
expect(versionObject.type.toLowerCase().includes('channel')).toBe(true);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
each(['6.0', '6.0.x', '6.0.*', '6.0.X']).test(
|
|
||||||
"if version: '%s' that can be resolved to 'channel' option is supplied and its major tag is >= 6, it should set type to 'channel' and qualityFlag to 'true' in version object",
|
|
||||||
async version => {
|
|
||||||
const dotnetVersionResolver = new installer.DotnetVersionResolver(
|
|
||||||
version
|
|
||||||
);
|
|
||||||
const versionObject = await dotnetVersionResolver.createDotNetVersion();
|
|
||||||
|
|
||||||
expect(versionObject.type.toLowerCase().includes('channel')).toBe(true);
|
|
||||||
expect(versionObject.qualityFlag).toBe(true);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
each(['3.1.2', '3.1.0-preview1']).test(
|
|
||||||
"if version: '%s' that can be resolved to 'version' option is supplied, it should set quality flag to 'false' and type to 'version' in version object",
|
|
||||||
async version => {
|
|
||||||
const dotnetVersionResolver = new installer.DotnetVersionResolver(
|
|
||||||
version
|
|
||||||
);
|
|
||||||
const versionObject = await dotnetVersionResolver.createDotNetVersion();
|
|
||||||
|
|
||||||
expect(versionObject.type.toLowerCase().includes('version')).toBe(true);
|
|
||||||
expect(versionObject.qualityFlag).toBe(false);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
each(['3.1.2', '3.1']).test(
|
|
||||||
'it should create proper line arguments for powershell/bash installation scripts',
|
|
||||||
async version => {
|
|
||||||
const dotnetVersionResolver = new installer.DotnetVersionResolver(
|
|
||||||
version
|
|
||||||
);
|
|
||||||
const versionObject = await dotnetVersionResolver.createDotNetVersion();
|
|
||||||
const windowsRegEx = new RegExp(/^-[VC]/);
|
|
||||||
const nonWindowsRegEx = new RegExp(/^--[vc]/);
|
|
||||||
|
|
||||||
if (IS_WINDOWS) {
|
if (IS_WINDOWS) {
|
||||||
expect(windowsRegEx.test(versionObject.type)).toBe(true);
|
it(`should supply '-ProxyAddress' argument to the installation script if env.variable 'https_proxy' is set`, async () => {
|
||||||
expect(nonWindowsRegEx.test(versionObject.type)).toBe(false);
|
process.env['https_proxy'] = 'https://proxy.com';
|
||||||
} else {
|
const inputVersion = '6.0.100';
|
||||||
expect(nonWindowsRegEx.test(versionObject.type)).toBe(true);
|
const inputQuality = '' as QualityOptions;
|
||||||
expect(windowsRegEx.test(versionObject.type)).toBe(false);
|
|
||||||
|
getExecOutputSpy.mockImplementation(() => {
|
||||||
|
return Promise.resolve({exitCode: 0, stdout: '', stderr: ''});
|
||||||
|
});
|
||||||
|
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||||
|
|
||||||
|
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
|
inputVersion,
|
||||||
|
inputQuality
|
||||||
|
);
|
||||||
|
|
||||||
|
await dotnetInstaller.installDotnet();
|
||||||
|
|
||||||
|
const scriptArguments = (
|
||||||
|
getExecOutputSpy.mock.calls[0][1] as string[]
|
||||||
|
).join(' ');
|
||||||
|
|
||||||
|
expect(scriptArguments).toContain(
|
||||||
|
`-ProxyAddress ${process.env['https_proxy']}`
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should supply '-ProxyBypassList' argument to the installation script if env.variable 'no_proxy' is set`, async () => {
|
||||||
|
process.env['no_proxy'] = 'first.url,second.url';
|
||||||
|
const inputVersion = '6.0.100';
|
||||||
|
const inputQuality = '' as QualityOptions;
|
||||||
|
|
||||||
|
getExecOutputSpy.mockImplementation(() => {
|
||||||
|
return Promise.resolve({exitCode: 0, stdout: '', stderr: ''});
|
||||||
|
});
|
||||||
|
maxSatisfyingSpy.mockImplementation(() => inputVersion);
|
||||||
|
|
||||||
|
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
||||||
|
inputVersion,
|
||||||
|
inputQuality
|
||||||
|
);
|
||||||
|
|
||||||
|
await dotnetInstaller.installDotnet();
|
||||||
|
|
||||||
|
const scriptArguments = (
|
||||||
|
getExecOutputSpy.mock.calls[0][1] as string[]
|
||||||
|
).join(' ');
|
||||||
|
|
||||||
|
expect(scriptArguments).toContain(
|
||||||
|
`-ProxyBypassList ${process.env['no_proxy']}`
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
describe('addToPath() tests', () => {
|
||||||
|
it(`should export DOTNET_ROOT env.var with value from DOTNET_INSTALL_DIR env.var`, async () => {
|
||||||
|
process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir';
|
||||||
|
installer.DotnetCoreInstaller.addToPath();
|
||||||
|
const dotnet_root = process.env['DOTNET_ROOT'];
|
||||||
|
expect(dotnet_root).toBe(process.env['DOTNET_INSTALL_DIR']);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should export value from DOTNET_INSTALL_DIR env.var to the PATH`, async () => {
|
||||||
|
process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir';
|
||||||
|
installer.DotnetCoreInstaller.addToPath();
|
||||||
|
const path = process.env['PATH'];
|
||||||
|
expect(path).toContain(process.env['DOTNET_INSTALL_DIR']);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('DotnetVersionResolver tests', () => {
|
||||||
|
describe('createDotNetVersion() tests', () => {
|
||||||
|
each([
|
||||||
|
'3.1',
|
||||||
|
'3.x',
|
||||||
|
'3.1.x',
|
||||||
|
'3.1.*',
|
||||||
|
'3.1.X',
|
||||||
|
'3.1.2',
|
||||||
|
'3.1.0-preview1'
|
||||||
|
]).test(
|
||||||
|
'if valid version is supplied (%s), it should return version object with some value',
|
||||||
|
async version => {
|
||||||
|
const dotnetVersionResolver = new installer.DotnetVersionResolver(
|
||||||
|
version
|
||||||
|
);
|
||||||
|
const versionObject =
|
||||||
|
await dotnetVersionResolver.createDotNetVersion();
|
||||||
|
|
||||||
|
expect(!!versionObject.value).toBe(true);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
each([
|
||||||
|
'.',
|
||||||
|
'..',
|
||||||
|
' . ',
|
||||||
|
'. ',
|
||||||
|
' .',
|
||||||
|
' . . ',
|
||||||
|
' .. ',
|
||||||
|
' . ',
|
||||||
|
'-1.-1',
|
||||||
|
'-1',
|
||||||
|
'-1.-1.-1',
|
||||||
|
'..3',
|
||||||
|
'1..3',
|
||||||
|
'1..',
|
||||||
|
'.2.3',
|
||||||
|
'.2.x',
|
||||||
|
'*.',
|
||||||
|
'1.2.',
|
||||||
|
'1.2.-abc',
|
||||||
|
'a.b',
|
||||||
|
'a.b.c',
|
||||||
|
'a.b.c-preview',
|
||||||
|
' 0 . 1 . 2 ',
|
||||||
|
'invalid'
|
||||||
|
]).test(
|
||||||
|
'if invalid version is supplied (%s), it should throw',
|
||||||
|
async version => {
|
||||||
|
const dotnetVersionResolver = new installer.DotnetVersionResolver(
|
||||||
|
version
|
||||||
|
);
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
async () => await dotnetVersionResolver.createDotNetVersion()
|
||||||
|
).rejects.toThrow();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
each(['3', '3.1', '3.1.x', '3.1.*', '3.1.X']).test(
|
||||||
|
"if version that can be resolved to 'channel' option is supplied (%s), it should set type to 'channel' in version object",
|
||||||
|
async version => {
|
||||||
|
const dotnetVersionResolver = new installer.DotnetVersionResolver(
|
||||||
|
version
|
||||||
|
);
|
||||||
|
const versionObject =
|
||||||
|
await dotnetVersionResolver.createDotNetVersion();
|
||||||
|
|
||||||
|
expect(versionObject.type.toLowerCase().includes('channel')).toBe(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
each(['6.0', '6.0.x', '6.0.*', '6.0.X']).test(
|
||||||
|
"if version that can be resolved to 'channel' option is supplied and its major tag is >= 6 (%s), it should set type to 'channel' and qualityFlag to 'true' in version object",
|
||||||
|
async version => {
|
||||||
|
const dotnetVersionResolver = new installer.DotnetVersionResolver(
|
||||||
|
version
|
||||||
|
);
|
||||||
|
const versionObject =
|
||||||
|
await dotnetVersionResolver.createDotNetVersion();
|
||||||
|
|
||||||
|
expect(versionObject.type.toLowerCase().includes('channel')).toBe(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
expect(versionObject.qualityFlag).toBe(true);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
each(['3.1.2', '3.1.0-preview1']).test(
|
||||||
|
"if version that can be resolved to 'version' option is supplied (%s), it should set quality flag to 'false' and type to 'version' in version object",
|
||||||
|
async version => {
|
||||||
|
const dotnetVersionResolver = new installer.DotnetVersionResolver(
|
||||||
|
version
|
||||||
|
);
|
||||||
|
const versionObject =
|
||||||
|
await dotnetVersionResolver.createDotNetVersion();
|
||||||
|
|
||||||
|
expect(versionObject.type.toLowerCase().includes('version')).toBe(
|
||||||
|
true
|
||||||
|
);
|
||||||
|
expect(versionObject.qualityFlag).toBe(false);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
each(['3.1.2', '3.1']).test(
|
||||||
|
'it should create proper line arguments for powershell/bash installation scripts',
|
||||||
|
async version => {
|
||||||
|
const dotnetVersionResolver = new installer.DotnetVersionResolver(
|
||||||
|
version
|
||||||
|
);
|
||||||
|
const versionObject =
|
||||||
|
await dotnetVersionResolver.createDotNetVersion();
|
||||||
|
const windowsRegEx = new RegExp(/^-(Version|Channel)/);
|
||||||
|
const nonWindowsRegEx = new RegExp(/^--(version|channel)/);
|
||||||
|
|
||||||
|
if (IS_WINDOWS) {
|
||||||
|
expect(windowsRegEx.test(versionObject.type)).toBe(true);
|
||||||
|
expect(nonWindowsRegEx.test(versionObject.type)).toBe(false);
|
||||||
|
} else {
|
||||||
|
expect(nonWindowsRegEx.test(versionObject.type)).toBe(true);
|
||||||
|
expect(windowsRegEx.test(versionObject.type)).toBe(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function normalizeFileContents(contents: string): string {
|
|
||||||
return contents
|
|
||||||
.trim()
|
|
||||||
.replace(new RegExp('\r\n', 'g'), '\n')
|
|
||||||
.replace(new RegExp('\r', 'g'), '\n');
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getDotnet(version: string, quality = ''): Promise<string> {
|
|
||||||
const dotnetInstaller = new installer.DotnetCoreInstaller(
|
|
||||||
version,
|
|
||||||
quality as QualityOptions
|
|
||||||
);
|
|
||||||
const installedVersion = await dotnetInstaller.installDotnet();
|
|
||||||
installer.DotnetCoreInstaller.addToPath();
|
|
||||||
return installedVersion;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,121 +1,203 @@
|
||||||
import * as io from '@actions/io';
|
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import os from 'os';
|
import semver from 'semver';
|
||||||
import path from 'path';
|
import * as auth from '../src/authutil';
|
||||||
|
|
||||||
import * as setup from '../src/setup-dotnet';
|
import * as setup from '../src/setup-dotnet';
|
||||||
import {IS_WINDOWS} from '../src/utils';
|
import {DotnetCoreInstaller} from '../src/installer';
|
||||||
import {IS_LINUX} from '../src/utils';
|
import * as cacheUtils from '../src/cache-utils';
|
||||||
|
import * as cacheRestore from '../src/cache-restore';
|
||||||
let toolDir: string;
|
|
||||||
|
|
||||||
if (IS_WINDOWS) {
|
|
||||||
toolDir = path.join(process.env['PROGRAMFILES'] + '', 'dotnet');
|
|
||||||
} else if (IS_LINUX) {
|
|
||||||
toolDir = '/usr/share/dotnet';
|
|
||||||
} else {
|
|
||||||
toolDir = path.join(process.env['HOME'] + '', '.dotnet');
|
|
||||||
}
|
|
||||||
|
|
||||||
function createGlobalJsonPath(dotnetVersion: string) {
|
|
||||||
const globalJsonPath = path.join(process.cwd(), 'global.json');
|
|
||||||
const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version": "${dotnetVersion}"${os.EOL}}${os.EOL}}`;
|
|
||||||
if (!fs.existsSync(globalJsonPath)) {
|
|
||||||
fs.writeFileSync(globalJsonPath, jsonContents);
|
|
||||||
}
|
|
||||||
return globalJsonPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
const tempDir = path.join(__dirname, 'runner', 'temp2');
|
|
||||||
|
|
||||||
describe('setup-dotnet tests', () => {
|
describe('setup-dotnet tests', () => {
|
||||||
const getInputSpy = jest.spyOn(core, 'getInput');
|
|
||||||
const getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
|
|
||||||
const getMultilineInputSpy = jest.spyOn(core, 'getMultilineInput');
|
|
||||||
const setOutputSpy = jest.spyOn(core, 'setOutput');
|
|
||||||
|
|
||||||
const inputs = {} as any;
|
const inputs = {} as any;
|
||||||
|
|
||||||
beforeAll(async () => {
|
const getInputSpy = jest.spyOn(core, 'getInput');
|
||||||
process.env.RUNNER_TOOL_CACHE = toolDir;
|
const getMultilineInputSpy = jest.spyOn(core, 'getMultilineInput');
|
||||||
process.env.DOTNET_INSTALL_DIR = toolDir;
|
const getBooleanInputSpy = jest.spyOn(core, 'getBooleanInput');
|
||||||
process.env.RUNNER_TEMP = tempDir;
|
const setFailedSpy = jest.spyOn(core, 'setFailed');
|
||||||
try {
|
const debugSpy = jest.spyOn(core, 'debug');
|
||||||
await io.rmRF(`${toolDir}/*`);
|
const infoSpy = jest.spyOn(core, 'info');
|
||||||
await io.rmRF(`${tempDir}/*`);
|
const setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||||
} catch (err) {
|
|
||||||
console.log(err.message);
|
|
||||||
console.log('Failed to remove test directories');
|
|
||||||
}
|
|
||||||
}, 30000);
|
|
||||||
|
|
||||||
afterEach(async () => {
|
const existsSyncSpy = jest.spyOn(fs, 'existsSync');
|
||||||
try {
|
|
||||||
await io.rmRF(path.join(process.cwd(), 'global.json'));
|
|
||||||
await io.rmRF(`${toolDir}/*`);
|
|
||||||
await io.rmRF(`${tempDir}/*`);
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err.message);
|
|
||||||
console.log('Failed to remove test directories');
|
|
||||||
}
|
|
||||||
}, 30000);
|
|
||||||
|
|
||||||
it('Acquires version of dotnet from global.json if no matching version is installed', async () => {
|
const maxSatisfyingSpy = jest.spyOn(semver, 'maxSatisfying');
|
||||||
createGlobalJsonPath('3.1.201');
|
|
||||||
await setup.run();
|
|
||||||
|
|
||||||
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).toBe(true);
|
const installDotnetSpy = jest.spyOn(
|
||||||
if (IS_WINDOWS) {
|
DotnetCoreInstaller.prototype,
|
||||||
expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
|
'installDotnet'
|
||||||
} else {
|
);
|
||||||
expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
|
const addToPathSpy = jest.spyOn(DotnetCoreInstaller, 'addToPath');
|
||||||
}
|
const isCacheFeatureAvailableSpy = jest.spyOn(
|
||||||
}, 400000);
|
cacheUtils,
|
||||||
|
'isCacheFeatureAvailable'
|
||||||
|
);
|
||||||
|
const restoreCacheSpy = jest.spyOn(cacheRestore, 'restoreCache');
|
||||||
|
const configAuthenticationSpy = jest.spyOn(auth, 'configAuthentication');
|
||||||
|
|
||||||
it("Sets output with the latest installed by action version if global.json file isn't specified", async () => {
|
describe('run() tests', () => {
|
||||||
inputs['cache'] = false;
|
beforeEach(() => {
|
||||||
inputs['dotnet-version'] = ['3.1.201', '6.0.401'];
|
getMultilineInputSpy.mockImplementation(input => inputs[input as string]);
|
||||||
|
getInputSpy.mockImplementation(input => inputs[input as string]);
|
||||||
|
getBooleanInputSpy.mockImplementation(input => inputs[input as string]);
|
||||||
|
});
|
||||||
|
|
||||||
getBooleanInputSpy.mockImplementation(input => inputs[input]);
|
afterEach(() => {
|
||||||
getMultilineInputSpy.mockImplementation(input => inputs[input]);
|
jest.clearAllMocks();
|
||||||
|
jest.resetAllMocks();
|
||||||
|
});
|
||||||
|
|
||||||
await setup.run();
|
it('should fail the action if global-json-file input is present, but the file does not exist in the file system', async () => {
|
||||||
|
inputs['global-json-file'] = 'fictitious.json';
|
||||||
|
inputs['dotnet-version'] = [];
|
||||||
|
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith('dotnet-version', '6.0.401');
|
const expectedErrorMessage = `The specified global.json file '${inputs['global-json-file']}' does not exist`;
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', false);
|
|
||||||
}, 400000);
|
|
||||||
|
|
||||||
it("Sets output with the version specified in global.json, if it's present", async () => {
|
await setup.run();
|
||||||
createGlobalJsonPath('3.0.103');
|
expect(setFailedSpy).toHaveBeenCalledWith(expectedErrorMessage);
|
||||||
|
});
|
||||||
|
|
||||||
inputs['cache'] = false;
|
test(`if 'dotnet-version' and 'global-json-file' inputs aren't present, should log into debug output, try to find global.json in the repo root, fail and log message into info output`, async () => {
|
||||||
inputs['dotnet-version'] = ['3.1.201', '6.0.401'];
|
inputs['global-json-file'] = '';
|
||||||
inputs['global-json-file'] = './global.json';
|
inputs['dotnet-version'] = [];
|
||||||
|
|
||||||
getBooleanInputSpy.mockImplementation(input => inputs[input]);
|
maxSatisfyingSpy.mockImplementation(() => null);
|
||||||
getMultilineInputSpy.mockImplementation(input => inputs[input]);
|
setOutputSpy.mockImplementation(() => {});
|
||||||
getInputSpy.mockImplementation(input => inputs[input]);
|
|
||||||
|
|
||||||
await setup.run();
|
const expectedDebugMessage =
|
||||||
|
'No version found, trying to find version from global.json';
|
||||||
|
const expectedInfoMessage = `global.json wasn't found in the root directory. No .NET version will be installed.`;
|
||||||
|
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith('dotnet-version', '3.0.103');
|
await setup.run();
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', false);
|
|
||||||
}, 400000);
|
|
||||||
|
|
||||||
it('Sets output with the version specified in global.json with absolute path', async () => {
|
expect(debugSpy).toHaveBeenCalledWith(expectedDebugMessage);
|
||||||
const globalJsonPath = createGlobalJsonPath('3.0.103');
|
expect(existsSyncSpy).toHaveBeenCalled();
|
||||||
|
expect(infoSpy).toHaveBeenCalledWith(expectedInfoMessage);
|
||||||
|
});
|
||||||
|
|
||||||
inputs['dotnet-version'] = ['3.1.201', '6.0.401'];
|
it('should fail the action if quality is supplied but its value is not supported', async () => {
|
||||||
inputs['global-json-file'] = globalJsonPath;
|
inputs['global-json-file'] = '';
|
||||||
|
inputs['dotnet-version'] = ['6.0'];
|
||||||
|
inputs['dotnet-quality'] = 'fictitiousQuality';
|
||||||
|
|
||||||
getMultilineInputSpy.mockImplementation(input => inputs[input]);
|
const expectedErrorMessage = `${inputs['dotnet-quality']} is not a supported value for 'dotnet-quality' option. Supported values are: daily, signed, validated, preview, ga.`;
|
||||||
|
|
||||||
getInputSpy.mockImplementation(input => inputs[input]);
|
await setup.run();
|
||||||
|
expect(setFailedSpy).toHaveBeenCalledWith(expectedErrorMessage);
|
||||||
|
});
|
||||||
|
|
||||||
await setup.run();
|
it('should call installDotnet() multiple times if dotnet-version multiline input is provided', async () => {
|
||||||
|
inputs['global-json-file'] = '';
|
||||||
|
inputs['dotnet-version'] = ['6.0', '7.0'];
|
||||||
|
inputs['dotnet-quality'] = '';
|
||||||
|
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith('dotnet-version', '3.0.103');
|
installDotnetSpy.mockImplementation(() => Promise.resolve(''));
|
||||||
expect(setOutputSpy).toHaveBeenCalledWith('cache-hit', false);
|
|
||||||
}, 400000);
|
await setup.run();
|
||||||
|
expect(installDotnetSpy).toHaveBeenCalledTimes(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call addToPath() after installation complete', async () => {
|
||||||
|
inputs['global-json-file'] = '';
|
||||||
|
inputs['dotnet-version'] = ['6.0', '7.0'];
|
||||||
|
inputs['dotnet-quality'] = '';
|
||||||
|
|
||||||
|
installDotnetSpy.mockImplementation(() => Promise.resolve(''));
|
||||||
|
addToPathSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
await setup.run();
|
||||||
|
expect(addToPathSpy).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call auth.configAuthentication() if source-url input is provided', async () => {
|
||||||
|
inputs['global-json-file'] = '';
|
||||||
|
inputs['dotnet-version'] = [];
|
||||||
|
inputs['dotnet-quality'] = '';
|
||||||
|
inputs['source-url'] = 'fictitious.source.url';
|
||||||
|
|
||||||
|
configAuthenticationSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
await setup.run();
|
||||||
|
expect(configAuthenticationSpy).toHaveBeenCalledWith(
|
||||||
|
inputs['source-url'],
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call auth.configAuthentication() with proper parameters if source-url and config-file inputs are provided', async () => {
|
||||||
|
inputs['global-json-file'] = '';
|
||||||
|
inputs['dotnet-version'] = [];
|
||||||
|
inputs['dotnet-quality'] = '';
|
||||||
|
inputs['source-url'] = 'fictitious.source.url';
|
||||||
|
inputs['config-file'] = 'fictitious.path';
|
||||||
|
|
||||||
|
configAuthenticationSpy.mockImplementation(() => {});
|
||||||
|
setOutputSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
await setup.run();
|
||||||
|
expect(configAuthenticationSpy).toHaveBeenCalledWith(
|
||||||
|
inputs['source-url'],
|
||||||
|
inputs['config-file']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should call setOutput() after installation complete', async () => {
|
||||||
|
inputs['dotnet-version'] = ['6.0.300'];
|
||||||
|
|
||||||
|
installDotnetSpy.mockImplementation(() => Promise.resolve(''));
|
||||||
|
addToPathSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
await setup.run();
|
||||||
|
expect(setOutputSpy).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`should get 'cache-dependency-path' and call restoreCache() if input cache is set to true and cache feature is available`, async () => {
|
||||||
|
inputs['dotnet-version'] = ['6.0.300'];
|
||||||
|
inputs['dotnet-quality'] = '';
|
||||||
|
inputs['cache'] = true;
|
||||||
|
inputs['cache-dependency-path'] = 'fictitious.package.lock.json';
|
||||||
|
|
||||||
|
installDotnetSpy.mockImplementation(() => Promise.resolve(''));
|
||||||
|
addToPathSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
isCacheFeatureAvailableSpy.mockImplementation(() => true);
|
||||||
|
restoreCacheSpy.mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
|
await setup.run();
|
||||||
|
expect(isCacheFeatureAvailableSpy).toHaveBeenCalledTimes(1);
|
||||||
|
expect(restoreCacheSpy).toHaveBeenCalledWith(
|
||||||
|
inputs['cache-dependency-path']
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`shouldn't call restoreCache() if input cache isn't set to true`, async () => {
|
||||||
|
inputs['dotnet-version'] = ['6.0.300'];
|
||||||
|
inputs['dotnet-quality'] = '';
|
||||||
|
inputs['cache'] = false;
|
||||||
|
|
||||||
|
installDotnetSpy.mockImplementation(() => Promise.resolve(''));
|
||||||
|
addToPathSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
isCacheFeatureAvailableSpy.mockImplementation(() => true);
|
||||||
|
restoreCacheSpy.mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
|
await setup.run();
|
||||||
|
expect(restoreCacheSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`shouldn't call restoreCache() if cache feature isn't available`, async () => {
|
||||||
|
inputs['dotnet-version'] = ['6.0.300'];
|
||||||
|
inputs['dotnet-quality'] = '';
|
||||||
|
inputs['cache'] = true;
|
||||||
|
|
||||||
|
installDotnetSpy.mockImplementation(() => Promise.resolve(''));
|
||||||
|
addToPathSpy.mockImplementation(() => {});
|
||||||
|
|
||||||
|
isCacheFeatureAvailableSpy.mockImplementation(() => false);
|
||||||
|
restoreCacheSpy.mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
|
await setup.run();
|
||||||
|
expect(restoreCacheSpy).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -58476,91 +58476,91 @@ exports["default"] = _default;
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
}
|
}
|
||||||
Object.defineProperty(o, k2, desc);
|
Object.defineProperty(o, k2, desc);
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.run = void 0;
|
exports.run = void 0;
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
const node_fs_1 = __importDefault(__nccwpck_require__(7561));
|
const node_fs_1 = __importDefault(__nccwpck_require__(7561));
|
||||||
const cache_utils_1 = __nccwpck_require__(1678);
|
const cache_utils_1 = __nccwpck_require__(1678);
|
||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
// Catch and log any unhandled exceptions. These exceptions can leak out of the uploadChunk method in
|
||||||
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
// @actions/toolkit when a failed upload closes the file descriptor causing any in-process reads to
|
||||||
// throw an uncaught exception. Instead of failing this action, just warn.
|
// throw an uncaught exception. Instead of failing this action, just warn.
|
||||||
process.on('uncaughtException', e => {
|
process.on('uncaughtException', e => {
|
||||||
const warningPrefix = '[warning]';
|
const warningPrefix = '[warning]';
|
||||||
core.info(`${warningPrefix}${e.message}`);
|
core.info(`${warningPrefix}${e.message}`);
|
||||||
});
|
});
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
if (core.getBooleanInput('cache')) {
|
if (core.getBooleanInput('cache')) {
|
||||||
yield cachePackages();
|
yield cachePackages();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
exports.run = run;
|
exports.run = run;
|
||||||
const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () {
|
const cachePackages = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const state = core.getState(constants_1.State.CacheMatchedKey);
|
const state = core.getState(constants_1.State.CacheMatchedKey);
|
||||||
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
|
const primaryKey = core.getState(constants_1.State.CachePrimaryKey);
|
||||||
if (!primaryKey) {
|
if (!primaryKey) {
|
||||||
core.info('Primary key was not generated, not saving cache.');
|
core.info('Primary key was not generated, not saving cache.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { 'global-packages': cachePath } = yield (0, cache_utils_1.getNuGetFolderPath)();
|
const { 'global-packages': cachePath } = yield (0, cache_utils_1.getNuGetFolderPath)();
|
||||||
if (!node_fs_1.default.existsSync(cachePath)) {
|
if (!node_fs_1.default.existsSync(cachePath)) {
|
||||||
throw new Error(`Cache folder path is retrieved for .NET CLI but doesn't exist on disk: ${cachePath}`);
|
throw new Error(`Cache folder path is retrieved for .NET CLI but doesn't exist on disk: ${cachePath}`);
|
||||||
}
|
}
|
||||||
if (primaryKey === state) {
|
if (primaryKey === state) {
|
||||||
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
|
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const cacheId = yield cache.saveCache([cachePath], primaryKey);
|
const cacheId = yield cache.saveCache([cachePath], primaryKey);
|
||||||
if (cacheId == -1) {
|
if (cacheId == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
core.info(`Cache saved with the key: ${primaryKey}`);
|
core.info(`Cache saved with the key: ${primaryKey}`);
|
||||||
});
|
});
|
||||||
run();
|
run();
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
@ -58569,114 +58569,114 @@ run();
|
||||||
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||||
}
|
}
|
||||||
Object.defineProperty(o, k2, desc);
|
Object.defineProperty(o, k2, desc);
|
||||||
}) : (function(o, m, k, k2) {
|
}) : (function(o, m, k, k2) {
|
||||||
if (k2 === undefined) k2 = k;
|
if (k2 === undefined) k2 = k;
|
||||||
o[k2] = m[k];
|
o[k2] = m[k];
|
||||||
}));
|
}));
|
||||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||||
}) : function(o, v) {
|
}) : function(o, v) {
|
||||||
o["default"] = v;
|
o["default"] = v;
|
||||||
});
|
});
|
||||||
var __importStar = (this && this.__importStar) || function (mod) {
|
var __importStar = (this && this.__importStar) || function (mod) {
|
||||||
if (mod && mod.__esModule) return mod;
|
if (mod && mod.__esModule) return mod;
|
||||||
var result = {};
|
var result = {};
|
||||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||||
__setModuleDefault(result, mod);
|
__setModuleDefault(result, mod);
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.isCacheFeatureAvailable = exports.getNuGetFolderPath = void 0;
|
exports.isCacheFeatureAvailable = exports.getNuGetFolderPath = void 0;
|
||||||
const cache = __importStar(__nccwpck_require__(7799));
|
const cache = __importStar(__nccwpck_require__(7799));
|
||||||
const core = __importStar(__nccwpck_require__(2186));
|
const core = __importStar(__nccwpck_require__(2186));
|
||||||
const exec = __importStar(__nccwpck_require__(1514));
|
const exec = __importStar(__nccwpck_require__(1514));
|
||||||
const constants_1 = __nccwpck_require__(9042);
|
const constants_1 = __nccwpck_require__(9042);
|
||||||
/**
|
/**
|
||||||
* Get NuGet global packages, cache, and temp folders from .NET CLI.
|
* Get NuGet global packages, cache, and temp folders from .NET CLI.
|
||||||
* @returns (Folder Name)-(Path) mappings
|
* @returns (Folder Name)-(Path) mappings
|
||||||
* @see https://docs.microsoft.com/nuget/consume-packages/managing-the-global-packages-and-cache-folders
|
* @see https://docs.microsoft.com/nuget/consume-packages/managing-the-global-packages-and-cache-folders
|
||||||
* @example
|
* @example
|
||||||
* Windows
|
* Windows
|
||||||
* ```json
|
* ```json
|
||||||
* {
|
* {
|
||||||
* "http-cache": "C:\\Users\\user1\\AppData\\Local\\NuGet\\v3-cache",
|
* "http-cache": "C:\\Users\\user1\\AppData\\Local\\NuGet\\v3-cache",
|
||||||
* "global-packages": "C:\\Users\\user1\\.nuget\\packages\\",
|
* "global-packages": "C:\\Users\\user1\\.nuget\\packages\\",
|
||||||
* "temp": "C:\\Users\\user1\\AppData\\Local\\Temp\\NuGetScratch",
|
* "temp": "C:\\Users\\user1\\AppData\\Local\\Temp\\NuGetScratch",
|
||||||
* "plugins-cache": "C:\\Users\\user1\\AppData\\Local\\NuGet\\plugins-cache"
|
* "plugins-cache": "C:\\Users\\user1\\AppData\\Local\\NuGet\\plugins-cache"
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
* Mac/Linux
|
* Mac/Linux
|
||||||
* ```json
|
* ```json
|
||||||
* {
|
* {
|
||||||
* "http-cache": "/home/user1/.local/share/NuGet/v3-cache",
|
* "http-cache": "/home/user1/.local/share/NuGet/v3-cache",
|
||||||
* "global-packages": "/home/user1/.nuget/packages/",
|
* "global-packages": "/home/user1/.nuget/packages/",
|
||||||
* "temp": "/tmp/NuGetScratch",
|
* "temp": "/tmp/NuGetScratch",
|
||||||
* "plugins-cache": "/home/user1/.local/share/NuGet/plugins-cache"
|
* "plugins-cache": "/home/user1/.local/share/NuGet/plugins-cache"
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
const getNuGetFolderPath = () => __awaiter(void 0, void 0, void 0, function* () {
|
const getNuGetFolderPath = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
const { stdout, stderr, exitCode } = yield exec.getExecOutput(constants_1.cliCommand, undefined, { ignoreReturnCode: true, silent: true });
|
const { stdout, stderr, exitCode } = yield exec.getExecOutput(constants_1.cliCommand, undefined, { ignoreReturnCode: true, silent: true });
|
||||||
if (exitCode) {
|
if (exitCode) {
|
||||||
throw new Error(!stderr.trim()
|
throw new Error(!stderr.trim()
|
||||||
? `The '${constants_1.cliCommand}' command failed with exit code: ${exitCode}`
|
? `The '${constants_1.cliCommand}' command failed with exit code: ${exitCode}`
|
||||||
: stderr);
|
: stderr);
|
||||||
}
|
}
|
||||||
const result = {
|
const result = {
|
||||||
'http-cache': '',
|
'http-cache': '',
|
||||||
'global-packages': '',
|
'global-packages': '',
|
||||||
temp: '',
|
temp: '',
|
||||||
'plugins-cache': ''
|
'plugins-cache': ''
|
||||||
};
|
};
|
||||||
const regex = /(?:^|\s)(?<key>[a-z-]+): (?<path>.+[/\\].+)$/gm;
|
const regex = /(?:^|\s)(?<key>[a-z-]+): (?<path>.+[/\\].+)$/gm;
|
||||||
let match;
|
let match;
|
||||||
while ((match = regex.exec(stdout)) !== null) {
|
while ((match = regex.exec(stdout)) !== null) {
|
||||||
const key = match.groups.key;
|
const key = match.groups.key;
|
||||||
if (key in result) {
|
if (key in result) {
|
||||||
result[key] = match.groups.path;
|
result[key] = match.groups.path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
exports.getNuGetFolderPath = getNuGetFolderPath;
|
exports.getNuGetFolderPath = getNuGetFolderPath;
|
||||||
function isCacheFeatureAvailable() {
|
function isCacheFeatureAvailable() {
|
||||||
if (cache.isFeatureAvailable()) {
|
if (cache.isFeatureAvailable()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (isGhes()) {
|
if (isGhes()) {
|
||||||
core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
|
core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
||||||
/**
|
/**
|
||||||
* Returns this action runs on GitHub Enterprise Server or not.
|
* Returns this action runs on GitHub Enterprise Server or not.
|
||||||
* (port from https://github.com/actions/toolkit/blob/457303960f03375db6f033e214b9f90d79c3fe5c/packages/cache/src/internal/cacheUtils.ts#L134)
|
* (port from https://github.com/actions/toolkit/blob/457303960f03375db6f033e214b9f90d79c3fe5c/packages/cache/src/internal/cacheUtils.ts#L134)
|
||||||
*/
|
*/
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
const url = process.env['GITHUB_SERVER_URL'] || 'https://github.com';
|
const url = process.env['GITHUB_SERVER_URL'] || 'https://github.com';
|
||||||
return new URL(url).hostname.toUpperCase() !== 'GITHUB.COM';
|
return new URL(url).hostname.toUpperCase() !== 'GITHUB.COM';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
@ -58685,26 +58685,26 @@ function isGhes() {
|
||||||
/***/ ((__unused_webpack_module, exports) => {
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.Outputs = exports.State = exports.cliCommand = exports.lockFilePatterns = void 0;
|
exports.Outputs = exports.State = exports.cliCommand = exports.lockFilePatterns = void 0;
|
||||||
/** NuGet lock file patterns */
|
/** NuGet lock file patterns */
|
||||||
exports.lockFilePatterns = ['packages.lock.json'];
|
exports.lockFilePatterns = ['packages.lock.json'];
|
||||||
/**
|
/**
|
||||||
* .NET CLI command to list local NuGet resources.
|
* .NET CLI command to list local NuGet resources.
|
||||||
* @see https://docs.microsoft.com/dotnet/core/tools/dotnet-nuget-locals
|
* @see https://docs.microsoft.com/dotnet/core/tools/dotnet-nuget-locals
|
||||||
*/
|
*/
|
||||||
exports.cliCommand = 'dotnet nuget locals all --list --force-english-output';
|
exports.cliCommand = 'dotnet nuget locals all --list --force-english-output';
|
||||||
var State;
|
var State;
|
||||||
(function (State) {
|
(function (State) {
|
||||||
State["CachePrimaryKey"] = "CACHE_KEY";
|
State["CachePrimaryKey"] = "CACHE_KEY";
|
||||||
State["CacheMatchedKey"] = "CACHE_RESULT";
|
State["CacheMatchedKey"] = "CACHE_RESULT";
|
||||||
})(State = exports.State || (exports.State = {}));
|
})(State = exports.State || (exports.State = {}));
|
||||||
var Outputs;
|
var Outputs;
|
||||||
(function (Outputs) {
|
(function (Outputs) {
|
||||||
Outputs["CacheHit"] = "cache-hit";
|
Outputs["CacheHit"] = "cache-hit";
|
||||||
Outputs["DotnetVersion"] = "dotnet-version";
|
Outputs["DotnetVersion"] = "dotnet-version";
|
||||||
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
})(Outputs = exports.Outputs || (exports.Outputs = {}));
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
Loading…
Reference in New Issue