Actions Bump (#130)
* Bump the actions group across 1 directory with 3 updates Bumps the actions group with 3 updates in the / directory: [@actions/tool-cache](https://github.com/actions/toolkit/tree/HEAD/packages/tool-cache), [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node) and [typescript](https://github.com/microsoft/TypeScript). Updates `@actions/tool-cache` from 2.0.1 to 2.0.2 - [Changelog](https://github.com/actions/toolkit/blob/main/packages/tool-cache/RELEASES.md) - [Commits](https://github.com/actions/toolkit/commits/HEAD/packages/tool-cache) Updates `@types/node` from 22.10.2 to 22.10.10 - [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases) - [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/node) Updates `typescript` from 5.7.2 to 5.7.3 - [Release notes](https://github.com/microsoft/TypeScript/releases) - [Changelog](https://github.com/microsoft/TypeScript/blob/main/azure-pipelines.release.yml) - [Commits](https://github.com/microsoft/TypeScript/compare/v5.7.2...v5.7.3) --- updated-dependencies: - dependency-name: "@actions/tool-cache" dependency-type: direct:production update-type: version-update:semver-patch dependency-group: actions - dependency-name: "@types/node" dependency-type: direct:development update-type: version-update:semver-patch dependency-group: actions - dependency-name: typescript dependency-type: direct:development update-type: version-update:semver-patch dependency-group: actions ... Signed-off-by: dependabot[bot] <support@github.com> * new method * initial * moved execution to index to free up tests --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
		
							
								
								
									
										69
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										69
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -11,16 +11,16 @@
 | 
			
		||||
         "dependencies": {
 | 
			
		||||
            "@actions/core": "^1.11.1",
 | 
			
		||||
            "@actions/exec": "^1.0.0",
 | 
			
		||||
            "@actions/tool-cache": "^2.0.1"
 | 
			
		||||
            "@actions/tool-cache": "^2.0.2"
 | 
			
		||||
         },
 | 
			
		||||
         "devDependencies": {
 | 
			
		||||
            "@types/jest": "^29.5.14",
 | 
			
		||||
            "@types/node": "^22.10.2",
 | 
			
		||||
            "@types/node": "^22.10.10",
 | 
			
		||||
            "@vercel/ncc": "^0.38.3",
 | 
			
		||||
            "jest": "^29.7.0",
 | 
			
		||||
            "prettier": "3.4.2",
 | 
			
		||||
            "ts-jest": "^29.2.5",
 | 
			
		||||
            "typescript": "5.7.2"
 | 
			
		||||
            "typescript": "5.7.3"
 | 
			
		||||
         }
 | 
			
		||||
      },
 | 
			
		||||
      "node_modules/@actions/core": {
 | 
			
		||||
@@ -54,16 +54,16 @@
 | 
			
		||||
         "integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw=="
 | 
			
		||||
      },
 | 
			
		||||
      "node_modules/@actions/tool-cache": {
 | 
			
		||||
         "version": "2.0.1",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz",
 | 
			
		||||
         "integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==",
 | 
			
		||||
         "version": "2.0.2",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.2.tgz",
 | 
			
		||||
         "integrity": "sha512-fBhNNOWxuoLxztQebpOaWu6WeVmuwa77Z+DxIZ1B+OYvGkGQon6kTVg6Z32Cb13WCuw0szqonK+hh03mJV7Z6w==",
 | 
			
		||||
         "license": "MIT",
 | 
			
		||||
         "dependencies": {
 | 
			
		||||
            "@actions/core": "^1.2.6",
 | 
			
		||||
            "@actions/core": "^1.11.1",
 | 
			
		||||
            "@actions/exec": "^1.0.0",
 | 
			
		||||
            "@actions/http-client": "^2.0.1",
 | 
			
		||||
            "@actions/io": "^1.1.1",
 | 
			
		||||
            "semver": "^6.1.0",
 | 
			
		||||
            "uuid": "^3.3.2"
 | 
			
		||||
            "semver": "^6.1.0"
 | 
			
		||||
         }
 | 
			
		||||
      },
 | 
			
		||||
      "node_modules/@ampproject/remapping": {
 | 
			
		||||
@@ -1105,10 +1105,11 @@
 | 
			
		||||
         }
 | 
			
		||||
      },
 | 
			
		||||
      "node_modules/@types/node": {
 | 
			
		||||
         "version": "22.10.2",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.2.tgz",
 | 
			
		||||
         "integrity": "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==",
 | 
			
		||||
         "version": "22.10.10",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.10.tgz",
 | 
			
		||||
         "integrity": "sha512-X47y/mPNzxviAGY5TcYPtYL8JsY3kAq2n8fMmKoRCxq/c4v4pyGNCzM2R6+M5/umG4ZfHuT+sgqDYqWc9rJ6ww==",
 | 
			
		||||
         "dev": true,
 | 
			
		||||
         "license": "MIT",
 | 
			
		||||
         "dependencies": {
 | 
			
		||||
            "undici-types": "~6.20.0"
 | 
			
		||||
         }
 | 
			
		||||
@@ -3581,10 +3582,11 @@
 | 
			
		||||
         }
 | 
			
		||||
      },
 | 
			
		||||
      "node_modules/typescript": {
 | 
			
		||||
         "version": "5.7.2",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz",
 | 
			
		||||
         "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==",
 | 
			
		||||
         "version": "5.7.3",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz",
 | 
			
		||||
         "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
 | 
			
		||||
         "dev": true,
 | 
			
		||||
         "license": "Apache-2.0",
 | 
			
		||||
         "bin": {
 | 
			
		||||
            "tsc": "bin/tsc",
 | 
			
		||||
            "tsserver": "bin/tsserver"
 | 
			
		||||
@@ -3629,15 +3631,6 @@
 | 
			
		||||
            "browserslist": ">= 4.21.0"
 | 
			
		||||
         }
 | 
			
		||||
      },
 | 
			
		||||
      "node_modules/uuid": {
 | 
			
		||||
         "version": "3.4.0",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
 | 
			
		||||
         "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
 | 
			
		||||
         "deprecated": "Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.",
 | 
			
		||||
         "bin": {
 | 
			
		||||
            "uuid": "bin/uuid"
 | 
			
		||||
         }
 | 
			
		||||
      },
 | 
			
		||||
      "node_modules/v8-to-istanbul": {
 | 
			
		||||
         "version": "9.3.0",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz",
 | 
			
		||||
@@ -3793,16 +3786,15 @@
 | 
			
		||||
         "integrity": "sha512-d+RwPlMp+2qmBfeLYPLXuSRykDIFEwdTA0MMxzS9kh4kvP1ftrc/9fzy6pX6qAjthdXruHQ6/6kjT/DNo5ALuw=="
 | 
			
		||||
      },
 | 
			
		||||
      "@actions/tool-cache": {
 | 
			
		||||
         "version": "2.0.1",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.1.tgz",
 | 
			
		||||
         "integrity": "sha512-iPU+mNwrbA8jodY8eyo/0S/QqCKDajiR8OxWTnSk/SnYg0sj8Hp4QcUEVC1YFpHWXtrfbQrE13Jz4k4HXJQKcA==",
 | 
			
		||||
         "version": "2.0.2",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/@actions/tool-cache/-/tool-cache-2.0.2.tgz",
 | 
			
		||||
         "integrity": "sha512-fBhNNOWxuoLxztQebpOaWu6WeVmuwa77Z+DxIZ1B+OYvGkGQon6kTVg6Z32Cb13WCuw0szqonK+hh03mJV7Z6w==",
 | 
			
		||||
         "requires": {
 | 
			
		||||
            "@actions/core": "^1.2.6",
 | 
			
		||||
            "@actions/core": "^1.11.1",
 | 
			
		||||
            "@actions/exec": "^1.0.0",
 | 
			
		||||
            "@actions/http-client": "^2.0.1",
 | 
			
		||||
            "@actions/io": "^1.1.1",
 | 
			
		||||
            "semver": "^6.1.0",
 | 
			
		||||
            "uuid": "^3.3.2"
 | 
			
		||||
            "semver": "^6.1.0"
 | 
			
		||||
         }
 | 
			
		||||
      },
 | 
			
		||||
      "@ampproject/remapping": {
 | 
			
		||||
@@ -4624,9 +4616,9 @@
 | 
			
		||||
         }
 | 
			
		||||
      },
 | 
			
		||||
      "@types/node": {
 | 
			
		||||
         "version": "22.10.2",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.2.tgz",
 | 
			
		||||
         "integrity": "sha512-Xxr6BBRCAOQixvonOye19wnzyDiUtTeqldOOmj3CkeblonbccA12PFwlufvRdrpjXxqnmUaeiU5EOA+7s5diUQ==",
 | 
			
		||||
         "version": "22.10.10",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/@types/node/-/node-22.10.10.tgz",
 | 
			
		||||
         "integrity": "sha512-X47y/mPNzxviAGY5TcYPtYL8JsY3kAq2n8fMmKoRCxq/c4v4pyGNCzM2R6+M5/umG4ZfHuT+sgqDYqWc9rJ6ww==",
 | 
			
		||||
         "dev": true,
 | 
			
		||||
         "requires": {
 | 
			
		||||
            "undici-types": "~6.20.0"
 | 
			
		||||
@@ -6421,9 +6413,9 @@
 | 
			
		||||
         "dev": true
 | 
			
		||||
      },
 | 
			
		||||
      "typescript": {
 | 
			
		||||
         "version": "5.7.2",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.2.tgz",
 | 
			
		||||
         "integrity": "sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==",
 | 
			
		||||
         "version": "5.7.3",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.7.3.tgz",
 | 
			
		||||
         "integrity": "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw==",
 | 
			
		||||
         "dev": true
 | 
			
		||||
      },
 | 
			
		||||
      "undici-types": {
 | 
			
		||||
@@ -6442,11 +6434,6 @@
 | 
			
		||||
            "picocolors": "^1.0.1"
 | 
			
		||||
         }
 | 
			
		||||
      },
 | 
			
		||||
      "uuid": {
 | 
			
		||||
         "version": "3.4.0",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
 | 
			
		||||
         "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A=="
 | 
			
		||||
      },
 | 
			
		||||
      "v8-to-istanbul": {
 | 
			
		||||
         "version": "9.3.0",
 | 
			
		||||
         "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz",
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@
 | 
			
		||||
   "private": true,
 | 
			
		||||
   "main": "lib/index.js",
 | 
			
		||||
   "scripts": {
 | 
			
		||||
      "build": "npm i ncc && npx ncc build src/run.ts -o lib",
 | 
			
		||||
      "build": "npm i ncc && npx ncc build src/index.ts -o lib",
 | 
			
		||||
      "test": "jest",
 | 
			
		||||
      "test-coverage": "jest --coverage",
 | 
			
		||||
      "format": "prettier --write .",
 | 
			
		||||
@@ -20,15 +20,15 @@
 | 
			
		||||
   "dependencies": {
 | 
			
		||||
      "@actions/core": "^1.11.1",
 | 
			
		||||
      "@actions/exec": "^1.0.0",
 | 
			
		||||
      "@actions/tool-cache": "^2.0.1"
 | 
			
		||||
      "@actions/tool-cache": "^2.0.2"
 | 
			
		||||
   },
 | 
			
		||||
   "devDependencies": {
 | 
			
		||||
      "@types/jest": "^29.5.14",
 | 
			
		||||
      "@types/node": "^22.10.2",
 | 
			
		||||
      "@types/node": "^22.10.10",
 | 
			
		||||
      "@vercel/ncc": "^0.38.3",
 | 
			
		||||
      "jest": "^29.7.0",
 | 
			
		||||
      "prettier": "3.4.2",
 | 
			
		||||
      "ts-jest": "^29.2.5",
 | 
			
		||||
      "typescript": "5.7.2"
 | 
			
		||||
      "typescript": "5.7.3"
 | 
			
		||||
   }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										4
									
								
								src/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								src/index.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,4 @@
 | 
			
		||||
import {run} from './run'
 | 
			
		||||
import * as core from '@actions/core'
 | 
			
		||||
 | 
			
		||||
run().catch(core.setFailed)
 | 
			
		||||
@@ -14,18 +14,14 @@ import * as util from 'util'
 | 
			
		||||
describe('Testing all functions in run file.', () => {
 | 
			
		||||
   test('getExecutableExtension() - return .exe when os is Windows', () => {
 | 
			
		||||
      jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
 | 
			
		||||
 | 
			
		||||
      expect(getExecutableExtension()).toBe('.exe')
 | 
			
		||||
      expect(os.type).toBeCalled()
 | 
			
		||||
   })
 | 
			
		||||
 | 
			
		||||
   test('getExecutableExtension() - return empty string for non-windows OS', () => {
 | 
			
		||||
      jest.spyOn(os, 'type').mockReturnValue('Darwin')
 | 
			
		||||
 | 
			
		||||
      expect(getExecutableExtension()).toBe('')
 | 
			
		||||
      expect(os.type).toBeCalled()
 | 
			
		||||
   })
 | 
			
		||||
 | 
			
		||||
   test.each([
 | 
			
		||||
      ['arm', 'arm'],
 | 
			
		||||
      ['arm64', 'arm64'],
 | 
			
		||||
@@ -34,12 +30,10 @@ describe('Testing all functions in run file.', () => {
 | 
			
		||||
      'getKubectlArch() - return on %s os arch %s kubectl arch',
 | 
			
		||||
      (osArch, kubectlArch) => {
 | 
			
		||||
         jest.spyOn(os, 'arch').mockReturnValue(osArch)
 | 
			
		||||
 | 
			
		||||
         expect(getKubectlArch()).toBe(kubectlArch)
 | 
			
		||||
         expect(os.arch).toBeCalled()
 | 
			
		||||
      }
 | 
			
		||||
   )
 | 
			
		||||
 | 
			
		||||
   test.each([['arm'], ['arm64'], ['amd64']])(
 | 
			
		||||
      'getkubectlDownloadURL() - return the URL to download %s kubectl for Linux',
 | 
			
		||||
      (arch) => {
 | 
			
		||||
@@ -48,12 +42,10 @@ describe('Testing all functions in run file.', () => {
 | 
			
		||||
            'https://dl.k8s.io/release/v1.15.0/bin/linux/%s/kubectl',
 | 
			
		||||
            arch
 | 
			
		||||
         )
 | 
			
		||||
 | 
			
		||||
         expect(getkubectlDownloadURL('v1.15.0', arch)).toBe(kubectlLinuxUrl)
 | 
			
		||||
         expect(os.type).toBeCalled()
 | 
			
		||||
      }
 | 
			
		||||
   )
 | 
			
		||||
 | 
			
		||||
   test.each([['arm'], ['arm64'], ['amd64']])(
 | 
			
		||||
      'getkubectlDownloadURL() - return the URL to download %s kubectl for Darwin',
 | 
			
		||||
      (arch) => {
 | 
			
		||||
@@ -62,17 +54,14 @@ describe('Testing all functions in run file.', () => {
 | 
			
		||||
            'https://dl.k8s.io/release/v1.15.0/bin/darwin/%s/kubectl',
 | 
			
		||||
            arch
 | 
			
		||||
         )
 | 
			
		||||
 | 
			
		||||
         expect(getkubectlDownloadURL('v1.15.0', arch)).toBe(kubectlDarwinUrl)
 | 
			
		||||
         expect(os.type).toBeCalled()
 | 
			
		||||
      }
 | 
			
		||||
   )
 | 
			
		||||
 | 
			
		||||
   test.each([['arm'], ['arm64'], ['amd64']])(
 | 
			
		||||
      'getkubectlDownloadURL() - return the URL to download %s kubectl for Windows',
 | 
			
		||||
      (arch) => {
 | 
			
		||||
         jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
 | 
			
		||||
 | 
			
		||||
         const kubectlWindowsUrl = util.format(
 | 
			
		||||
            'https://dl.k8s.io/release/v1.15.0/bin/windows/%s/kubectl.exe',
 | 
			
		||||
            arch
 | 
			
		||||
@@ -81,38 +70,31 @@ describe('Testing all functions in run file.', () => {
 | 
			
		||||
         expect(os.type).toBeCalled()
 | 
			
		||||
      }
 | 
			
		||||
   )
 | 
			
		||||
 | 
			
		||||
   test('getStableKubectlVersion() - download stable version file, read version and return it', async () => {
 | 
			
		||||
      jest
 | 
			
		||||
         .spyOn(toolCache, 'downloadTool')
 | 
			
		||||
         .mockReturnValue(Promise.resolve('pathToTool'))
 | 
			
		||||
      jest.spyOn(fs, 'readFileSync').mockReturnValue('v1.20.4')
 | 
			
		||||
 | 
			
		||||
      expect(await run.getStableKubectlVersion()).toBe('v1.20.4')
 | 
			
		||||
      expect(toolCache.downloadTool).toBeCalled()
 | 
			
		||||
      expect(fs.readFileSync).toBeCalledWith('pathToTool', 'utf8')
 | 
			
		||||
      expect(fs.readFileSync).toHaveBeenCalledWith('pathToTool', 'utf8')
 | 
			
		||||
   })
 | 
			
		||||
 | 
			
		||||
   test('getStableKubectlVersion() - return default v1.15.0 if version read is empty', async () => {
 | 
			
		||||
      jest
 | 
			
		||||
         .spyOn(toolCache, 'downloadTool')
 | 
			
		||||
         .mockReturnValue(Promise.resolve('pathToTool'))
 | 
			
		||||
      jest.spyOn(fs, 'readFileSync').mockReturnValue('')
 | 
			
		||||
 | 
			
		||||
      expect(await run.getStableKubectlVersion()).toBe('v1.15.0')
 | 
			
		||||
      expect(toolCache.downloadTool).toBeCalled()
 | 
			
		||||
      expect(fs.readFileSync).toBeCalledWith('pathToTool', 'utf8')
 | 
			
		||||
      expect(fs.readFileSync).toHaveBeenCalledWith('pathToTool', 'utf8')
 | 
			
		||||
   })
 | 
			
		||||
 | 
			
		||||
   test('getStableKubectlVersion() - return default v1.15.0 if unable to download file', async () => {
 | 
			
		||||
      jest
 | 
			
		||||
         .spyOn(toolCache, 'downloadTool')
 | 
			
		||||
         .mockRejectedValue('Unable to download.')
 | 
			
		||||
 | 
			
		||||
      expect(await run.getStableKubectlVersion()).toBe('v1.15.0')
 | 
			
		||||
      expect(toolCache.downloadTool).toBeCalled()
 | 
			
		||||
   })
 | 
			
		||||
 | 
			
		||||
   test('downloadKubectl() - download kubectl, add it to toolCache and return path to it', async () => {
 | 
			
		||||
      jest.spyOn(toolCache, 'find').mockReturnValue('')
 | 
			
		||||
      jest
 | 
			
		||||
@@ -123,43 +105,37 @@ describe('Testing all functions in run file.', () => {
 | 
			
		||||
         .mockReturnValue(Promise.resolve('pathToCachedTool'))
 | 
			
		||||
      jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
 | 
			
		||||
      jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
 | 
			
		||||
 | 
			
		||||
      expect(await run.downloadKubectl('v1.15.0')).toBe(
 | 
			
		||||
         path.join('pathToCachedTool', 'kubectl.exe')
 | 
			
		||||
      )
 | 
			
		||||
      expect(toolCache.find).toBeCalledWith('kubectl', 'v1.15.0')
 | 
			
		||||
      expect(toolCache.find).toHaveBeenCalledWith('kubectl', 'v1.15.0')
 | 
			
		||||
      expect(toolCache.downloadTool).toBeCalled()
 | 
			
		||||
      expect(toolCache.cacheFile).toBeCalled()
 | 
			
		||||
      expect(os.type).toBeCalled()
 | 
			
		||||
      expect(fs.chmodSync).toBeCalledWith(
 | 
			
		||||
      expect(fs.chmodSync).toHaveBeenCalledWith(
 | 
			
		||||
         path.join('pathToCachedTool', 'kubectl.exe'),
 | 
			
		||||
         '775'
 | 
			
		||||
      )
 | 
			
		||||
   })
 | 
			
		||||
 | 
			
		||||
   test('downloadKubectl() - throw DownloadKubectlFailed error when unable to download kubectl', async () => {
 | 
			
		||||
      jest.spyOn(toolCache, 'find').mockReturnValue('')
 | 
			
		||||
      jest
 | 
			
		||||
         .spyOn(toolCache, 'downloadTool')
 | 
			
		||||
         .mockRejectedValue('Unable to download kubectl.')
 | 
			
		||||
 | 
			
		||||
      await expect(run.downloadKubectl('v1.15.0')).rejects.toThrow(
 | 
			
		||||
         'DownloadKubectlFailed'
 | 
			
		||||
      )
 | 
			
		||||
      expect(toolCache.find).toBeCalledWith('kubectl', 'v1.15.0')
 | 
			
		||||
      expect(toolCache.find).toHaveBeenCalledWith('kubectl', 'v1.15.0')
 | 
			
		||||
      expect(toolCache.downloadTool).toBeCalled()
 | 
			
		||||
   })
 | 
			
		||||
 | 
			
		||||
   test('downloadKubectl() - throw kubectl not found error when receive 404 response', async () => {
 | 
			
		||||
      const kubectlVersion = 'v1.15.0'
 | 
			
		||||
      const arch = 'arm128'
 | 
			
		||||
 | 
			
		||||
      jest.spyOn(os, 'arch').mockReturnValue(arch)
 | 
			
		||||
      jest.spyOn(toolCache, 'find').mockReturnValue('')
 | 
			
		||||
      jest.spyOn(toolCache, 'downloadTool').mockImplementation((_) => {
 | 
			
		||||
         throw new toolCache.HTTPError(404)
 | 
			
		||||
      })
 | 
			
		||||
 | 
			
		||||
      await expect(run.downloadKubectl(kubectlVersion)).rejects.toThrow(
 | 
			
		||||
         util.format(
 | 
			
		||||
            "Kubectl '%s' for '%s' arch not found.",
 | 
			
		||||
@@ -168,28 +144,26 @@ describe('Testing all functions in run file.', () => {
 | 
			
		||||
         )
 | 
			
		||||
      )
 | 
			
		||||
      expect(os.arch).toBeCalled()
 | 
			
		||||
      expect(toolCache.find).toBeCalledWith('kubectl', kubectlVersion)
 | 
			
		||||
      expect(toolCache.find).toHaveBeenCalledWith('kubectl', kubectlVersion)
 | 
			
		||||
      expect(toolCache.downloadTool).toBeCalled()
 | 
			
		||||
   })
 | 
			
		||||
 | 
			
		||||
   test('downloadKubectl() - return path to existing cache of kubectl', async () => {
 | 
			
		||||
      jest.spyOn(core, 'getInput').mockImplementation(() => 'v1.15.5')
 | 
			
		||||
      jest.spyOn(toolCache, 'find').mockReturnValue('pathToCachedTool')
 | 
			
		||||
      jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
 | 
			
		||||
      jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
 | 
			
		||||
      jest.spyOn(toolCache, 'downloadTool')
 | 
			
		||||
 | 
			
		||||
      expect(await run.downloadKubectl('v1.15.0')).toBe(
 | 
			
		||||
         path.join('pathToCachedTool', 'kubectl.exe')
 | 
			
		||||
      )
 | 
			
		||||
      expect(toolCache.find).toBeCalledWith('kubectl', 'v1.15.0')
 | 
			
		||||
      expect(toolCache.find).toHaveBeenCalledWith('kubectl', 'v1.15.0')
 | 
			
		||||
      expect(os.type).toBeCalled()
 | 
			
		||||
      expect(fs.chmodSync).toBeCalledWith(
 | 
			
		||||
      expect(fs.chmodSync).toHaveBeenCalledWith(
 | 
			
		||||
         path.join('pathToCachedTool', 'kubectl.exe'),
 | 
			
		||||
         '775'
 | 
			
		||||
      )
 | 
			
		||||
      expect(toolCache.downloadTool).not.toBeCalled()
 | 
			
		||||
   })
 | 
			
		||||
 | 
			
		||||
   test('run() - download specified version and set output', async () => {
 | 
			
		||||
      jest.spyOn(core, 'getInput').mockReturnValue('v1.15.5')
 | 
			
		||||
      jest.spyOn(toolCache, 'find').mockReturnValue('pathToCachedTool')
 | 
			
		||||
@@ -198,16 +172,14 @@ describe('Testing all functions in run file.', () => {
 | 
			
		||||
      jest.spyOn(core, 'addPath').mockImplementation()
 | 
			
		||||
      jest.spyOn(console, 'log').mockImplementation()
 | 
			
		||||
      jest.spyOn(core, 'setOutput').mockImplementation()
 | 
			
		||||
 | 
			
		||||
      expect(await run.run()).toBeUndefined()
 | 
			
		||||
      expect(core.getInput).toBeCalledWith('version', {required: true})
 | 
			
		||||
      expect(core.addPath).toBeCalledWith('pathToCachedTool')
 | 
			
		||||
      expect(core.setOutput).toBeCalledWith(
 | 
			
		||||
      expect(core.getInput).toHaveBeenCalledWith('version', {required: true})
 | 
			
		||||
      expect(core.addPath).toHaveBeenCalledWith('pathToCachedTool')
 | 
			
		||||
      expect(core.setOutput).toHaveBeenCalledWith(
 | 
			
		||||
         'kubectl-path',
 | 
			
		||||
         path.join('pathToCachedTool', 'kubectl.exe')
 | 
			
		||||
      )
 | 
			
		||||
   })
 | 
			
		||||
 | 
			
		||||
   test('run() - get latest version, download it and set output', async () => {
 | 
			
		||||
      jest.spyOn(core, 'getInput').mockReturnValue('latest')
 | 
			
		||||
      jest
 | 
			
		||||
@@ -220,14 +192,13 @@ describe('Testing all functions in run file.', () => {
 | 
			
		||||
      jest.spyOn(core, 'addPath').mockImplementation()
 | 
			
		||||
      jest.spyOn(console, 'log').mockImplementation()
 | 
			
		||||
      jest.spyOn(core, 'setOutput').mockImplementation()
 | 
			
		||||
 | 
			
		||||
      expect(await run.run()).toBeUndefined()
 | 
			
		||||
      expect(toolCache.downloadTool).toBeCalledWith(
 | 
			
		||||
      expect(toolCache.downloadTool).toHaveBeenCalledWith(
 | 
			
		||||
         'https://storage.googleapis.com/kubernetes-release/release/stable.txt'
 | 
			
		||||
      )
 | 
			
		||||
      expect(core.getInput).toBeCalledWith('version', {required: true})
 | 
			
		||||
      expect(core.addPath).toBeCalledWith('pathToCachedTool')
 | 
			
		||||
      expect(core.setOutput).toBeCalledWith(
 | 
			
		||||
      expect(core.getInput).toHaveBeenCalledWith('version', {required: true})
 | 
			
		||||
      expect(core.addPath).toHaveBeenCalledWith('pathToCachedTool')
 | 
			
		||||
      expect(core.setOutput).toHaveBeenCalledWith(
 | 
			
		||||
         'kubectl-path',
 | 
			
		||||
         path.join('pathToCachedTool', 'kubectl.exe')
 | 
			
		||||
      )
 | 
			
		||||
 
 | 
			
		||||
@@ -89,5 +89,3 @@ export async function downloadKubectl(version: string): Promise<string> {
 | 
			
		||||
   fs.chmodSync(kubectlPath, '775')
 | 
			
		||||
   return kubectlPath
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
run().catch(core.setFailed)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user