setup-dotnet/.github/workflows/workflow.yml

186 lines
5.8 KiB
YAML

name: Main workflow
on:
pull_request:
push:
branches:
- main
- releases/*
jobs:
build:
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: Set Node.js 12
uses: actions/setup-node@v1
with:
node-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
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 (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
Remove-Item "$env:ProgramFiles\dotnet/*" -Recurse -Force -ErrorAction SilentlyContinue
# Side-by-side install of 2.2 and 3.1 used for the test project
- name: Setup dotnet 2.2.402
uses: ./
with:
dotnet-version: 2.2.402
- name: Setup dotnet 3.1.201
uses: ./
with:
dotnet-version: 3.1.201
# We are including this veriable to force the generation of the nuget config file to verify that it is created in the correct place
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: NOTATOKEN
- name: Verify dotnet
if: runner.os != 'windows'
run: __tests__/verify-dotnet.sh 3.1.201 2.2.402
- name: Verify dotnet (Windows)
if: runner.os == 'windows'
run: __tests__/verify-dotnet.ps1 3.1.201 2.2.402
# Set new cache before 2 digit install
- name: Set new tool cache (macOS)
if: runner.os == 'macos'
run: |
echo "::set-env name=DOTNET_INSTALL_DIR::/Users/runner/.dotnet2"
- name: Set new tool cache (Ubuntu)
if: runner.os == 'linux'
run: |
echo "::set-env name=DOTNET_INSTALL_DIR::/home/runner/.dotnet2"
- name: Set new tool cache (Windows)
if: runner.os == 'windows'
run: |
echo "::set-env name=DOTNET_INSTALL_DIR::$env:LocalAppData\Microsoft\dotnet2"
# 2.0, 3.0, 5.0 needs to be in single quotes to interpret as a string instead of as an integer
- name: Setup dotnet '2.0'
uses: ./
with:
dotnet-version: '2.0'
# Clear cache before .x version install
- name: Set new tool cache (macOS)
if: runner.os == 'macos'
run: |
echo "::set-env name=DOTNET_INSTALL_DIR::/Users/runner/.dotnet3"
- name: Set new tool cache (Ubuntu)
if: runner.os == 'linux'
run: |
echo "::set-env name=DOTNET_INSTALL_DIR::/home/runner/.dotnet3"
- name: Set new tool cache (Windows)
if: runner.os == 'windows'
run: |
echo "::set-env name=DOTNET_INSTALL_DIR::$env:LocalAppData\Microsoft\dotnet3"
- name: Setup dotnet 2.0.x
uses: ./
with:
dotnet-version: 2.0.x
# Clear cache before .* version install
- name: Set new tool cache (macOS)
if: runner.os == 'macos'
run: |
echo "::set-env name=DOTNET_INSTALL_DIR::/Users/runner/.dotnet4"
- name: Set new tool cache (Ubuntu)
if: runner.os == 'linux'
run: |
echo "::set-env name=DOTNET_INSTALL_DIR::/home/runner/.dotnet4"
- name: Set new tool cache (Windows)
if: runner.os == 'windows'
run: |
echo "::set-env name=DOTNET_INSTALL_DIR::$env:LocalAppData\Microsoft\dotnet4"
- name: Setup dotnet 2.0.*
uses: ./
with:
dotnet-version: 2.0.*
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
http_proxy: http://squid-proxy:3128
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Clear tool cache
run: rm -rf "/usr/share/dotnet"
- name: Install curl
run: |
apt update
apt -y install curl
- name: Setup dotnet 3.1.201
uses: ./
with:
dotnet-version: 3.1.201
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: NOTATOKEN
- name: Verify dotnet
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,dotnetcli.azureedge.net
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Clear tool cache
run: rm -rf "/usr/share/dotnet"
- name: Setup dotnet 3.1.201
uses: ./
with:
dotnet-version: 3.1.201
source-url: https://api.nuget.org/v3/index.json
env:
NUGET_AUTH_TOKEN: NOTATOKEN
- name: Verify dotnet
run: __tests__/verify-dotnet.sh 3.1.201