mirror of
https://github.com/actions/setup-dotnet.git
synced 2026-05-27 09:18:18 +01:00
Support global.json's rollForward latest* variants (#538)
* Rename toolcache directory instead of moving to tmp
This further enhances time savings seen in #213, down from a few minutes to seconds.
* Remove branch constraint on workflows used for testing
This means you are going to be notified of CI issues quicker, especially if you have to wait for a confirmation before running the workflows on your PR.
* Support global.json's rollForward latest* variants
* Remove e2e-test's dependency on Microsoft.NET.Test.Sdk
The newer versions are net8.0/net462+ only, making older .NET sdks more annoying to test
* Revert "Remove e2e-test's dependency on Microsoft.NET.Test.Sdk"
This reverts commit 14839a662649cdea79ccecc3a7ce9a91386185b4.
* Don't run unsupported versions in global.json tests
* Revert "Remove branch constraint on workflows used for testing"
This reverts commit d9dae35030.
This commit is contained in:
75
.github/workflows/e2e-tests.yml
vendored
75
.github/workflows/e2e-tests.yml
vendored
@@ -257,6 +257,81 @@ jobs:
|
|||||||
shell: pwsh
|
shell: pwsh
|
||||||
run: __tests__/verify-dotnet.ps1 -Patterns "^9.0", "^10.0"
|
run: __tests__/verify-dotnet.ps1 -Patterns "^9.0", "^10.0"
|
||||||
|
|
||||||
|
test-setup-global-json-rollforward-latestmajor:
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
- name: Clear toolcache
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
- name: Write global.json
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir subdirectory
|
||||||
|
echo '{"sdk":{"version": "3.1.0","rollForward": "latestMajor"}}' > ./subdirectory/global.json
|
||||||
|
- name: Setup dotnet
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
global-json-file: ./subdirectory/global.json
|
||||||
|
- name: Verify dotnet
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/verify-dotnet.ps1 -Patterns "^(?!3)"
|
||||||
|
|
||||||
|
test-setup-global-json-rollforward-latestfeature:
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
- name: Clear toolcache
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
- name: Write global.json
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir subdirectory
|
||||||
|
echo '{"sdk":{"version": "10.0.100","rollForward": "latestFeature"}}' > ./subdirectory/global.json
|
||||||
|
- name: Setup dotnet
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
global-json-file: ./subdirectory/global.json
|
||||||
|
- name: Verify dotnet
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/verify-dotnet.ps1 -Patterns "^10.0.(?!1)"
|
||||||
|
|
||||||
|
test-setup-global-json-rollforward-latestpatch:
|
||||||
|
runs-on: ${{ matrix.operating-system }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
operating-system: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v6
|
||||||
|
- name: Clear toolcache
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/clear-toolcache.ps1 ${{ runner.os }}
|
||||||
|
- name: Write global.json
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
mkdir subdirectory
|
||||||
|
echo '{"sdk":{"version": "10.0.100","rollForward": "latestPatch"}}' > ./subdirectory/global.json
|
||||||
|
- name: Setup dotnet
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
global-json-file: ./subdirectory/global.json
|
||||||
|
- name: Verify dotnet
|
||||||
|
shell: pwsh
|
||||||
|
run: __tests__/verify-dotnet.ps1 -Patterns "^10.0.1(?!00)"
|
||||||
|
|
||||||
test-setup-global-json-only:
|
test-setup-global-json-only:
|
||||||
runs-on: ${{ matrix.operating-system }}
|
runs-on: ${{ matrix.operating-system }}
|
||||||
strategy:
|
strategy:
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ $dotnetPaths = @{
|
|||||||
|
|
||||||
foreach ($srcPath in $dotnetPaths[$args[0]]) {
|
foreach ($srcPath in $dotnetPaths[$args[0]]) {
|
||||||
if (Test-Path $srcPath) {
|
if (Test-Path $srcPath) {
|
||||||
Write-Host "Move $srcPath path"
|
$dstPath = "$srcPath-" + [IO.Path]::GetRandomFileName()
|
||||||
$dstPath = Join-Path ([IO.Path]::GetTempPath()) ([IO.Path]::GetRandomFileName())
|
Write-Host "Moving $srcPath to $dstPath"
|
||||||
Move-Item -Path $srcPath -Destination $dstPath
|
Move-Item -Path $srcPath -Destination $dstPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
20
dist/setup/index.js
vendored
20
dist/setup/index.js
vendored
@@ -79244,9 +79244,23 @@ function getVersionFromGlobalJson(globalJsonPath) {
|
|||||||
if (globalJson.sdk && globalJson.sdk.version) {
|
if (globalJson.sdk && globalJson.sdk.version) {
|
||||||
version = globalJson.sdk.version;
|
version = globalJson.sdk.version;
|
||||||
const rollForward = globalJson.sdk.rollForward;
|
const rollForward = globalJson.sdk.rollForward;
|
||||||
if (rollForward && rollForward === 'latestFeature') {
|
if (rollForward) {
|
||||||
const [major, minor] = version.split('.');
|
const [major, minor, featurePatch] = version.split('.');
|
||||||
version = `${major}.${minor}`;
|
const feature = featurePatch.substring(0, 1);
|
||||||
|
switch (rollForward) {
|
||||||
|
case 'latestMajor':
|
||||||
|
version = '';
|
||||||
|
break;
|
||||||
|
case 'latestMinor':
|
||||||
|
version = `${major}`;
|
||||||
|
break;
|
||||||
|
case 'latestFeature':
|
||||||
|
version = `${major}.${minor}`;
|
||||||
|
break;
|
||||||
|
case 'latestPatch':
|
||||||
|
version = `${major}.${minor}.${feature}xx`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
|
|||||||
@@ -207,9 +207,27 @@ function getVersionFromGlobalJson(globalJsonPath: string): string {
|
|||||||
if (globalJson.sdk && globalJson.sdk.version) {
|
if (globalJson.sdk && globalJson.sdk.version) {
|
||||||
version = globalJson.sdk.version;
|
version = globalJson.sdk.version;
|
||||||
const rollForward = globalJson.sdk.rollForward;
|
const rollForward = globalJson.sdk.rollForward;
|
||||||
if (rollForward && rollForward === 'latestFeature') {
|
if (rollForward) {
|
||||||
const [major, minor] = version.split('.');
|
const [major, minor, featurePatch] = version.split('.');
|
||||||
version = `${major}.${minor}`;
|
const feature = featurePatch.substring(0, 1);
|
||||||
|
|
||||||
|
switch (rollForward) {
|
||||||
|
case 'latestMajor':
|
||||||
|
version = '';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'latestMinor':
|
||||||
|
version = `${major}`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'latestFeature':
|
||||||
|
version = `${major}.${minor}`;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'latestPatch':
|
||||||
|
version = `${major}.${minor}.${feature}xx`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return version;
|
return version;
|
||||||
|
|||||||
Reference in New Issue
Block a user