From b4737b42ef4939bca196a752410e007bbcda3ee6 Mon Sep 17 00:00:00 2001 From: js6pak Date: Sun, 21 Jul 2024 00:41:11 +0200 Subject: [PATCH 1/4] 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 5589ec1dd..a8bd902d1 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 18b9c2a2769b108ffd036965ce138bf6993fc91b Mon Sep 17 00:00:00 2001 From: js6pak Date: Sun, 21 Jul 2024 00:18:57 +0200 Subject: [PATCH 2/4] Update installers --- externals/install-dotnet.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/externals/install-dotnet.sh b/externals/install-dotnet.sh index 42c201af4..caa3ea450 100755 --- a/externals/install-dotnet.sh +++ b/externals/install-dotnet.sh @@ -327,6 +327,10 @@ get_machine_architecture() { echo "loongarch64" return 0 ;; + riscv64) + echo "riscv64" + return 0 + ;; esac fi From 3f75cd0094569fa290b49ab70ef4cf769c406aef Mon Sep 17 00:00:00 2001 From: js6pak Date: Sun, 21 Jul 2024 00:19:08 +0200 Subject: [PATCH 3/4] 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 4bcf16ca5..f77a24015 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 30aa2210d..587d9896f 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 7a8261238..c18410c0c 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 43b538719..9b26d7be6 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 37f1560c3..d6ac99605 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 32f91acd4..0c9b742d0 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 8a21b4ed1527c384b6d4b7919db11dcb8389065c Mon Sep 17 00:00:00 2001 From: Chris Philips Date: Wed, 15 Nov 2023 11:58:12 -0800 Subject: [PATCH 4/4] 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 9b26d7be6..d9c51f8ed 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -201,6 +201,106 @@ jobs: shell: pwsh run: __tests__/verify-dotnet.ps1 -Patterns "^2.2", "^3.1" + test-setup-global-json-rollforward-latestmajor: + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest, 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-latest, 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-latest, 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-latest, 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 405862d3b..6d3a0e44e 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -94096,9 +94096,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 2a628a5ab..60434566e 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;