Skip to content

Commit

Permalink
Merge branch 'support-latest-version' of https://github.com/litetex/s…
Browse files Browse the repository at this point in the history
…etup-dotnet-forked into litetex-support-latest-version
  • Loading branch information
Zachary Eisinger committed May 29, 2020
2 parents db2ebd0 + 983c8ef commit 4039072
Show file tree
Hide file tree
Showing 4 changed files with 267 additions and 36 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ steps:
- uses: actions/checkout@master
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.100' # SDK Version to use.
dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel
- run: dotnet build <my project>
```
Expand All @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-16.04
strategy:
matrix:
dotnet: [ '2.2.103', '3.0.100', '3.1.100' ]
dotnet: [ '2.2.103', '3.0', '3.1.x' ]
name: Dotnet ${{ matrix.dotnet }} sample
steps:
- uses: actions/checkout@master
Expand All @@ -49,7 +49,7 @@ steps:
# Authenticates packages to push to GPR
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.100' # SDK Version to use.
dotnet-version: '3.1.x' # SDK Version to use.
source-url: https://nuget.pkg.github.com/<owner>/index.json
env:
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
Expand Down
104 changes: 103 additions & 1 deletion __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import os = require('os');
import path = require('path');
import hc = require('@actions/http-client');

import each from 'jest-each';

const toolDir = path.join(__dirname, 'runner', 'tools');
const tempDir = path.join(__dirname, 'runner', 'temp');

Expand All @@ -14,6 +16,61 @@ import * as installer from '../src/installer';

const IS_WINDOWS = process.platform === 'win32';

describe('version tests', () => {
each(['3.1.999', '3.1.101-preview.3']).test(
"Exact version '%s' should be the same",
vers => {
let versInfo = new installer.DotNetVersionInfo(vers);

expect(versInfo.isExactVersion()).toBe(true);
expect(versInfo.version()).toBe(vers);
}
);

each([['3.1.x', '3.1'], ['1.1.*', '1.1'], ['2.0', '2.0']]).test(
"Generic version '%s' should be '%s'",
(vers, resVers) => {
let versInfo = new installer.DotNetVersionInfo(vers);

expect(versInfo.isExactVersion()).toBe(false);
expect(versInfo.version()).toBe(resVers);
}
);

each([
'',
'.',
'..',
' . ',
'. ',
' .',
' . . ',
' .. ',
' . ',
'-1.-1',
'-1',
'-1.-1.-1',
'..3',
'1..3',
'1..',
'.2.3',
'.2.x',
'1',
'2.x',
'*.*.1',
'*.1',
'*.',
'1.2.',
'1.2.-abc',
'a.b',
'a.b.c',
'a.b.c-preview',
' 0 . 1 . 2 '
]).test("Malformed version '%s' should throw", vers => {
expect(() => new installer.DotNetVersionInfo(vers)).toThrow();
});
});

describe('installer tests', () => {
beforeAll(async () => {
await io.rmRF(toolDir);
Expand All @@ -29,6 +86,51 @@ describe('installer tests', () => {
}
}, 100000);

it('Resolving a normal generic version works', async () => {
const dotnetInstaller = new installer.DotnetCoreInstaller('3.1.x');
let versInfo = await dotnetInstaller.resolveInfos(
['win-x64'],
new installer.DotNetVersionInfo('3.1.x')
);

expect(versInfo.resolvedVersion.startsWith('3.1.'));
}, 100000);

it('Resolving a nonexistent generic version fails', async () => {
const dotnetInstaller = new installer.DotnetCoreInstaller('999.1.x');
try {
await dotnetInstaller.resolveInfos(
['win-x64'],
new installer.DotNetVersionInfo('999.1.x')
);
fail();
} catch {
expect(true);
}
}, 100000);

it('Resolving a exact stable version works', async () => {
const dotnetInstaller = new installer.DotnetCoreInstaller('3.1.201');
let versInfo = await dotnetInstaller.resolveInfos(
['win-x64'],
new installer.DotNetVersionInfo('3.1.201')
);

expect(versInfo.resolvedVersion).toBe('3.1.201');
}, 100000);

it('Resolving a exact preview version works', async () => {
const dotnetInstaller = new installer.DotnetCoreInstaller(
'5.0.0-preview.4'
);
let versInfo = await dotnetInstaller.resolveInfos(
['win-x64'],
new installer.DotNetVersionInfo('5.0.0-preview.4')
);

expect(versInfo.resolvedVersion).toBe('5.0.0-preview.4');
}, 100000);

it('Acquires version of dotnet if no matching version is installed', async () => {
await getDotnet('2.2.205');
const dotnetDir = path.join(toolDir, 'dncs', '2.2.205', os.arch());
Expand All @@ -39,7 +141,7 @@ describe('installer tests', () => {
} else {
expect(fs.existsSync(path.join(dotnetDir, 'dotnet'))).toBe(true);
}
}, 100000);
}, 400000); //This needs some time to download on "slower" internet connections

it('Acquires version of dotnet if no matching version is installed', async () => {
const dotnetDir = path.join(toolDir, 'dncs', '2.2.105', os.arch());
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ branding:
color: green
inputs:
dotnet-version:
description: 'SDK version to use. Example: 2.2.104'
description: 'SDK version to use. Examples: 2.2.104, 3.1, 3.1.x'
source-url:
description: 'Optional package source for which to set up authentication. Will consult any existing NuGet.config in the root of the repo and provide a temporary NuGet.config using the NUGET_AUTH_TOKEN environment variable as a ClearTextPassword'
owner:
Expand Down
Loading

0 comments on commit 4039072

Please sign in to comment.