Skip to content

Commit db2ebd0

Browse files
author
Zachary Eisinger
authored
Merge pull request #74 from actions/global-json
Fallback to global json if no version given
2 parents 00f2601 + 7895df1 commit db2ebd0

File tree

7 files changed

+2509
-5686
lines changed

7 files changed

+2509
-5686
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# dev dependencies are *not* checked in
2+
global.json
13
lib/
24
node_modules/
35
__tests__/runner/*

__tests__/installer.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const tempDir = path.join(__dirname, 'runner', 'temp');
99

1010
process.env['RUNNER_TOOL_CACHE'] = toolDir;
1111
process.env['RUNNER_TEMP'] = tempDir;
12+
import * as setup from '../src/setup-dotnet';
1213
import * as installer from '../src/installer';
1314

1415
const IS_WINDOWS = process.platform === 'win32';
@@ -40,6 +41,25 @@ describe('installer tests', () => {
4041
}
4142
}, 100000);
4243

44+
it('Acquires version of dotnet if no matching version is installed', async () => {
45+
const dotnetDir = path.join(toolDir, 'dncs', '2.2.105', os.arch());
46+
47+
const globalJsonPath = path.join(process.cwd(), 'global.json');
48+
const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version": "2.2.105"${os.EOL}}${os.EOL}}`;
49+
if (!fs.existsSync(globalJsonPath)) {
50+
fs.writeFileSync(globalJsonPath, jsonContents);
51+
}
52+
await setup.run();
53+
54+
expect(fs.existsSync(`${dotnetDir}.complete`)).toBe(true);
55+
if (IS_WINDOWS) {
56+
expect(fs.existsSync(path.join(dotnetDir, 'dotnet.exe'))).toBe(true);
57+
} else {
58+
expect(fs.existsSync(path.join(dotnetDir, 'dotnet'))).toBe(true);
59+
}
60+
fs.unlinkSync(globalJsonPath);
61+
}, 100000);
62+
4363
it('Throws if no location contains correct dotnet version', async () => {
4464
let thrown = false;
4565
try {

dist/index.js

Lines changed: 135 additions & 50 deletions
Large diffs are not rendered by default.

externals/install-dotnet.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ get_current_os_name() {
172172
return 0
173173
elif [ "$uname" = "FreeBSD" ]; then
174174
echo "freebsd"
175-
return 0
175+
return 0
176176
elif [ "$uname" = "Linux" ]; then
177177
local linux_platform_name
178178
linux_platform_name="$(get_linux_platform_name)" || { echo "linux" && return 0 ; }
@@ -728,11 +728,12 @@ downloadcurl() {
728728
# Append feed_credential as late as possible before calling curl to avoid logging feed_credential
729729
remote_path="${remote_path}${feed_credential}"
730730
731+
local curl_options="--retry 20 --retry-delay 2 --connect-timeout 15 -sSL -f --create-dirs "
731732
local failed=false
732733
if [ -z "$out_path" ]; then
733-
curl --retry 10 -sSL -f --create-dirs "$remote_path" || failed=true
734+
curl $curl_options "$remote_path" || failed=true
734735
else
735-
curl --retry 10 -sSL -f --create-dirs -o "$out_path" "$remote_path" || failed=true
736+
curl $curl_options -o "$out_path" "$remote_path" || failed=true
736737
fi
737738
if [ "$failed" = true ]; then
738739
say_verbose "Curl download failed"
@@ -748,12 +749,12 @@ downloadwget() {
748749
749750
# Append feed_credential as late as possible before calling wget to avoid logging feed_credential
750751
remote_path="${remote_path}${feed_credential}"
751-
752+
local wget_options="--tries 20 --waitretry 2 --connect-timeout 15 "
752753
local failed=false
753754
if [ -z "$out_path" ]; then
754-
wget -q --tries 10 -O - "$remote_path" || failed=true
755+
wget -q $wget_options -O - "$remote_path" || failed=true
755756
else
756-
wget --tries 10 -O "$out_path" "$remote_path" || failed=true
757+
wget $wget_options -O "$out_path" "$remote_path" || failed=true
757758
fi
758759
if [ "$failed" = true ]; then
759760
say_verbose "Wget download failed"

0 commit comments

Comments
 (0)