Skip to content

Commit 4039072

Browse files
author
Zachary Eisinger
committed
Merge branch 'support-latest-version' of https://github.com/litetex/setup-dotnet-forked into litetex-support-latest-version
2 parents db2ebd0 + 983c8ef commit 4039072

File tree

4 files changed

+267
-36
lines changed

4 files changed

+267
-36
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ steps:
2020
- uses: actions/checkout@master
2121
- uses: actions/setup-dotnet@v1
2222
with:
23-
dotnet-version: '3.1.100' # SDK Version to use.
23+
dotnet-version: '3.1.x' # SDK Version to use; x will use the latest version of the 3.1 channel
2424
- run: dotnet build <my project>
2525
```
2626
@@ -31,7 +31,7 @@ jobs:
3131
runs-on: ubuntu-16.04
3232
strategy:
3333
matrix:
34-
dotnet: [ '2.2.103', '3.0.100', '3.1.100' ]
34+
dotnet: [ '2.2.103', '3.0', '3.1.x' ]
3535
name: Dotnet ${{ matrix.dotnet }} sample
3636
steps:
3737
- uses: actions/checkout@master
@@ -49,7 +49,7 @@ steps:
4949
# Authenticates packages to push to GPR
5050
- uses: actions/setup-dotnet@v1
5151
with:
52-
dotnet-version: '3.1.100' # SDK Version to use.
52+
dotnet-version: '3.1.x' # SDK Version to use.
5353
source-url: https://nuget.pkg.github.com/<owner>/index.json
5454
env:
5555
NUGET_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

__tests__/installer.test.ts

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import os = require('os');
44
import path = require('path');
55
import hc = require('@actions/http-client');
66

7+
import each from 'jest-each';
8+
79
const toolDir = path.join(__dirname, 'runner', 'tools');
810
const tempDir = path.join(__dirname, 'runner', 'temp');
911

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

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

19+
describe('version tests', () => {
20+
each(['3.1.999', '3.1.101-preview.3']).test(
21+
"Exact version '%s' should be the same",
22+
vers => {
23+
let versInfo = new installer.DotNetVersionInfo(vers);
24+
25+
expect(versInfo.isExactVersion()).toBe(true);
26+
expect(versInfo.version()).toBe(vers);
27+
}
28+
);
29+
30+
each([['3.1.x', '3.1'], ['1.1.*', '1.1'], ['2.0', '2.0']]).test(
31+
"Generic version '%s' should be '%s'",
32+
(vers, resVers) => {
33+
let versInfo = new installer.DotNetVersionInfo(vers);
34+
35+
expect(versInfo.isExactVersion()).toBe(false);
36+
expect(versInfo.version()).toBe(resVers);
37+
}
38+
);
39+
40+
each([
41+
'',
42+
'.',
43+
'..',
44+
' . ',
45+
'. ',
46+
' .',
47+
' . . ',
48+
' .. ',
49+
' . ',
50+
'-1.-1',
51+
'-1',
52+
'-1.-1.-1',
53+
'..3',
54+
'1..3',
55+
'1..',
56+
'.2.3',
57+
'.2.x',
58+
'1',
59+
'2.x',
60+
'*.*.1',
61+
'*.1',
62+
'*.',
63+
'1.2.',
64+
'1.2.-abc',
65+
'a.b',
66+
'a.b.c',
67+
'a.b.c-preview',
68+
' 0 . 1 . 2 '
69+
]).test("Malformed version '%s' should throw", vers => {
70+
expect(() => new installer.DotNetVersionInfo(vers)).toThrow();
71+
});
72+
});
73+
1774
describe('installer tests', () => {
1875
beforeAll(async () => {
1976
await io.rmRF(toolDir);
@@ -29,6 +86,51 @@ describe('installer tests', () => {
2986
}
3087
}, 100000);
3188

89+
it('Resolving a normal generic version works', async () => {
90+
const dotnetInstaller = new installer.DotnetCoreInstaller('3.1.x');
91+
let versInfo = await dotnetInstaller.resolveInfos(
92+
['win-x64'],
93+
new installer.DotNetVersionInfo('3.1.x')
94+
);
95+
96+
expect(versInfo.resolvedVersion.startsWith('3.1.'));
97+
}, 100000);
98+
99+
it('Resolving a nonexistent generic version fails', async () => {
100+
const dotnetInstaller = new installer.DotnetCoreInstaller('999.1.x');
101+
try {
102+
await dotnetInstaller.resolveInfos(
103+
['win-x64'],
104+
new installer.DotNetVersionInfo('999.1.x')
105+
);
106+
fail();
107+
} catch {
108+
expect(true);
109+
}
110+
}, 100000);
111+
112+
it('Resolving a exact stable version works', async () => {
113+
const dotnetInstaller = new installer.DotnetCoreInstaller('3.1.201');
114+
let versInfo = await dotnetInstaller.resolveInfos(
115+
['win-x64'],
116+
new installer.DotNetVersionInfo('3.1.201')
117+
);
118+
119+
expect(versInfo.resolvedVersion).toBe('3.1.201');
120+
}, 100000);
121+
122+
it('Resolving a exact preview version works', async () => {
123+
const dotnetInstaller = new installer.DotnetCoreInstaller(
124+
'5.0.0-preview.4'
125+
);
126+
let versInfo = await dotnetInstaller.resolveInfos(
127+
['win-x64'],
128+
new installer.DotNetVersionInfo('5.0.0-preview.4')
129+
);
130+
131+
expect(versInfo.resolvedVersion).toBe('5.0.0-preview.4');
132+
}, 100000);
133+
32134
it('Acquires version of dotnet if no matching version is installed', async () => {
33135
await getDotnet('2.2.205');
34136
const dotnetDir = path.join(toolDir, 'dncs', '2.2.205', os.arch());
@@ -39,7 +141,7 @@ describe('installer tests', () => {
39141
} else {
40142
expect(fs.existsSync(path.join(dotnetDir, 'dotnet'))).toBe(true);
41143
}
42-
}, 100000);
144+
}, 400000); //This needs some time to download on "slower" internet connections
43145

44146
it('Acquires version of dotnet if no matching version is installed', async () => {
45147
const dotnetDir = path.join(toolDir, 'dncs', '2.2.105', os.arch());

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ branding:
66
color: green
77
inputs:
88
dotnet-version:
9-
description: 'SDK version to use. Example: 2.2.104'
9+
description: 'SDK version to use. Examples: 2.2.104, 3.1, 3.1.x'
1010
source-url:
1111
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'
1212
owner:

0 commit comments

Comments
 (0)