From 966e2297fc341aafdf1aee887a124e3b20420af5 Mon Sep 17 00:00:00 2001 From: js6pak Date: Sun, 21 Jul 2024 00:41:11 +0200 Subject: [PATCH 1/3] Rename toolcache directory instead of moving to tmp This further enhances time savings seen in #213, down from a few minutes to seconds. --- __tests__/clear-toolcache.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/__tests__/clear-toolcache.ps1 b/__tests__/clear-toolcache.ps1 index 5589ec1..a8bd902 100644 --- a/__tests__/clear-toolcache.ps1 +++ b/__tests__/clear-toolcache.ps1 @@ -6,8 +6,8 @@ $dotnetPaths = @{ foreach ($srcPath in $dotnetPaths[$args[0]]) { if (Test-Path $srcPath) { - Write-Host "Move $srcPath path" - $dstPath = Join-Path ([IO.Path]::GetTempPath()) ([IO.Path]::GetRandomFileName()) + $dstPath = "$srcPath-" + [IO.Path]::GetRandomFileName() + Write-Host "Moving $srcPath to $dstPath" Move-Item -Path $srcPath -Destination $dstPath } } \ No newline at end of file From b35888cca79393592a61f59f5be58682d15eb524 Mon Sep 17 00:00:00 2001 From: js6pak Date: Sun, 21 Jul 2024 00:19:08 +0200 Subject: [PATCH 2/3] 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. --- .github/workflows/basic-validation.yml | 3 --- .github/workflows/check-dist.yml | 2 -- .github/workflows/codeql-analysis.yml | 2 -- .github/workflows/e2e-tests.yml | 3 --- .github/workflows/licensed.yml | 4 ---- .github/workflows/test-dotnet.yml | 3 --- 6 files changed, 17 deletions(-) diff --git a/.github/workflows/basic-validation.yml b/.github/workflows/basic-validation.yml index 4bcf16c..f77a240 100644 --- a/.github/workflows/basic-validation.yml +++ b/.github/workflows/basic-validation.yml @@ -5,9 +5,6 @@ on: paths-ignore: - '**.md' push: - branches: - - main - - releases/* paths-ignore: - '**.md' diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 30aa221..587d989 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -2,8 +2,6 @@ name: Check dist/ on: push: - branches: - - main paths-ignore: - '**.md' pull_request: diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 7a82612..c18410c 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,9 +2,7 @@ name: CodeQL analysis on: push: - branches: [main] pull_request: - branches: [main] schedule: - cron: '0 3 * * 0' diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 28c98d0..3165ba8 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -5,9 +5,6 @@ on: paths-ignore: - '**.md' push: - branches: - - main - - releases/* paths-ignore: - '**.md' diff --git a/.github/workflows/licensed.yml b/.github/workflows/licensed.yml index 37f1560..d6ac996 100644 --- a/.github/workflows/licensed.yml +++ b/.github/workflows/licensed.yml @@ -2,11 +2,7 @@ name: Licensed on: push: - branches: - - main pull_request: - branches: - - main workflow_dispatch: jobs: diff --git a/.github/workflows/test-dotnet.yml b/.github/workflows/test-dotnet.yml index 51e6d64..00d2334 100644 --- a/.github/workflows/test-dotnet.yml +++ b/.github/workflows/test-dotnet.yml @@ -5,9 +5,6 @@ on: paths-ignore: - '**.md' push: - branches: - - main - - releases/* paths-ignore: - '**.md' From 4456588b5efffeb2ff495375ad05553b81c39f57 Mon Sep 17 00:00:00 2001 From: Chris Philips Date: Wed, 15 Nov 2023 11:58:12 -0800 Subject: [PATCH 3/3] Support global.json's rollForward latest* variants Co-authored-by: js6pak --- .github/workflows/e2e-tests.yml | 100 ++++++++++++++++++++++++++++++++ dist/setup/index.js | 20 ++++++- src/setup-dotnet.ts | 24 +++++++- 3 files changed, 138 insertions(+), 6 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 3165ba8..0faaaac 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -373,6 +373,106 @@ jobs: shell: pwsh run: __tests__/verify-dotnet.ps1 -Patterns "^6.0", "^8.0" + test-setup-global-json-rollforward-latestmajor: + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-22.04, windows-latest, macos-13] + steps: + - name: Checkout + uses: actions/checkout@v3 + - 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-latestminor: + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-22.04, windows-latest, macos-13] + steps: + - name: Checkout + uses: actions/checkout@v3 + - 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.0.100","rollForward": "latestMinor"}}' > ./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.1" + + test-setup-global-json-rollforward-latestfeature: + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-22.04, windows-latest, macos-13] + steps: + - name: Checkout + uses: actions/checkout@v3 + - 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.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 "^3.1.4" + + test-setup-global-json-rollforward-latestpatch: + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-22.04, windows-latest, macos-13] + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Clear toolcache + shell: pwsh + run: __tests__/clear-toolcache.ps1 ${{ runner.os }} + - name: Write global.json + shell: bash + run: | + mkdir subdirectory + echo '{"sdk":{"version": "5.0.400","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 "^5.0.408$" + test-setup-global-json-only: runs-on: ${{ matrix.operating-system }} strategy: diff --git a/dist/setup/index.js b/dist/setup/index.js index 5a9ec03..2c41219 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -99758,9 +99758,23 @@ function getVersionFromGlobalJson(globalJsonPath) { if (globalJson.sdk && globalJson.sdk.version) { version = globalJson.sdk.version; const rollForward = globalJson.sdk.rollForward; - if (rollForward && rollForward === 'latestFeature') { - const [major, minor] = version.split('.'); - version = `${major}.${minor}`; + if (rollForward) { + const [major, minor, featurePatch] = version.split('.'); + 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; diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index 2a628a5..6043456 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -110,9 +110,27 @@ function getVersionFromGlobalJson(globalJsonPath: string): string { if (globalJson.sdk && globalJson.sdk.version) { version = globalJson.sdk.version; const rollForward = globalJson.sdk.rollForward; - if (rollForward && rollForward === 'latestFeature') { - const [major, minor] = version.split('.'); - version = `${major}.${minor}`; + if (rollForward) { + const [major, minor, featurePatch] = version.split('.'); + 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;