Skip to content

Commit

Permalink
follow proxy settings
Browse files Browse the repository at this point in the history
  • Loading branch information
eric sciple committed Feb 6, 2020
1 parent b782114 commit cf5f899
Show file tree
Hide file tree
Showing 627 changed files with 22,615 additions and 104,481 deletions.
93 changes: 79 additions & 14 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,91 @@
name: Main workflow
on: [push, pull_request]

on:
pull_request:
push:
branches:
- master
- releases/*

jobs:
run:
name: Run
build:
runs-on: ${{ matrix.operating-system }}
strategy:
matrix:
operating-system: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Checkout
uses: actions/checkout@master

- name: Set Node.js 10.x
uses: actions/setup-node@master
uses: actions/checkout@v2
- name: Set Node.js 12
uses: actions/setup-node@v1
with:
version: 10.x
version: 12.x
- run: npm ci
- run: npm run build
- run: npm run format-check
- run: npm test
- name: Verify no unstaged changes
if: runner.os != 'windows'
run: __tests__/verify-no-unstaged-changes.sh

- name: npm install
run: npm install
test:
runs-on: ${{ matrix.operating-system }}
strategy:
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
uses: ./
with:
dotnet-version: 3.0.100
- name: Verify dotnet
if: runner.os != 'windows'
run: __tests__/verify-dotnet.sh 3.0.100
- name: Verify dotnet (Windows)
if: runner.os == 'windows'
run: __tests__/verify-dotnet.ps1 3.0.100

- name: Lint
run: npm run format-check
test-proxy:
runs-on: ubuntu-latest
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
ports:
- 3128:3128
env:
https_proxy: http://squid-proxy:3128
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Clear tool cache
run: rm -rf $RUNNER_TOOL_CACHE/*
- name: Setup dotnet 3.0.100
uses: ./
with:
dotnet-version: 3.0.100
- name: Verify dotnet
run: __tests__/verify-dotnet.sh 3.0.100

- name: npm test
run: npm test
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
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
uses: ./
with:
dotnet-version: 3.0.100
- name: Verify dotnet
run: __tests__/verify-dotnet.sh 3.0.100
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Explicitly not ignoring node_modules so that they are included in package downloaded by runner
!node_modules/
lib/
node_modules/
__tests__/runner/*
__tests__/sample-csproj/bin/
__tests__/sample-csproj/obj/

# Rest of the file pulled from https://github.com/github/gitignore/blob/master/Node.gitignore
# Logs
Expand Down
26 changes: 13 additions & 13 deletions __tests__/installer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down
14 changes: 14 additions & 0 deletions __tests__/sample-csproj/Program.cs
Original file line number Diff line number Diff line change
@@ -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 changes: 7 additions & 0 deletions __tests__/sample-csproj/runtimeconfig.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"runtimeOptions": {
"configProperties": {
"System.Globalization.Invariant": true
}
}
}
13 changes: 13 additions & 0 deletions __tests__/sample-csproj/sample.csproj
Original file line number Diff line number Diff line change
@@ -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 changes: 32 additions & 0 deletions __tests__/verify-dotnet.ps1
Original file line number Diff line number Diff line change
@@ -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 changes: 22 additions & 0 deletions __tests__/verify-dotnet.sh
Original file line number Diff line number Diff line change
@@ -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 changes: 17 additions & 0 deletions __tests__/verify-no-unstaged-changes.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ inputs:
deprecationMessage: 'The version property will not be supported after October 1, 2019. Use dotnet-version instead'
runs:
using: 'node12'
main: 'lib/setup-dotnet.js'
main: 'dist/index.js'
Loading

0 comments on commit cf5f899

Please sign in to comment.