From 559e47b01b20368e2cfc1fc8975b5ffe267f5c89 Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Thu, 13 Apr 2023 10:33:52 +0200 Subject: [PATCH] Fix review points --- .github/workflows/e2e-tests.yml | 24 ------------------------ dist/index.js | 16 +++++++++++++--- src/installer.ts | 18 +++++++++++++++--- 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/.github/workflows/e2e-tests.yml b/.github/workflows/e2e-tests.yml index 551ad8c..1be4173 100644 --- a/.github/workflows/e2e-tests.yml +++ b/.github/workflows/e2e-tests.yml @@ -165,30 +165,6 @@ jobs: shell: pwsh run: __tests__/verify-dotnet.ps1 3.1 2.2 - test-setup-with-ABCxx-syntax: - runs-on: ${{ matrix.operating-system }} - strategy: - fail-fast: false - matrix: - operating-system: [ubuntu-latest, windows-latest, macOS-latest] - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Clear toolcache - shell: pwsh - run: __tests__/clear-toolcache.ps1 ${{ runner.os }} - - name: Setup dotnet '5.0.2xx' - uses: ./ - with: - dotnet-version: '5.0.2xx' - - name: Setup dotnet '7.0.1xx' - uses: ./ - with: - dotnet-version: '7.0.1xx' - - name: Verify dotnet - shell: pwsh - run: __tests__/verify-dotnet.ps1 5.0.2 7.0.1 - test-setup-global-json-specified-and-version: runs-on: ${{ matrix.operating-system }} strategy: diff --git a/dist/index.js b/dist/index.js index a9e8a7e..40338d4 100644 --- a/dist/index.js +++ b/dist/index.js @@ -243,6 +243,11 @@ const path_1 = __importDefault(__nccwpck_require__(1017)); const os_1 = __importDefault(__nccwpck_require__(2037)); const semver_1 = __importDefault(__nccwpck_require__(5911)); const utils_1 = __nccwpck_require__(918); +var DotnetInstallerLimits; +(function (DotnetInstallerLimits) { + DotnetInstallerLimits[DotnetInstallerLimits["QualityInputMinimalMajorTag"] = 6] = "QualityInputMinimalMajorTag"; + DotnetInstallerLimits[DotnetInstallerLimits["LatestPatchSyntaxMinimalMajorTag"] = 5] = "LatestPatchSyntaxMinimalMajorTag"; +})(DotnetInstallerLimits || (DotnetInstallerLimits = {})); class DotnetVersionResolver { constructor(version) { this.inputVersion = version.trim(); @@ -267,7 +272,9 @@ class DotnetVersionResolver { isLatestPatchSyntax() { var _b, _c; const majorTag = (_c = (_b = this.inputVersion.match(/^(?\d+)\.\d+\.\d{1}x{2}$/)) === null || _b === void 0 ? void 0 : _b.groups) === null || _c === void 0 ? void 0 : _c.majorTag; - if (majorTag && parseInt(majorTag) < 5) { + if (majorTag && + parseInt(majorTag) < + DotnetInstallerLimits.LatestPatchSyntaxMinimalMajorTag) { throw new Error(`'dotnet-version' was supplied in invalid format: ${this.inputVersion}! The A.B.Cxx syntax is available since the .NET 5.0 release.`); } return majorTag ? true : false; @@ -290,10 +297,13 @@ class DotnetVersionResolver { this.resolvedArgument.value = yield this.getLatestByMajorTag(major); } else { - // Resolve LTS version of .NET if "dotnet-version" is specified as *, x or X + // If "dotnet-version" is specified as *, x or X resolve latest version of .NET explicitly from LTS channel. The version argument will be set to "latest" by default. this.resolvedArgument.value = 'LTS'; } - this.resolvedArgument.qualityFlag = parseInt(major) >= 6 ? true : false; + this.resolvedArgument.qualityFlag = + parseInt(major) >= DotnetInstallerLimits.QualityInputMinimalMajorTag + ? true + : false; }); } createDotNetVersion() { diff --git a/src/installer.ts b/src/installer.ts index 211c6c7..a105fef 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -17,6 +17,11 @@ export interface DotnetVersion { qualityFlag: boolean; } +enum DotnetInstallerLimits { + QualityInputMinimalMajorTag = 6, + LatestPatchSyntaxMinimalMajorTag = 5 +} + export class DotnetVersionResolver { private inputVersion: string; private resolvedArgument: DotnetVersion; @@ -47,7 +52,11 @@ export class DotnetVersionResolver { const majorTag = this.inputVersion.match( /^(?\d+)\.\d+\.\d{1}x{2}$/ )?.groups?.majorTag; - if (majorTag && parseInt(majorTag) < 5) { + if ( + majorTag && + parseInt(majorTag) < + DotnetInstallerLimits.LatestPatchSyntaxMinimalMajorTag + ) { throw new Error( `'dotnet-version' was supplied in invalid format: ${this.inputVersion}! The A.B.Cxx syntax is available since the .NET 5.0 release.` ); @@ -70,10 +79,13 @@ export class DotnetVersionResolver { } else if (this.isNumericTag(major)) { this.resolvedArgument.value = await this.getLatestByMajorTag(major); } else { - // Resolve LTS version of .NET if "dotnet-version" is specified as *, x or X + // If "dotnet-version" is specified as *, x or X resolve latest version of .NET explicitly from LTS channel. The version argument will be set to "latest" by default. this.resolvedArgument.value = 'LTS'; } - this.resolvedArgument.qualityFlag = parseInt(major) >= 6 ? true : false; + this.resolvedArgument.qualityFlag = + parseInt(major) >= DotnetInstallerLimits.QualityInputMinimalMajorTag + ? true + : false; } public async createDotNetVersion(): Promise {