From d26ead4cf075832061d80601b2fbea1d47568807 Mon Sep 17 00:00:00 2001 From: Nogic <24802730+nogic1008@users.noreply.github.com> Date: Mon, 25 Jul 2022 02:58:35 +0000 Subject: [PATCH 1/5] chore(deps-dev): migrate husky config to v8 Follow: https://github.com/typicode/husky-4-to-8 - npm install husky --save-dev - npx husky-init - npm exec -- github:typicode/husky-4-to-8 --remove-v4-config --- .husky/pre-commit | 4 ++++ .husky/pre-push | 5 +++++ package-lock.json | 16 ++++++++-------- package.json | 10 ++-------- 4 files changed, 19 insertions(+), 16 deletions(-) create mode 100755 .husky/pre-commit create mode 100755 .husky/pre-push diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 0000000..1bda9c1 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npm run format diff --git a/.husky/pre-push b/.husky/pre-push new file mode 100755 index 0000000..1dc0f9b --- /dev/null +++ b/.husky/pre-push @@ -0,0 +1,5 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +# Tests are not run at push time since they can take 2-4 minutes to complete +npm run format-check diff --git a/package-lock.json b/package-lock.json index 8eb695c..96c9134 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "@types/node": "^16.11.25", "@types/semver": "^6.2.2", "@vercel/ncc": "^0.33.4", - "husky": "^7.0.2", + "husky": "^8.0.1", "jest": "^27.2.5", "jest-circus": "^27.2.5", "prettier": "^1.19.1", @@ -2305,15 +2305,15 @@ } }, "node_modules/husky": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.2.tgz", - "integrity": "sha512-8yKEWNX4z2YsofXAMT7KvA1g8p+GxtB1ffV8XtpAEGuXNAbCV5wdNKH+qTpw8SM9fh4aMPDR+yQuKfgnreyZlg==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", + "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", "dev": true, "bin": { "husky": "lib/bin.js" }, "engines": { - "node": ">=12" + "node": ">=14" }, "funding": { "url": "https://github.com/sponsors/typicode" @@ -6645,9 +6645,9 @@ "dev": true }, "husky": { - "version": "7.0.2", - "resolved": "https://registry.npmjs.org/husky/-/husky-7.0.2.tgz", - "integrity": "sha512-8yKEWNX4z2YsofXAMT7KvA1g8p+GxtB1ffV8XtpAEGuXNAbCV5wdNKH+qTpw8SM9fh4aMPDR+yQuKfgnreyZlg==", + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/husky/-/husky-8.0.1.tgz", + "integrity": "sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw==", "dev": true }, "iconv-lite": { diff --git a/package.json b/package.json index 71d3438..fcb4562 100644 --- a/package.json +++ b/package.json @@ -8,16 +8,10 @@ "build": "tsc && ncc build", "format": "prettier --write **/*.ts", "format-check": "prettier --check **/*.ts", + "prepare": "husky install", "test": "jest", "update-installers": "nwget https://dot.net/v1/dotnet-install.ps1 -O externals/install-dotnet.ps1 && nwget https://dot.net/v1/dotnet-install.sh -O externals/install-dotnet.sh" }, - "husky": { - "hooks": { - "//": "Tests are not run at push time since they can take 2-4 minutes to complete", - "pre-commit": "npm run format", - "pre-push": "npm run format-check" - } - }, "repository": { "type": "git", "url": "git+https://github.com/actions/setup-dotnet.git" @@ -44,7 +38,7 @@ "@types/node": "^16.11.25", "@types/semver": "^6.2.2", "@vercel/ncc": "^0.33.4", - "husky": "^7.0.2", + "husky": "^8.0.1", "jest": "^27.2.5", "jest-circus": "^27.2.5", "prettier": "^1.19.1", From bac4044d912f17c32b2d7d6ee0f35f701be2e352 Mon Sep 17 00:00:00 2001 From: Nogic <24802730+nogic1008@users.noreply.github.com> Date: Mon, 25 Jul 2022 03:07:37 +0000 Subject: [PATCH 2/5] ci: add `--ignore-scripts` argument --- .github/workflows/check-dist.yml | 2 +- .github/workflows/licensed.yml | 2 +- .github/workflows/workflow.yml | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/check-dist.yml b/.github/workflows/check-dist.yml index 1275188..91e3b88 100644 --- a/.github/workflows/check-dist.yml +++ b/.github/workflows/check-dist.yml @@ -30,7 +30,7 @@ jobs: cache: npm - name: Install dependencies - run: npm ci + run: npm ci --ignore-scripts - name: Rebuild the dist/ directory run: npm run build diff --git a/.github/workflows/licensed.yml b/.github/workflows/licensed.yml index fd70702..d8fb6ea 100644 --- a/.github/workflows/licensed.yml +++ b/.github/workflows/licensed.yml @@ -15,7 +15,7 @@ jobs: name: Check licenses steps: - uses: actions/checkout@v3 - - run: npm ci + - run: npm ci --ignore-scripts - name: Install licensed run: | cd $RUNNER_TEMP diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index d2dcede..629d82a 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -26,14 +26,14 @@ jobs: with: node-version: 16.x cache: npm - - run: npm ci + - run: npm ci --ignore-scripts - run: npm run build - run: npm run format-check - run: npm test - name: Verify no unstaged changes if: runner.os != 'windows' run: __tests__/verify-no-unstaged-changes.sh - + test-setup-multiple-versions: runs-on: ${{ matrix.operating-system }} strategy: @@ -50,9 +50,9 @@ jobs: uses: ./ with: dotnet-version: | - 2.2.402 - 3.1.404 - 3.0.x + 2.2.402 + 3.1.404 + 3.0.x - name: Verify dotnet shell: pwsh run: __tests__/verify-dotnet.ps1 2.2.402 3.1.404 '3.0' @@ -114,7 +114,7 @@ jobs: - name: Verify dotnet shell: pwsh run: __tests__/verify-dotnet.ps1 3.1 2.2 - + test-setup-latest-patch-version: runs-on: ${{ matrix.operating-system }} strategy: From ba5e53c61d7c39e7733cdefda3a45f96b5ec0db4 Mon Sep 17 00:00:00 2001 From: Nogic <24802730+nogic1008@users.noreply.github.com> Date: Wed, 24 Nov 2021 09:08:35 +0900 Subject: [PATCH 3/5] refactor: use core.getBooleanInput() --- dist/index.js | 3 +-- src/setup-dotnet.ts | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dist/index.js b/dist/index.js index 1ef7203..d897c56 100644 --- a/dist/index.js +++ b/dist/index.js @@ -478,8 +478,7 @@ function run() { } } if (versions.length) { - const includePrerelease = (core.getInput('include-prerelease') || 'false').toLowerCase() === - 'true'; + const includePrerelease = core.getBooleanInput('include-prerelease'); let dotnetInstaller; for (const version of new Set(versions)) { dotnetInstaller = new installer.DotnetCoreInstaller(version, includePrerelease); diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index 64f3149..2ae0459 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -38,9 +38,9 @@ export async function run() { } if (versions.length) { - const includePrerelease: boolean = - (core.getInput('include-prerelease') || 'false').toLowerCase() === - 'true'; + const includePrerelease: boolean = core.getBooleanInput( + 'include-prerelease' + ); let dotnetInstaller!: installer.DotnetCoreInstaller; for (const version of new Set(versions)) { dotnetInstaller = new installer.DotnetCoreInstaller( From c5267f5e54b2cc875fa47dca679c1771f95d5abd Mon Sep 17 00:00:00 2001 From: Nogic <24802730+nogic1008@users.noreply.github.com> Date: Wed, 24 Nov 2021 09:12:08 +0900 Subject: [PATCH 4/5] chore: set include-prerelease to false on default --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 3c0ecb0..0405e1c 100644 --- a/action.yml +++ b/action.yml @@ -18,6 +18,7 @@ inputs: include-prerelease: description: 'Whether prerelease versions should be matched with non-exact versions (for example 5.0.0-preview.6 being matched by 5, 5.0, 5.x or 5.0.x). Defaults to false if not provided.' required: False + default: 'false' runs: using: 'node16' main: 'dist/index.js' From c2dac7f3675d6dc861cd7705d30a4bd3133ca98b Mon Sep 17 00:00:00 2001 From: Nogic <24802730+nogic1008@users.noreply.github.com> Date: Wed, 24 Nov 2021 09:12:51 +0900 Subject: [PATCH 5/5] test: add include-prerelease env on test --- __tests__/setup-dotnet.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/__tests__/setup-dotnet.test.ts b/__tests__/setup-dotnet.test.ts index 7ad8be8..aa8e380 100644 --- a/__tests__/setup-dotnet.test.ts +++ b/__tests__/setup-dotnet.test.ts @@ -16,6 +16,7 @@ describe('setup-dotnet tests', () => { process.env.RUNNER_TOOL_CACHE = toolDir; process.env.DOTNET_INSTALL_DIR = toolDir; process.env.RUNNER_TEMP = tempDir; + process.env['INPUT_INCLUDE-PRERELEASE'] = 'false'; await io.rmRF(toolDir); await io.rmRF(tempDir); });