mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-04-07 07:49:53 +00:00
follow proxy settings
This commit is contained in:
@ -2,7 +2,7 @@ import io = require('@actions/io');
|
||||
import fs = require('fs');
|
||||
import os = require('os');
|
||||
import path = require('path');
|
||||
import httpClient = require('typed-rest-client/HttpClient');
|
||||
import hc = require('@actions/http-client');
|
||||
|
||||
const toolDir = path.join(__dirname, 'runner', 'tools');
|
||||
const tempDir = path.join(__dirname, 'runner', 'temp');
|
||||
@ -74,14 +74,14 @@ describe('installer tests', () => {
|
||||
});
|
||||
|
||||
it('Uses an up to date bash download script', async () => {
|
||||
var httpCallbackClient = new httpClient.HttpClient(
|
||||
'setup-dotnet-test',
|
||||
[],
|
||||
{}
|
||||
);
|
||||
const response: httpClient.HttpClientResponse = await httpCallbackClient.get(
|
||||
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(
|
||||
@ -94,14 +94,14 @@ describe('installer tests', () => {
|
||||
}, 100000);
|
||||
|
||||
it('Uses an up to date powershell download script', async () => {
|
||||
var httpCallbackClient = new httpClient.HttpClient(
|
||||
'setup-dotnet-test',
|
||||
[],
|
||||
{}
|
||||
);
|
||||
const response: httpClient.HttpClientResponse = await httpCallbackClient.get(
|
||||
var 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(
|
||||
|
14
__tests__/sample-csproj/Program.cs
Normal file
14
__tests__/sample-csproj/Program.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace sample_csproj
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var json = JsonConvert.SerializeObject(new[] {"Hello", "World!" });
|
||||
Console.WriteLine(json);
|
||||
}
|
||||
}
|
||||
}
|
7
__tests__/sample-csproj/runtimeconfig.template.json
Normal file
7
__tests__/sample-csproj/runtimeconfig.template.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"configProperties": {
|
||||
"System.Globalization.Invariant": true
|
||||
}
|
||||
}
|
||||
}
|
13
__tests__/sample-csproj/sample.csproj
Normal file
13
__tests__/sample-csproj/sample.csproj
Normal file
@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<RootNamespace>sample_csproj</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
32
__tests__/verify-dotnet.ps1
Executable file
32
__tests__/verify-dotnet.ps1
Executable file
@ -0,0 +1,32 @@
|
||||
if (!$args[0])
|
||||
{
|
||||
throw "Must supply dotnet version argument"
|
||||
}
|
||||
|
||||
$dotnet = Get-Command dotnet | Select-Object -First 1 | ForEach-Object { $_.Path }
|
||||
Write-Host "Found '$dotnet'"
|
||||
|
||||
$version = & $dotnet --version | Out-String | ForEach-Object { $_.Trim() }
|
||||
Write-Host "Version $version"
|
||||
# if ($version -ne $args[0])
|
||||
# {
|
||||
# Write-Host "PATH='$env:path'"
|
||||
# Write-Host "gcm dotnet:"
|
||||
# gcm dotnet | fl
|
||||
# throw "Unexpected version"
|
||||
# }
|
||||
|
||||
Write-Host "Building sample csproj"
|
||||
& $dotnet build __tests__/sample-csproj/ --no-cache
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
throw "Unexpected exit code $LASTEXITCODE"
|
||||
}
|
||||
|
||||
Write-Host "Testing compiled app"
|
||||
$sample_output = "$(__tests__/sample-csproj/bin/Debug/netcoreapp3.0/sample.exe)".Trim()
|
||||
Write-Host "Sample output: $sample_output"
|
||||
if ($sample_output -notlike "*Hello*World*")
|
||||
{
|
||||
throw "Unexpected output"
|
||||
}
|
22
__tests__/verify-dotnet.sh
Executable file
22
__tests__/verify-dotnet.sh
Executable file
@ -0,0 +1,22 @@
|
||||
if [ -z "$1" ]; then
|
||||
echo "Must supply dotnet version argument"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dotnet_version="$(dotnet --version)"
|
||||
echo "Found dotnet version '$dotnet_version'"
|
||||
if [ -z "$(echo $dotnet_version | grep $1)" ]; then
|
||||
echo "Unexpected version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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)"
|
||||
echo "Sample output: $sample_output"
|
||||
if [ -z "$(echo $sample_output | grep Hello)" ]; then
|
||||
echo "Unexpected output"
|
||||
exit 1
|
||||
fi
|
17
__tests__/verify-no-unstaged-changes.sh
Executable file
17
__tests__/verify-no-unstaged-changes.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$(git status --porcelain)" != "" ]]; then
|
||||
echo ----------------------------------------
|
||||
echo git status
|
||||
echo ----------------------------------------
|
||||
git status
|
||||
echo ----------------------------------------
|
||||
echo git diff
|
||||
echo ----------------------------------------
|
||||
git diff
|
||||
echo ----------------------------------------
|
||||
echo Troubleshooting
|
||||
echo ----------------------------------------
|
||||
echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && npm ci && npm run pre-checkin"
|
||||
exit 1
|
||||
fi
|
Reference in New Issue
Block a user