mirror of
https://github.com/Azure/setup-helm.git
synced 2025-07-17 19:30:34 +00:00
Compare commits
3 Commits
v4.2.0
...
davidgamer
Author | SHA1 | Date | |
---|---|---|---|
2fed091e15 | |||
0ef5b45fe6 | |||
1430074977 |
16
.github/workflows/release-pr.yml
vendored
16
.github/workflows/release-pr.yml
vendored
@ -1,18 +1,16 @@
|
|||||||
name: Release Project
|
name: Create release PR
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
|
||||||
- CHANGELOG.md
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
release:
|
||||||
|
description: 'Define release version (ex: v1, v2, v3)'
|
||||||
|
required: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release-pr:
|
||||||
|
uses: Azure/action-release-workflows/.github/workflows/release_js_project.yaml@a705b2ab6a3ee889f2b0d925ad0bd2f9eb733ce6
|
||||||
permissions:
|
permissions:
|
||||||
actions: read
|
|
||||||
contents: write
|
contents: write
|
||||||
uses: Azure/action-release-workflows/.github/workflows/release_js_project.yaml@v1
|
|
||||||
with:
|
with:
|
||||||
changelogPath: ./CHANGELOG.md
|
changelogPath: ./CHANGELOG.md
|
||||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -11,6 +11,8 @@ pids
|
|||||||
*.seed
|
*.seed
|
||||||
*.pid.lock
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
# Coverage directory used by tools like istanbul
|
# Coverage directory used by tools like istanbul
|
||||||
coverage
|
coverage
|
||||||
@ -62,3 +64,4 @@ node_modules
|
|||||||
coverage
|
coverage
|
||||||
|
|
||||||
# Transpiled JS
|
# Transpiled JS
|
||||||
|
lib/
|
||||||
|
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,13 +0,0 @@
|
|||||||
# Change Log
|
|
||||||
|
|
||||||
## [4.2.0] - 2024-04-15
|
|
||||||
|
|
||||||
- #124 Fix OS detection and download OS-native archive extension
|
|
||||||
|
|
||||||
## [4.1.0] - 2024-03-01
|
|
||||||
|
|
||||||
- #130 switches to use Helm published file to read latest version instead of using GitHub releases
|
|
||||||
|
|
||||||
## [4.0.0] - 2024-02-12
|
|
||||||
|
|
||||||
- #121 update to node20 as node16 is deprecated
|
|
@ -4,17 +4,18 @@ Install a specific version of helm binary on the runner.
|
|||||||
|
|
||||||
## Example
|
## Example
|
||||||
|
|
||||||
Acceptable values are latest or any semantic version string like v3.5.0 Use this action in workflow to define which version of helm will be used. v2+ of this action only support Helm3.
|
Acceptable values are latest or any semantic version string like v3.5.0 Use this action in workflow to define which version of helm will be used. v2 and v3 of this action only support Helm3.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: azure/setup-helm@v4.2.0
|
- uses: azure/setup-helm@v3
|
||||||
with:
|
with:
|
||||||
version: '<version>' # default is latest (stable)
|
version: '<version>' # default is latest (stable)
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }} # only needed if version is 'latest'
|
||||||
id: install
|
id: install
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> If something goes wrong with fetching the latest version the action will use the hardcoded default stable version (currently v3.13.3). If you rely on a certain version higher than the default, you should explicitly use that version instead of latest.
|
> When using latest version you might hit the GitHub GraphQL API hourly rate limit of 5,000. The action will then return the hardcoded default stable version (currently v3.13.3). If you rely on a certain version higher than the default, you should use that version instead of latest.
|
||||||
|
|
||||||
The cached helm binary path is prepended to the PATH environment variable as well as stored in the helm-path output variable.
|
The cached helm binary path is prepended to the PATH environment variable as well as stored in the helm-path output variable.
|
||||||
Refer to the action metadata file for details about all the inputs https://github.com/Azure/setup-helm/blob/master/action.yml
|
Refer to the action metadata file for details about all the inputs https://github.com/Azure/setup-helm/blob/master/action.yml
|
||||||
|
@ -6,9 +6,8 @@ inputs:
|
|||||||
required: true
|
required: true
|
||||||
default: 'latest'
|
default: 'latest'
|
||||||
token:
|
token:
|
||||||
description: GitHub token. Used to be required to fetch the latest version
|
description: GitHub token. Required only if 'version' == 'latest'
|
||||||
required: false
|
required: false
|
||||||
deprecationMessage: 'GitHub token is no longer required'
|
|
||||||
default: '${{ github.token }}'
|
default: '${{ github.token }}'
|
||||||
downloadBaseURL:
|
downloadBaseURL:
|
||||||
description: 'Set the download base URL'
|
description: 'Set the download base URL'
|
||||||
|
30846
lib/index.js
30846
lib/index.js
File diff suppressed because one or more lines are too long
135
package-lock.json
generated
135
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "setuphelm",
|
"name": "setuphelm",
|
||||||
"version": "4.2.0",
|
"version": "0.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "setuphelm",
|
"name": "setuphelm",
|
||||||
"version": "4.2.0",
|
"version": "0.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
@ -14,7 +14,6 @@
|
|||||||
"@actions/io": "^1.1.2",
|
"@actions/io": "^1.1.2",
|
||||||
"@actions/tool-cache": "2.0.1",
|
"@actions/tool-cache": "2.0.1",
|
||||||
"@octokit/action": "^6.0.7",
|
"@octokit/action": "^6.0.7",
|
||||||
"ncc": "^0.3.6",
|
|
||||||
"semver": "^7.5.4"
|
"semver": "^7.5.4"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -1117,9 +1116,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@octokit/action/node_modules/undici": {
|
"node_modules/@octokit/action/node_modules/undici": {
|
||||||
"version": "6.11.1",
|
"version": "6.5.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.11.1.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-6.5.0.tgz",
|
||||||
"integrity": "sha512-KyhzaLJnV1qa3BSHdj4AZ2ndqI0QWPxYzaIOio0WzcEJB9gvuysprJSLtpvc2D9mhR9jPDUk7xlJlZbH2KR5iw==",
|
"integrity": "sha512-/MUmPb2ptTvp1j7lPvdMSofMdqPxcOhAaKZi4k55sqm6XMeKI3n1dZJ5cnD4gLjpt2l7CIlthR1IXM59xKhpxw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@fastify/busboy": "^2.0.0"
|
||||||
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0"
|
"node": ">=18.0"
|
||||||
}
|
}
|
||||||
@ -1581,7 +1583,8 @@
|
|||||||
"node_modules/balanced-match": {
|
"node_modules/balanced-match": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
|
||||||
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
|
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/before-after-hook": {
|
"node_modules/before-after-hook": {
|
||||||
"version": "2.2.3",
|
"version": "2.2.3",
|
||||||
@ -1592,6 +1595,7 @@
|
|||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
|
||||||
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
|
||||||
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"balanced-match": "^1.0.0",
|
"balanced-match": "^1.0.0",
|
||||||
"concat-map": "0.0.1"
|
"concat-map": "0.0.1"
|
||||||
@ -1800,18 +1804,11 @@
|
|||||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/colors": {
|
|
||||||
"version": "1.2.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.2.3.tgz",
|
|
||||||
"integrity": "sha512-qTfM2pNFeMZcLvf/RbrVAzDEVttZjFhaApfx9dplNjvHSX88Ui66zBRb/4YGob/xUWxDceirgoC1lT676asfCQ==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=0.1.90"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/concat-map": {
|
"node_modules/concat-map": {
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||||
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg=="
|
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/convert-source-map": {
|
"node_modules/convert-source-map": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
@ -1854,14 +1851,6 @@
|
|||||||
"node": ">= 8"
|
"node": ">= 8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/dateformat": {
|
|
||||||
"version": "3.0.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz",
|
|
||||||
"integrity": "sha512-jyCETtSl3VMZMWeRo7iY1FL19ges1t55hMo5yaam4Jrsm5EPL89UQkoQRyiI+Yf4k8r2ZpdngkV8hr1lIdjb3Q==",
|
|
||||||
"engines": {
|
|
||||||
"node": "*"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/debug": {
|
"node_modules/debug": {
|
||||||
"version": "4.3.4",
|
"version": "4.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||||
@ -2080,7 +2069,8 @@
|
|||||||
"node_modules/fs.realpath": {
|
"node_modules/fs.realpath": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
|
||||||
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw=="
|
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/function-bind": {
|
"node_modules/function-bind": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.2",
|
||||||
@ -2134,6 +2124,7 @@
|
|||||||
"version": "7.2.3",
|
"version": "7.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz",
|
||||||
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
|
"integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==",
|
||||||
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fs.realpath": "^1.0.0",
|
"fs.realpath": "^1.0.0",
|
||||||
"inflight": "^1.0.4",
|
"inflight": "^1.0.4",
|
||||||
@ -2232,6 +2223,7 @@
|
|||||||
"version": "1.0.6",
|
"version": "1.0.6",
|
||||||
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
|
||||||
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
|
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
|
||||||
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"once": "^1.3.0",
|
"once": "^1.3.0",
|
||||||
"wrappy": "1"
|
"wrappy": "1"
|
||||||
@ -2240,7 +2232,8 @@
|
|||||||
"node_modules/inherits": {
|
"node_modules/inherits": {
|
||||||
"version": "2.0.4",
|
"version": "2.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
|
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||||
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/is-arrayish": {
|
"node_modules/is-arrayish": {
|
||||||
"version": "0.2.1",
|
"version": "0.2.1",
|
||||||
@ -3088,6 +3081,7 @@
|
|||||||
"version": "3.1.2",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||||
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
|
||||||
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"brace-expansion": "^1.1.7"
|
"brace-expansion": "^1.1.7"
|
||||||
},
|
},
|
||||||
@ -3095,25 +3089,6 @@
|
|||||||
"node": "*"
|
"node": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/minimist": {
|
|
||||||
"version": "1.2.8",
|
|
||||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
|
||||||
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
|
||||||
"funding": {
|
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/mkdirp": {
|
|
||||||
"version": "0.5.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
|
||||||
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
|
|
||||||
"dependencies": {
|
|
||||||
"minimist": "^1.2.6"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"mkdirp": "bin/cmd.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ms": {
|
"node_modules/ms": {
|
||||||
"version": "2.1.2",
|
"version": "2.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||||
@ -3126,17 +3101,6 @@
|
|||||||
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
|
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/ncc": {
|
|
||||||
"version": "0.3.6",
|
|
||||||
"resolved": "https://registry.npmjs.org/ncc/-/ncc-0.3.6.tgz",
|
|
||||||
"integrity": "sha512-OXudTB2Ebt/FnOuDoPQbaa17+tdVqSOWA+gLfPxccWwsNED1uA2zEhpoB1hwdFC9yYbio/mdV5cvOtQI3Zrx1w==",
|
|
||||||
"dependencies": {
|
|
||||||
"mkdirp": "^0.5.1",
|
|
||||||
"rimraf": "^2.6.1",
|
|
||||||
"tracer": "^0.8.7",
|
|
||||||
"ws": "^2.3.1"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/node-int64": {
|
"node_modules/node-int64": {
|
||||||
"version": "0.4.0",
|
"version": "0.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz",
|
||||||
@ -3275,6 +3239,7 @@
|
|||||||
"version": "1.0.1",
|
"version": "1.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
|
||||||
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
|
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
|
||||||
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
}
|
}
|
||||||
@ -3465,22 +3430,6 @@
|
|||||||
"node": ">=10"
|
"node": ">=10"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/rimraf": {
|
|
||||||
"version": "2.7.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz",
|
|
||||||
"integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==",
|
|
||||||
"dependencies": {
|
|
||||||
"glob": "^7.1.3"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"rimraf": "bin.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/safe-buffer": {
|
|
||||||
"version": "5.0.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.0.1.tgz",
|
|
||||||
"integrity": "sha512-cr7dZWLwOeaFBLTIuZeYdkfO7UzGIKhjYENJFAxUOMKWGaWDm2nJM2rzxNRm5Owu0DH3ApwNo6kx5idXZfb/Iw=="
|
|
||||||
},
|
|
||||||
"node_modules/semver": {
|
"node_modules/semver": {
|
||||||
"version": "7.5.4",
|
"version": "7.5.4",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
|
||||||
@ -3697,14 +3646,6 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tinytim": {
|
|
||||||
"version": "0.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/tinytim/-/tinytim-0.1.1.tgz",
|
|
||||||
"integrity": "sha512-NIpsp9lBIxPNzB++HnMmUd4byzJSVbbO4F+As1Gb1IG/YQT5QvmBDjpx8SpDS8fhGC+t+Qw8ldQgbcAIaU+2cA==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.2.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/tmpl": {
|
"node_modules/tmpl": {
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz",
|
"resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz",
|
||||||
@ -3732,20 +3673,6 @@
|
|||||||
"node": ">=8.0"
|
"node": ">=8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tracer": {
|
|
||||||
"version": "0.8.15",
|
|
||||||
"resolved": "https://registry.npmjs.org/tracer/-/tracer-0.8.15.tgz",
|
|
||||||
"integrity": "sha512-ZQzlhd6zZFIpAhACiZkxLjl65XqVwi8t8UEBVGRIHAQN6nj55ftJWiFell+WSqWCP/vEycrIbUSuiyMwul+TFw==",
|
|
||||||
"dependencies": {
|
|
||||||
"colors": "1.2.3",
|
|
||||||
"dateformat": "3.0.3",
|
|
||||||
"mkdirp": "^0.5.1",
|
|
||||||
"tinytim": "0.1.1"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.10.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/ts-jest": {
|
"node_modules/ts-jest": {
|
||||||
"version": "29.1.2",
|
"version": "29.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.2.tgz",
|
||||||
@ -3831,15 +3758,10 @@
|
|||||||
"node": ">=14.17"
|
"node": ">=14.17"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ultron": {
|
|
||||||
"version": "1.1.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz",
|
|
||||||
"integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og=="
|
|
||||||
},
|
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "5.28.4",
|
"version": "5.28.2",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.2.tgz",
|
||||||
"integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==",
|
"integrity": "sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/busboy": "^2.0.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
},
|
},
|
||||||
@ -3969,15 +3891,6 @@
|
|||||||
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
|
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ws": {
|
|
||||||
"version": "2.3.1",
|
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-2.3.1.tgz",
|
|
||||||
"integrity": "sha512-61a+9LgtYZxTq1hAonhX8Xwpo2riK4IOR/BIVxioFbCfc3QFKmpE4x9dLExfLHKtUfVZigYa36tThVhO57erEw==",
|
|
||||||
"dependencies": {
|
|
||||||
"safe-buffer": "~5.0.1",
|
|
||||||
"ultron": "~1.1.0"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/y18n": {
|
"node_modules/y18n": {
|
||||||
"version": "5.0.8",
|
"version": "5.0.8",
|
||||||
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setuphelm",
|
"name": "setuphelm",
|
||||||
"version": "4.2.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Setup helm",
|
"description": "Setup helm",
|
||||||
"author": "Anumita Shenoy",
|
"author": "Anumita Shenoy",
|
||||||
@ -11,12 +11,10 @@
|
|||||||
"@actions/io": "^1.1.2",
|
"@actions/io": "^1.1.2",
|
||||||
"@actions/tool-cache": "2.0.1",
|
"@actions/tool-cache": "2.0.1",
|
||||||
"@octokit/action": "^6.0.7",
|
"@octokit/action": "^6.0.7",
|
||||||
"ncc": "^0.3.6",
|
|
||||||
"semver": "^7.5.4"
|
"semver": "^7.5.4"
|
||||||
},
|
},
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "npm i ncc",
|
|
||||||
"build": "ncc build src/run.ts -o lib",
|
"build": "ncc build src/run.ts -o lib",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"test-coverage": "jest --coverage",
|
"test-coverage": "jest --coverage",
|
||||||
|
184
src/run.test.ts
184
src/run.test.ts
@ -6,95 +6,90 @@ import * as path from 'path'
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
|
||||||
describe('run.ts', () => {
|
describe('run.ts', () => {
|
||||||
const downloadBaseURL = 'https://test.tld'
|
|
||||||
|
|
||||||
// Cleanup mocks after each test to ensure that subsequent tests are not affected by the mocks.
|
|
||||||
afterEach(() => {
|
|
||||||
jest.restoreAllMocks()
|
|
||||||
})
|
|
||||||
|
|
||||||
test('getExecutableExtension() - return .exe when os is Windows', () => {
|
test('getExecutableExtension() - return .exe when os is Windows', () => {
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('win32')
|
jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
|
||||||
|
|
||||||
expect(run.getExecutableExtension()).toBe('.exe')
|
expect(run.getExecutableExtension()).toBe('.exe')
|
||||||
expect(os.platform).toHaveBeenCalled()
|
expect(os.type).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('getExecutableExtension() - return empty string for non-windows OS', () => {
|
test('getExecutableExtension() - return empty string for non-windows OS', () => {
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('darwin')
|
jest.spyOn(os, 'type').mockReturnValue('Darwin')
|
||||||
|
|
||||||
expect(run.getExecutableExtension()).toBe('')
|
expect(run.getExecutableExtension()).toBe('')
|
||||||
expect(os.platform).toHaveBeenCalled()
|
expect(os.type).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('getHelmDownloadURL() - return the URL to download helm for Linux amd64', () => {
|
test('getHelmDownloadURL() - return the URL to download helm for Linux', () => {
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('linux')
|
const downloadBaseURL = 'https://test.tld'
|
||||||
jest.spyOn(os, 'arch').mockReturnValue('x64')
|
|
||||||
const expected = 'https://test.tld/helm-v3.8.0-linux-amd64.tar.gz'
|
|
||||||
|
|
||||||
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe(expected)
|
jest.spyOn(os, 'type').mockReturnValue('Linux')
|
||||||
expect(os.platform).toHaveBeenCalled()
|
jest.spyOn(os, 'arch').mockReturnValueOnce('unknown')
|
||||||
|
const helmLinuxUrl = 'https://test.tld/helm-v3.8.0-linux-amd64.zip'
|
||||||
|
|
||||||
|
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe(
|
||||||
|
helmLinuxUrl
|
||||||
|
)
|
||||||
|
expect(os.type).toHaveBeenCalled()
|
||||||
|
expect(os.arch).toHaveBeenCalled()
|
||||||
|
|
||||||
|
// arm64
|
||||||
|
jest.spyOn(os, 'type').mockReturnValue('Linux')
|
||||||
|
jest.spyOn(os, 'arch').mockReturnValueOnce('arm64')
|
||||||
|
const helmLinuxArm64Url = 'https://test.tld/helm-v3.8.0-linux-arm64.zip'
|
||||||
|
|
||||||
|
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe(
|
||||||
|
helmLinuxArm64Url
|
||||||
|
)
|
||||||
|
expect(os.type).toHaveBeenCalled()
|
||||||
expect(os.arch).toHaveBeenCalled()
|
expect(os.arch).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('getHelmDownloadURL() - return the URL to download helm for Linux arm64', () => {
|
test('getHelmDownloadURL() - return the URL to download helm for Darwin', () => {
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('linux')
|
const downloadBaseURL = 'https://test.tld'
|
||||||
jest.spyOn(os, 'arch').mockReturnValue('arm64')
|
|
||||||
const expected = 'https://test.tld/helm-v3.8.0-linux-arm64.tar.gz'
|
|
||||||
|
|
||||||
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe(expected)
|
jest.spyOn(os, 'type').mockReturnValue('Darwin')
|
||||||
expect(os.platform).toHaveBeenCalled()
|
jest.spyOn(os, 'arch').mockReturnValueOnce('unknown')
|
||||||
|
const helmDarwinUrl = 'https://test.tld/helm-v3.8.0-darwin-amd64.zip'
|
||||||
|
|
||||||
|
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe(
|
||||||
|
helmDarwinUrl
|
||||||
|
)
|
||||||
|
expect(os.type).toHaveBeenCalled()
|
||||||
expect(os.arch).toHaveBeenCalled()
|
expect(os.arch).toHaveBeenCalled()
|
||||||
})
|
|
||||||
|
|
||||||
test('getHelmDownloadURL() - return the URL to download helm for Darwin x64', () => {
|
// arm64
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('darwin')
|
jest.spyOn(os, 'type').mockReturnValue('Darwin')
|
||||||
jest.spyOn(os, 'arch').mockReturnValue('x64')
|
jest.spyOn(os, 'arch').mockReturnValueOnce('arm64')
|
||||||
const expected = 'https://test.tld/helm-v3.8.0-darwin-amd64.tar.gz'
|
const helmDarwinArm64Url = 'https://test.tld/helm-v3.8.0-darwin-arm64.zip'
|
||||||
|
|
||||||
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe(expected)
|
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe(
|
||||||
expect(os.platform).toHaveBeenCalled()
|
helmDarwinArm64Url
|
||||||
|
)
|
||||||
|
expect(os.type).toHaveBeenCalled()
|
||||||
expect(os.arch).toHaveBeenCalled()
|
expect(os.arch).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('getHelmDownloadURL() - return the URL to download helm for Darwin arm64', () => {
|
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('darwin')
|
|
||||||
jest.spyOn(os, 'arch').mockReturnValue('arm64')
|
|
||||||
const expected = 'https://test.tld/helm-v3.8.0-darwin-arm64.tar.gz'
|
|
||||||
|
|
||||||
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe(expected)
|
|
||||||
expect(os.platform).toHaveBeenCalled()
|
|
||||||
expect(os.arch).toHaveBeenCalled()
|
|
||||||
})
|
|
||||||
|
|
||||||
test('getHelmDownloadURL() - return the URL to download helm for Windows', () => {
|
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('win32')
|
|
||||||
jest.spyOn(os, 'arch').mockReturnValue('x64')
|
|
||||||
|
|
||||||
const expected = 'https://test.tld/helm-v3.8.0-windows-amd64.zip'
|
|
||||||
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe(expected)
|
|
||||||
expect(os.platform).toHaveBeenCalled()
|
|
||||||
})
|
|
||||||
|
|
||||||
test('getLatestHelmVersion() - return the latest version of HELM', async () => {
|
|
||||||
const res = {
|
|
||||||
status: 200,
|
|
||||||
text: async () => 'v9.99.999'
|
|
||||||
} as Response
|
|
||||||
global.fetch = jest.fn().mockReturnValue(res)
|
|
||||||
expect(await run.getLatestHelmVersion()).toBe('v9.99.999')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('getLatestHelmVersion() - return the stable version of HELM when simulating a network error', async () => {
|
|
||||||
const errorMessage: string = 'Network Error'
|
|
||||||
global.fetch = jest.fn().mockRejectedValueOnce(new Error(errorMessage))
|
|
||||||
expect(await run.getLatestHelmVersion()).toBe('v3.13.3')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('getValidVersion() - return version with v prepended', () => {
|
test('getValidVersion() - return version with v prepended', () => {
|
||||||
expect(run.getValidVersion('3.8.0')).toBe('v3.8.0')
|
expect(run.getValidVersion('3.8.0')).toBe('v3.8.0')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('getHelmDownloadURL() - return the URL to download helm for Windows', () => {
|
||||||
|
const downloadBaseURL = 'https://test.tld'
|
||||||
|
|
||||||
|
jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
|
||||||
|
|
||||||
|
const helmWindowsUrl = 'https://test.tld/helm-v3.8.0-windows-amd64.zip'
|
||||||
|
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe(
|
||||||
|
helmWindowsUrl
|
||||||
|
)
|
||||||
|
expect(os.type).toHaveBeenCalled()
|
||||||
|
})
|
||||||
|
|
||||||
|
test('getLatestHelmVersion() - return the stable version of HELM since its not authenticated', async () => {
|
||||||
|
expect(await run.getLatestHelmVersion()).toBe('v3.13.3')
|
||||||
|
})
|
||||||
|
|
||||||
test('walkSync() - return path to the all files matching fileToFind in dir', () => {
|
test('walkSync() - return path to the all files matching fileToFind in dir', () => {
|
||||||
jest.spyOn(fs, 'readdirSync').mockImplementation((file, _) => {
|
jest.spyOn(fs, 'readdirSync').mockImplementation((file, _) => {
|
||||||
if (file == 'mainFolder')
|
if (file == 'mainFolder')
|
||||||
@ -114,7 +109,6 @@ describe('run.ts', () => {
|
|||||||
'file21' as unknown as fs.Dirent,
|
'file21' as unknown as fs.Dirent,
|
||||||
'file22' as unknown as fs.Dirent
|
'file22' as unknown as fs.Dirent
|
||||||
]
|
]
|
||||||
return []
|
|
||||||
})
|
})
|
||||||
jest.spyOn(core, 'debug').mockImplementation()
|
jest.spyOn(core, 'debug').mockImplementation()
|
||||||
jest.spyOn(fs, 'statSync').mockImplementation((file) => {
|
jest.spyOn(fs, 'statSync').mockImplementation((file) => {
|
||||||
@ -149,7 +143,6 @@ describe('run.ts', () => {
|
|||||||
'file21' as unknown as fs.Dirent,
|
'file21' as unknown as fs.Dirent,
|
||||||
'file22' as unknown as fs.Dirent
|
'file22' as unknown as fs.Dirent
|
||||||
]
|
]
|
||||||
return []
|
|
||||||
})
|
})
|
||||||
jest.spyOn(core, 'debug').mockImplementation()
|
jest.spyOn(core, 'debug').mockImplementation()
|
||||||
jest.spyOn(fs, 'statSync').mockImplementation((file) => {
|
jest.spyOn(fs, 'statSync').mockImplementation((file) => {
|
||||||
@ -167,14 +160,13 @@ describe('run.ts', () => {
|
|||||||
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
|
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
|
||||||
jest.spyOn(fs, 'readdirSync').mockImplementation((file, _) => {
|
jest.spyOn(fs, 'readdirSync').mockImplementation((file, _) => {
|
||||||
if (file == 'mainFolder') return ['helm.exe' as unknown as fs.Dirent]
|
if (file == 'mainFolder') return ['helm.exe' as unknown as fs.Dirent]
|
||||||
return []
|
|
||||||
})
|
})
|
||||||
jest.spyOn(fs, 'statSync').mockImplementation((file) => {
|
jest.spyOn(fs, 'statSync').mockImplementation((file) => {
|
||||||
const isDirectory =
|
const isDirectory =
|
||||||
(file as string).indexOf('folder') == -1 ? false : true
|
(file as string).indexOf('folder') == -1 ? false : true
|
||||||
return {isDirectory: () => isDirectory} as fs.Stats
|
return {isDirectory: () => isDirectory} as fs.Stats
|
||||||
})
|
})
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('win32')
|
jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
|
||||||
|
|
||||||
expect(run.findHelm('mainFolder')).toBe(
|
expect(run.findHelm('mainFolder')).toBe(
|
||||||
path.join('mainFolder', 'helm.exe')
|
path.join('mainFolder', 'helm.exe')
|
||||||
@ -185,13 +177,11 @@ describe('run.ts', () => {
|
|||||||
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
|
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
|
||||||
jest.spyOn(fs, 'readdirSync').mockImplementation((file, _) => {
|
jest.spyOn(fs, 'readdirSync').mockImplementation((file, _) => {
|
||||||
if (file == 'mainFolder') return []
|
if (file == 'mainFolder') return []
|
||||||
return []
|
|
||||||
})
|
})
|
||||||
jest.spyOn(fs, 'statSync').mockImplementation((file) => {
|
jest.spyOn(fs, 'statSync').mockImplementation((file) => {
|
||||||
return {isDirectory: () => true} as fs.Stats
|
return {isDirectory: () => true} as fs.Stats
|
||||||
})
|
})
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('win32')
|
jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
|
||||||
|
|
||||||
expect(() => run.findHelm('mainFolder')).toThrow(
|
expect(() => run.findHelm('mainFolder')).toThrow(
|
||||||
'Helm executable not found in path mainFolder'
|
'Helm executable not found in path mainFolder'
|
||||||
)
|
)
|
||||||
@ -202,9 +192,11 @@ describe('run.ts', () => {
|
|||||||
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool')
|
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool')
|
||||||
const response = JSON.stringify([{tag_name: 'v4.0.0'}])
|
const response = JSON.stringify([{tag_name: 'v4.0.0'}])
|
||||||
jest.spyOn(fs, 'readFileSync').mockReturnValue(response)
|
jest.spyOn(fs, 'readFileSync').mockReturnValue(response)
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('win32')
|
jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
|
||||||
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
|
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
|
||||||
jest.spyOn(toolCache, 'extractZip').mockResolvedValue('extractedPath')
|
jest
|
||||||
|
.spyOn(toolCache, 'extractZip')
|
||||||
|
.mockResolvedValue('pathToUnzippedHelm')
|
||||||
jest.spyOn(toolCache, 'cacheDir').mockResolvedValue('pathToCachedDir')
|
jest.spyOn(toolCache, 'cacheDir').mockResolvedValue('pathToCachedDir')
|
||||||
jest
|
jest
|
||||||
.spyOn(fs, 'readdirSync')
|
.spyOn(fs, 'readdirSync')
|
||||||
@ -215,7 +207,9 @@ describe('run.ts', () => {
|
|||||||
return {isDirectory: () => isDirectory} as fs.Stats
|
return {isDirectory: () => isDirectory} as fs.Stats
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(await run.downloadHelm(downloadBaseURL, 'v4.0.0')).toBe(
|
const baseURL = 'https://test.tld'
|
||||||
|
|
||||||
|
expect(await run.downloadHelm(baseURL, 'v4.0.0')).toBe(
|
||||||
path.join('pathToCachedDir', 'helm.exe')
|
path.join('pathToCachedDir', 'helm.exe')
|
||||||
)
|
)
|
||||||
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v4.0.0')
|
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v4.0.0')
|
||||||
@ -235,33 +229,26 @@ describe('run.ts', () => {
|
|||||||
jest.spyOn(toolCache, 'downloadTool').mockImplementation(async () => {
|
jest.spyOn(toolCache, 'downloadTool').mockImplementation(async () => {
|
||||||
throw 'Unable to download'
|
throw 'Unable to download'
|
||||||
})
|
})
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('win32')
|
jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
|
||||||
|
|
||||||
const downloadUrl = 'https://test.tld/helm-v3.2.1-windows-amd64.zip'
|
const baseURL = 'https://test.tld'
|
||||||
await expect(run.downloadHelm(downloadBaseURL, 'v3.2.1')).rejects.toThrow(
|
|
||||||
`Failed to download Helm from location ${downloadUrl}`
|
await expect(run.downloadHelm(baseURL, 'v3.2.1')).rejects.toThrow(
|
||||||
|
'Failed to download Helm from location https://test.tld/helm-v3.2.1-windows-amd64.zip'
|
||||||
)
|
)
|
||||||
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v3.2.1')
|
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v3.2.1')
|
||||||
expect(toolCache.downloadTool).toHaveBeenCalledWith(`${downloadUrl}`)
|
expect(toolCache.downloadTool).toHaveBeenCalledWith(
|
||||||
|
'https://test.tld/helm-v3.2.1-windows-amd64.zip'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('downloadHelm() - return path to helm tool with same version from toolCache', async () => {
|
test('downloadHelm() - return path to helm tool with same version from toolCache', async () => {
|
||||||
jest.spyOn(toolCache, 'find').mockReturnValue('pathToCachedDir')
|
jest.spyOn(toolCache, 'find').mockReturnValue('pathToCachedDir')
|
||||||
jest.spyOn(toolCache, 'cacheDir').mockResolvedValue('pathToCachedDir')
|
|
||||||
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool')
|
|
||||||
jest.spyOn(toolCache, 'extractZip').mockResolvedValue('extractedPath')
|
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('win32')
|
|
||||||
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
|
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
|
||||||
jest
|
|
||||||
.spyOn(fs, 'readdirSync')
|
|
||||||
.mockReturnValue(['helm.exe' as unknown as fs.Dirent])
|
|
||||||
jest.spyOn(fs, 'statSync').mockImplementation((file) => {
|
|
||||||
const isDirectory =
|
|
||||||
(file as string).indexOf('folder') == -1 ? false : true
|
|
||||||
return {isDirectory: () => isDirectory} as fs.Stats
|
|
||||||
})
|
|
||||||
|
|
||||||
expect(await run.downloadHelm(downloadBaseURL, 'v3.2.1')).toBe(
|
const baseURL = 'https://test.tld'
|
||||||
|
|
||||||
|
expect(await run.downloadHelm(baseURL, 'v3.2.1')).toBe(
|
||||||
path.join('pathToCachedDir', 'helm.exe')
|
path.join('pathToCachedDir', 'helm.exe')
|
||||||
)
|
)
|
||||||
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v3.2.1')
|
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v3.2.1')
|
||||||
@ -274,11 +261,12 @@ describe('run.ts', () => {
|
|||||||
test('downloadHelm() - throw error is helm is not found in path', async () => {
|
test('downloadHelm() - throw error is helm is not found in path', async () => {
|
||||||
jest.spyOn(toolCache, 'find').mockReturnValue('')
|
jest.spyOn(toolCache, 'find').mockReturnValue('')
|
||||||
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool')
|
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool')
|
||||||
jest.spyOn(toolCache, 'cacheDir').mockResolvedValue('pathToCachedDir')
|
jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
|
||||||
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool')
|
|
||||||
jest.spyOn(toolCache, 'extractZip').mockResolvedValue('extractedPath')
|
|
||||||
jest.spyOn(os, 'platform').mockReturnValue('win32')
|
|
||||||
jest.spyOn(fs, 'chmodSync').mockImplementation()
|
jest.spyOn(fs, 'chmodSync').mockImplementation()
|
||||||
|
jest
|
||||||
|
.spyOn(toolCache, 'extractZip')
|
||||||
|
.mockResolvedValue('pathToUnzippedHelm')
|
||||||
|
jest.spyOn(toolCache, 'cacheDir').mockResolvedValue('pathToCachedDir')
|
||||||
jest.spyOn(fs, 'readdirSync').mockImplementation((file, _) => [])
|
jest.spyOn(fs, 'readdirSync').mockImplementation((file, _) => [])
|
||||||
jest.spyOn(fs, 'statSync').mockImplementation((file) => {
|
jest.spyOn(fs, 'statSync').mockImplementation((file) => {
|
||||||
const isDirectory =
|
const isDirectory =
|
||||||
@ -286,7 +274,9 @@ describe('run.ts', () => {
|
|||||||
return {isDirectory: () => isDirectory} as fs.Stats
|
return {isDirectory: () => isDirectory} as fs.Stats
|
||||||
})
|
})
|
||||||
|
|
||||||
await expect(run.downloadHelm(downloadBaseURL, 'v3.2.1')).rejects.toThrow(
|
const baseURL = 'https://test.tld'
|
||||||
|
|
||||||
|
await expect(run.downloadHelm(baseURL, 'v3.2.1')).rejects.toThrow(
|
||||||
'Helm executable not found in path pathToCachedDir'
|
'Helm executable not found in path pathToCachedDir'
|
||||||
)
|
)
|
||||||
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v3.2.1')
|
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v3.2.1')
|
||||||
|
79
src/run.ts
79
src/run.ts
@ -9,6 +9,7 @@ import * as fs from 'fs'
|
|||||||
|
|
||||||
import * as toolCache from '@actions/tool-cache'
|
import * as toolCache from '@actions/tool-cache'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import {Octokit} from '@octokit/action'
|
||||||
|
|
||||||
const helmToolName = 'helm'
|
const helmToolName = 'helm'
|
||||||
const stableHelmVersion = 'v3.13.3'
|
const stableHelmVersion = 'v3.13.3'
|
||||||
@ -50,35 +51,75 @@ export function getValidVersion(version: string): string {
|
|||||||
// Gets the latest helm version or returns a default stable if getting latest fails
|
// Gets the latest helm version or returns a default stable if getting latest fails
|
||||||
export async function getLatestHelmVersion(): Promise<string> {
|
export async function getLatestHelmVersion(): Promise<string> {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('https://get.helm.sh/helm-latest-version')
|
const octokit = new Octokit()
|
||||||
const release = (await response.text()).trim()
|
const response = await octokit.rest.repos.listReleases({
|
||||||
return release
|
owner: 'helm',
|
||||||
|
repo: 'helm',
|
||||||
|
per_page: 100,
|
||||||
|
order: 'desc',
|
||||||
|
sort: 'created'
|
||||||
|
})
|
||||||
|
|
||||||
|
const releases = response.data
|
||||||
|
const latestValidRelease: string = releases.find(
|
||||||
|
({tag_name, draft, prerelease}) =>
|
||||||
|
isValidVersion(tag_name) && !draft && !prerelease
|
||||||
|
)?.tag_name
|
||||||
|
|
||||||
|
if (latestValidRelease) return latestValidRelease
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
core.warning(
|
core.warning(
|
||||||
`Error while fetching latest Helm release: ${err.toString()}. Using default version ${stableHelmVersion}`
|
`Error while fetching latest Helm release: ${err.toString()}. Using default version ${stableHelmVersion}`
|
||||||
)
|
)
|
||||||
return stableHelmVersion
|
return stableHelmVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
core.warning(
|
||||||
|
`Could not find valid release. Using default version ${stableHelmVersion}`
|
||||||
|
)
|
||||||
|
return stableHelmVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getArch(): string {
|
// isValidVersion checks if verison is a stable release
|
||||||
return os.arch() === 'x64' ? 'amd64' : os.arch()
|
function isValidVersion(version: string): boolean {
|
||||||
}
|
return version.indexOf('rc') == -1
|
||||||
|
|
||||||
export function getPlatform(): string {
|
|
||||||
return os.platform() === 'win32' ? 'windows' : os.platform()
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getArchiveExtension(): string {
|
|
||||||
return os.platform() === 'win32' ? 'zip' : 'tar.gz'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getExecutableExtension(): string {
|
export function getExecutableExtension(): string {
|
||||||
return os.platform() === 'win32' ? '.exe' : ''
|
if (os.type().match(/^Win/)) {
|
||||||
|
return '.exe'
|
||||||
|
}
|
||||||
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const LINUX = 'Linux'
|
||||||
|
const MAC_OS = 'Darwin'
|
||||||
|
const WINDOWS = 'Windows_NT'
|
||||||
|
const ARM64 = 'arm64'
|
||||||
export function getHelmDownloadURL(baseURL: string, version: string): string {
|
export function getHelmDownloadURL(baseURL: string, version: string): string {
|
||||||
const urlPath = `helm-${version}-${getPlatform()}-${getArch()}.${getArchiveExtension()}`
|
const arch = os.arch()
|
||||||
|
const operatingSystem = os.type()
|
||||||
|
|
||||||
|
let urlPath = ''
|
||||||
|
|
||||||
|
switch (true) {
|
||||||
|
case operatingSystem == LINUX && arch == ARM64:
|
||||||
|
urlPath = util.format(`/helm-%s-linux-arm64.zip`, version)
|
||||||
|
break
|
||||||
|
case operatingSystem == LINUX:
|
||||||
|
urlPath = util.format(`/helm-%s-linux-amd64.zip`, version)
|
||||||
|
break
|
||||||
|
case operatingSystem == MAC_OS && arch == ARM64:
|
||||||
|
urlPath = util.format(`/helm-%s-darwin-arm64.zip`, version)
|
||||||
|
break
|
||||||
|
case operatingSystem == MAC_OS:
|
||||||
|
urlPath = util.format(`/helm-%s-darwin-amd64.zip`, version)
|
||||||
|
break
|
||||||
|
case operatingSystem == WINDOWS:
|
||||||
|
default:
|
||||||
|
urlPath = util.format(`/helm-%s-windows-amd64.zip`, version)
|
||||||
|
}
|
||||||
|
|
||||||
const url = new URL(urlPath, baseURL)
|
const url = new URL(urlPath, baseURL)
|
||||||
return url.toString()
|
return url.toString()
|
||||||
}
|
}
|
||||||
@ -104,13 +145,9 @@ export async function downloadHelm(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fs.chmodSync(helmDownloadPath, '777')
|
fs.chmodSync(helmDownloadPath, '777')
|
||||||
const extractedPath =
|
const unzipedHelmPath = await toolCache.extractZip(helmDownloadPath)
|
||||||
getPlatform() === 'windows'
|
|
||||||
? await toolCache.extractZip(helmDownloadPath)
|
|
||||||
: await toolCache.extractTar(helmDownloadPath)
|
|
||||||
|
|
||||||
cachedToolpath = await toolCache.cacheDir(
|
cachedToolpath = await toolCache.cacheDir(
|
||||||
extractedPath,
|
unzipedHelmPath,
|
||||||
helmToolName,
|
helmToolName,
|
||||||
version
|
version
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user