Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use install-dotnet scripts for installation #71

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
c367698
Remove version parameter
Nov 5, 2019
6f11b36
Update node_modules
Nov 5, 2019
cdb6e42
Ignore vscode files
Nov 5, 2019
6647a1d
Update scripts from dot.net/v1/dotnet-install.*
Nov 5, 2019
21cbb73
Use install-dotnet scripts for install
Nov 5, 2019
07ddfd3
fallback to global json if no version
Nov 5, 2019
5668f13
Format ts
Nov 5, 2019
173f136
Add new test
Nov 5, 2019
5cfedd0
Merge remote-tracking branch 'origin/master' into sxs-with-fallback
Nov 8, 2019
4543e75
Restore gitignore settings
Dec 17, 2019
ae6aad3
Merge remote-tracking branch 'origin/master' into sxs-with-fallback
Dec 17, 2019
485def9
Remove warning from master branch
Dec 17, 2019
0b0e81a
Updated to get testing working
Dec 18, 2019
60e54bf
Husky commit correct node modules
Dec 18, 2019
8a5bbb0
Uncomment slow test
Dec 18, 2019
6259d1a
Use mac in strategy, no failfast
Dec 18, 2019
5c8120b
Remove unused external scripts
Dec 18, 2019
9d492ae
Fix array problems in installer
Dec 18, 2019
b689c99
Fix compile errors
Dec 19, 2019
e201cec
Remove unnecessary test
Dec 19, 2019
1bca1dc
Test run proper check for accurate installation
Dec 19, 2019
f356c2f
Merge remote-tracking branch 'origin/master' into sxs-with-fallback
Jan 9, 2020
2f37098
Node task uses node-version
Apr 13, 2020
b41bbeb
update install-dotnet
Apr 14, 2020
2056771
Merge branch 'master' into sxs-with-fallback
Apr 14, 2020
0a20e20
Latest package updates
Apr 14, 2020
6192e4a
Use latest dotnet version
Apr 14, 2020
0fe4f94
Clean out tool cache
Apr 14, 2020
a9ccaa8
Update package
Apr 14, 2020
9cdfbc3
Rebuilding index
Apr 14, 2020
a7ad374
workflow fixes
Apr 17, 2020
277403d
Merge remote-tracking branch 'origin/main' into sxs-with-fallback
Jul 16, 2020
fe82455
Start cleaning up broken tests
Jul 16, 2020
f87d15e
Add proxy settings to the windows script
Jul 16, 2020
082a886
Check install in tool directory with folder name
Jul 17, 2020
b928c2d
Avoid api calls for exact versions
Jul 17, 2020
a831d11
rename function calls
Jul 17, 2020
f9ad088
Merge remote-tracking branch 'origin/main' into sxs-with-fallback
Aug 10, 2020
f681fcf
Update ps1 script
Aug 10, 2020
08f6efe
Alternate install location for testing
Aug 10, 2020
e86a5fd
Set install location for test
Aug 10, 2020
9d9ff9f
Proper variable usage
Aug 10, 2020
4e86def
Use the correct dotnet folder to clean out
Aug 10, 2020
b7f3cf0
Diagnostic information
Aug 10, 2020
9ce8cb7
Uninstall location
Aug 10, 2020
ab32ad2
run action on push
Aug 10, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 38 additions & 19 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ on:
branches:
- main
- releases/*
- sxs-with-fallback

jobs:
build:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
steps:
Expand All @@ -19,7 +21,7 @@ jobs:
- name: Set Node.js 12
uses: actions/setup-node@v1
with:
version: 12.x
node-version: 12.x
- run: npm ci
- run: npm run build
- run: npm run format-check
Expand All @@ -31,29 +33,46 @@ jobs:
test:
runs-on: ${{ matrix.operating-system }}
strategy:
fail-fast: false
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Clear tool cache
run: mv "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old"
- name: Setup dotnet 3.0.100
- name: Clear tool cache (macOS)
if: runner.os == 'macos'
run: |
echo $PATH
dotnet --info
rm -rf "/Users/runner/.dotnet"
- name: Clear tool cache (Ubuntu)
if: runner.os == 'linux'
run: |
echo $PATH
dotnet --info
rm -rf "/usr/share/dotnet"
- name: Clear tool cache (Windows)
if: runner.os == 'windows'
run: |
echo $env:PATH
dotnet --info
Remove-Item $env:LocalAppData\Microsoft\dotnet/* -Recurse -Force -ErrorAction SilentlyContinue
- name: Setup dotnet 3.1.201
uses: ./
with:
dotnet-version: 3.0.100
dotnet-version: 3.1.201
- name: Verify dotnet
if: runner.os != 'windows'
run: __tests__/verify-dotnet.sh 3.0.100
run: __tests__/verify-dotnet.sh 3.1.201
- name: Verify dotnet (Windows)
if: runner.os == 'windows'
run: __tests__/verify-dotnet.ps1 3.0.100
run: __tests__/verify-dotnet.ps1 3.1.201

test-proxy:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/dotnet/core/runtime-deps:3.0-bionic
options: --dns 127.0.0.1
# container:
# image: mcr.microsoft.com/dotnet/core/runtime-deps:3.0-bionic
# options: --dns 127.0.0.1
services:
squid-proxy:
image: datadog/squid:latest
Expand All @@ -65,27 +84,27 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Clear tool cache
run: rm -rf $RUNNER_TOOL_CACHE/*
- name: Setup dotnet 3.0.100
run: rm -rf "/usr/share/dotnet"
- name: Setup dotnet 3.1.201
uses: ./
with:
dotnet-version: 3.0.100
dotnet-version: 3.1.201
- name: Verify dotnet
run: __tests__/verify-dotnet.sh 3.0.100
run: __tests__/verify-dotnet.sh 3.1.201

test-bypass-proxy:
runs-on: ubuntu-latest
env:
https_proxy: http://no-such-proxy:3128
no_proxy: github.com,dotnetcli.blob.core.windows.net,download.visualstudio.microsoft.com,api.nuget.org
no_proxy: github.com,dotnetcli.blob.core.windows.net,download.visualstudio.microsoft.com,api.nuget.org,dotnetcli.azureedge.net
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Clear tool cache
run: mv "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old"
- name: Setup dotnet 3.0.100
run: rm -rf "/usr/share/dotnet"
- name: Setup dotnet 3.1.201
uses: ./
with:
dotnet-version: 3.0.100
dotnet-version: 3.1.201
- name: Verify dotnet
run: __tests__/verify-dotnet.sh 3.0.100
run: __tests__/verify-dotnet.sh 3.1.201
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,5 @@ typings/
# DynamoDB Local files
.dynamodb/

.vscode/*
# Ignore .vscode files
.vscode/
6 changes: 5 additions & 1 deletion __tests__/authutil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ describe('authutil tests', () => {
beforeEach(async () => {
await io.rmRF(fakeSourcesDirForTesting);
await io.mkdirP(fakeSourcesDirForTesting);
}, 100000);
}, 30000);

afterAll(async () => {
await io.rmRF(fakeSourcesDirForTesting);
}, 30000);

beforeEach(() => {
if (fs.existsSync(nugetConfigFile)) {
Expand Down
76 changes: 24 additions & 52 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ describe('version tests', () => {

describe('installer tests', () => {
beforeAll(async () => {
process.env.RUNNER_TOOL_CACHE = toolDir;
process.env.DOTNET_INSTALL_DIR = toolDir;
process.env.RUNNER_TEMP = tempDir;
await io.rmRF(toolDir);
await io.rmRF(tempDir);
});
Expand All @@ -84,23 +87,21 @@ describe('installer tests', () => {
} catch {
console.log('Failed to remove test directories');
}
}, 100000);
}, 30000);

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

expect(versInfo.resolvedVersion.startsWith('3.1.'));
expect(versInfo.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'],
await dotnetInstaller.resolveVersion(
new installer.DotNetVersionInfo('999.1.x')
);
fail();
Expand All @@ -111,53 +112,47 @@ describe('installer tests', () => {

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

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

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

expect(versInfo.resolvedVersion).toBe('5.0.0-preview.4');
expect(versInfo).toBe('5.0.0-preview.6');
}, 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());

expect(fs.existsSync(`${dotnetDir}.complete`)).toBe(true);
await getDotnet('3.1.201');
expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).toBe(true);
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(dotnetDir, 'dotnet.exe'))).toBe(true);
expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
} else {
expect(fs.existsSync(path.join(dotnetDir, 'dotnet'))).toBe(true);
expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
}
}, 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());

it('Acquires version of dotnet from global.json if no matching version is installed', async () => {
const globalJsonPath = path.join(process.cwd(), 'global.json');
const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version": "2.2.105"${os.EOL}}${os.EOL}}`;
if (!fs.existsSync(globalJsonPath)) {
fs.writeFileSync(globalJsonPath, jsonContents);
}
await setup.run();

expect(fs.existsSync(`${dotnetDir}.complete`)).toBe(true);
expect(fs.existsSync(path.join(toolDir, 'sdk', '2.2.105'))).toBe(true);
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(dotnetDir, 'dotnet.exe'))).toBe(true);
expect(fs.existsSync(path.join(toolDir, 'dotnet.exe'))).toBe(true);
} else {
expect(fs.existsSync(path.join(dotnetDir, 'dotnet'))).toBe(true);
expect(fs.existsSync(path.join(toolDir, 'dotnet'))).toBe(true);
}
fs.unlinkSync(globalJsonPath);
}, 100000);
Expand All @@ -170,30 +165,7 @@ describe('installer tests', () => {
thrown = true;
}
expect(thrown).toBe(true);
}, 100000);

it('Uses version of dotnet installed in cache', async () => {
const dotnetDir: string = path.join(toolDir, 'dncs', '250.0.0', os.arch());
await io.mkdirP(dotnetDir);
fs.writeFileSync(`${dotnetDir}.complete`, 'hello');
// This will throw if it doesn't find it in the cache (because no such version exists)
await getDotnet('250.0.0');
return;
});

it('Doesnt use version of dotnet that was only partially installed in cache', async () => {
const dotnetDir: string = path.join(toolDir, 'dncs', '251.0.0', os.arch());
await io.mkdirP(dotnetDir);
let thrown = false;
try {
// This will throw if it doesn't find it in the cache (because no such version exists)
await getDotnet('251.0.0');
} catch {
thrown = true;
}
expect(thrown).toBe(true);
return;
});
}, 30000);

it('Uses an up to date bash download script', async () => {
const httpCallbackClient = new hc.HttpClient('setup-dotnet-test', [], {
Expand All @@ -213,7 +185,7 @@ describe('installer tests', () => {
expect(normalizeFileContents(currentContents)).toBe(
normalizeFileContents(upToDateContents)
);
}, 100000);
}, 30000);

it('Uses an up to date powershell download script', async () => {
var httpCallbackClient = new hc.HttpClient('setup-dotnet-test', [], {
Expand All @@ -233,7 +205,7 @@ describe('installer tests', () => {
expect(normalizeFileContents(currentContents)).toBe(
normalizeFileContents(upToDateContents)
);
}, 100000);
}, 30000);
});

function normalizeFileContents(contents: string): string {
Expand Down
48 changes: 48 additions & 0 deletions __tests__/setup-dotnet.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import io = require('@actions/io');
import fs = require('fs');
import os = require('os');
import path = require('path');

const toolDir = path.join(__dirname, 'runner', 'tools2');
const tempDir = path.join(__dirname, 'runner', 'temp2');

import * as setup from '../src/setup-dotnet';

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

describe('setup-dotnet tests', () => {
beforeAll(async () => {
process.env.RUNNER_TOOL_CACHE = toolDir;
process.env.DOTNET_INSTALL_DIR = toolDir;
process.env.RUNNER_TEMP = tempDir;
await io.rmRF(toolDir);
await io.rmRF(tempDir);
});

afterAll(async () => {
try {
await io.rmRF(path.join(process.cwd(), 'global.json'));
await io.rmRF(toolDir);
await io.rmRF(tempDir);
} catch {
console.log('Failed to remove test directories');
}
}, 30000);

it('Acquires version of dotnet if no matching version is installed', async () => {
const globalJsonPath = path.join(process.cwd(), 'global.json');
const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version": "3.1.201"${os.EOL}}${os.EOL}}`;
if (!fs.existsSync(globalJsonPath)) {
fs.writeFileSync(globalJsonPath, jsonContents);
}
await setup.run();

expect(fs.existsSync(path.join(toolDir, 'sdk', '3.1.201'))).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);
}
fs.unlinkSync(globalJsonPath);
}, 100000);
});
2 changes: 1 addition & 1 deletion __tests__/verify-dotnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ echo "Building sample csproj"
dotnet build __tests__/sample-csproj/ --no-cache || exit 1

echo "Testing compiled app"
sample_output="$(__tests__/sample-csproj/bin/Debug/netcoreapp3.0/sample)"
sample_output="$(__tests__/sample-csproj/bin/Debug/netcoreapp3.0/sample.dll)"
echo "Sample output: $sample_output"
if [ -z "$(echo $sample_output | grep Hello)" ]; then
echo "Unexpected output"
Expand Down
Loading