diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 90f7350..419dd14 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -75,7 +75,82 @@ jobs: 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 + run: __tests__/verify-dotnet.ps1 3.1.201 2.2.402 + + # Clear cache before 2 digit install + - name: Clear tool cache (macOS) + if: runner.os == 'macos' + run: | + rm -rf "/Users/runner/.dotnet" + - name: Clear tool cache (Ubuntu) + if: runner.os == 'linux' + run: | + rm -rf "/usr/share/dotnet" + - name: Clear tool cache (Windows) + if: runner.os == 'windows' + run: | + Remove-Item $env:LocalAppData\Microsoft\dotnet/* -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item "$env:ProgramFiles\dotnet/*" -Recurse -Force -ErrorAction SilentlyContinue + - name: Setup dotnet 2.0 + uses: ./ + with: + dotnet-version: 2.0 + - name: Verify dotnet + if: runner.os != 'windows' + run: __tests__/verify-dotnet-version.sh 2.0.9 + - name: Verify dotnet (Windows) + if: runner.os == 'windows' + run: __tests__/verify-dotnet-version.ps1 2.0.9 + + # Clear cache before .x version install + - name: Clear tool cache (macOS) + if: runner.os == 'macos' + run: | + rm -rf "/Users/runner/.dotnet" + - name: Clear tool cache (Ubuntu) + if: runner.os == 'linux' + run: | + rm -rf "/usr/share/dotnet" + - name: Clear tool cache (Windows) + if: runner.os == 'windows' + run: | + Remove-Item $env:LocalAppData\Microsoft\dotnet/* -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item "$env:ProgramFiles\dotnet/*" -Recurse -Force -ErrorAction SilentlyContinue + - name: Setup dotnet 2.0.x + uses: ./ + with: + dotnet-version: 2.0.x + - name: Verify dotnet + if: runner.os != 'windows' + run: __tests__/verify-dotnet-version.sh 2.0.9 + - name: Verify dotnet (Windows) + if: runner.os == 'windows' + run: __tests__/verify-dotnet-version.ps1 2.0.9 + + # Clear cache before .* version install + - name: Clear tool cache (macOS) + if: runner.os == 'macos' + run: | + rm -rf "/Users/runner/.dotnet" + - name: Clear tool cache (Ubuntu) + if: runner.os == 'linux' + run: | + rm -rf "/usr/share/dotnet" + - name: Clear tool cache (Windows) + if: runner.os == 'windows' + run: | + Remove-Item $env:LocalAppData\Microsoft\dotnet/* -Recurse -Force -ErrorAction SilentlyContinue + Remove-Item "$env:ProgramFiles\dotnet/*" -Recurse -Force -ErrorAction SilentlyContinue + - name: Setup dotnet 2.0.* + uses: ./ + with: + dotnet-version: 2.0.* + - name: Verify dotnet + if: runner.os != 'windows' + run: __tests__/verify-dotnet-version.sh 2.0.9 + - name: Verify dotnet (Windows) + if: runner.os == 'windows' + run: __tests__/verify-dotnet-version.ps1 2.0.9 test-proxy: runs-on: ubuntu-latest diff --git a/__tests__/verify-dotnet-version.ps1 b/__tests__/verify-dotnet-version.ps1 new file mode 100644 index 0000000..aa83d78 --- /dev/null +++ b/__tests__/verify-dotnet-version.ps1 @@ -0,0 +1,27 @@ +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'" + throw "Unexpected version" +} + +if ($args[1]) +{ + # SDKs are listed on multiple lines with the path afterwards in square brackets + $version = & $dotnet --list-sdks | ForEach-Object { $_.SubString(0, $_.IndexOf('[')).Trim() } + Write-Host "Version $version" + if (-not ($version -contains $args[1])) + { + Write-Host "PATH='$env:path'" + throw "Unexpected version" + } +} \ No newline at end of file diff --git a/__tests__/verify-dotnet-version.sh b/__tests__/verify-dotnet-version.sh new file mode 100644 index 0000000..6c7ccea --- /dev/null +++ b/__tests__/verify-dotnet-version.sh @@ -0,0 +1,20 @@ +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 + +if [ -n "$2" ]; then + dotnet_version="$(dotnet --list-sdks)" + echo "Found dotnet version '$dotnet_version'" + if [ -z "$(echo $dotnet_version | grep $2)" ]; then + echo "Unexpected version" + exit 1 + fi +fi \ No newline at end of file