4
0
Fork 0
mirror of https://github.com/Azure/setup-helm.git synced 2025-11-07 04:56:56 +00:00

Merge branch 'main' into default-version

This commit is contained in:
Suneha Bose 2025-08-06 13:17:51 -07:00 committed by GitHub
commit deb4c049e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 1002 additions and 3819 deletions

2
.github/CODEOWNERS vendored
View file

@ -1 +1 @@
* @Azure/aks-atlanta * @Azure/cloud-native-github-action-owners

View file

@ -76,7 +76,8 @@ jobs:
--repo helm/helm \ --repo helm/helm \
--exclude-drafts \ --exclude-drafts \
--exclude-pre-releases \ --exclude-pre-releases \
--limit 1 | awk '{print $4}') --json name,isLatest \
--jq '.[] | select(.isLatest)|.name' | awk '{print $2}')
if [[ $(helm version) != *$HELM_LATEST* ]]; then if [[ $(helm version) != *$HELM_LATEST* ]]; then
echo "HELM VERSION INCORRECT: HELM VERSION DOES NOT CONTAIN $HELM_LATEST" echo "HELM VERSION INCORRECT: HELM VERSION DOES NOT CONTAIN $HELM_LATEST"

View file

@ -13,6 +13,6 @@ jobs:
permissions: permissions:
actions: read actions: read
contents: write contents: write
uses: Azure/action-release-workflows/.github/workflows/release_js_project.yaml@1b199cc979febcb43526d33853f2d71183091cdb # v1.0.2 uses: Azure/action-release-workflows/.github/workflows/release_js_project.yaml@3c677ba5ab58f5c5c1a6f0cfb176b333b1f27405 # v1.0.3
with: with:
changelogPath: ./CHANGELOG.md changelogPath: ./CHANGELOG.md

7
.husky/pre-commit Normal file
View file

@ -0,0 +1,7 @@
npm test
npm run format-check || {
echo ""
echo "❌ Formatting check failed."
echo "💡 Run 'npm run format' or 'prettier --write .' to fix formatting issues."
exit 1
}

4773
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -15,20 +15,21 @@
}, },
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {
"prebuild": "npm i ncc",
"build": "ncc build src/index.ts -o lib", "build": "ncc build src/index.ts -o lib",
"test": "jest", "test": "jest",
"test-coverage": "jest --coverage", "test-coverage": "jest --coverage",
"format": "prettier --write .", "format": "prettier --write .",
"format-check": "prettier --check ." "format-check": "prettier --check .",
"prepare": "husky"
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^30.0.0", "@types/jest": "^30.0.0",
"@types/node": "^24.0.1", "@types/node": "^24.1.0",
"@vercel/ncc": "^0.38.3", "@vercel/ncc": "^0.38.3",
"jest": "^30.0.0", "husky": "^9.1.7",
"prettier": "^3.5.3", "jest": "^30.0.5",
"ts-jest": "^29.4.0", "prettier": "^3.6.2",
"typescript": "^5.8.3" "ts-jest": "^29.4.1",
"typescript": "^5.9.2"
} }
} }

View file

@ -67,7 +67,7 @@ describe('run.ts', () => {
expect(os.arch).toHaveBeenCalled() expect(os.arch).toHaveBeenCalled()
}) })
test('getHelmDownloadURL() - return the URL to download helm for Windows', () => { test('getHelmDownloadURL() - return the URL to download helm for Windows x64', () => {
jest.spyOn(os, 'platform').mockReturnValue('win32') jest.spyOn(os, 'platform').mockReturnValue('win32')
jest.spyOn(os, 'arch').mockReturnValue('x64') jest.spyOn(os, 'arch').mockReturnValue('x64')
@ -76,6 +76,15 @@ describe('run.ts', () => {
expect(os.platform).toHaveBeenCalled() expect(os.platform).toHaveBeenCalled()
}) })
test('getHelmDownloadURL() - return the URL to download helm for Windows arm64', () => {
jest.spyOn(os, 'platform').mockReturnValue('win32')
jest.spyOn(os, 'arch').mockReturnValue('arm64')
const expected = 'https://test.tld/helm-v3.8.0-windows-arm64.zip'
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe(expected)
expect(os.platform).toHaveBeenCalled()
})
test('getLatestHelmVersion() - return the latest version of HELM', async () => { test('getLatestHelmVersion() - return the latest version of HELM', async () => {
const res = { const res = {
status: 200, status: 200,
@ -88,7 +97,7 @@ describe('run.ts', () => {
test('getLatestHelmVersion() - return the stable version of HELM when simulating a network error', async () => { test('getLatestHelmVersion() - return the stable version of HELM when simulating a network error', async () => {
const errorMessage: string = 'Network Error' const errorMessage: string = 'Network Error'
global.fetch = jest.fn().mockRejectedValueOnce(new Error(errorMessage)) global.fetch = jest.fn().mockRejectedValueOnce(new Error(errorMessage))
expect(await run.getLatestHelmVersion()).toBe('v3.18.3') expect(await run.getLatestHelmVersion()).toBe(run.stableHelmVersion)
}) })
test('getValidVersion() - return version with v prepended', () => { test('getValidVersion() - return version with v prepended', () => {
@ -204,6 +213,7 @@ describe('run.ts', () => {
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, 'platform').mockReturnValue('win32')
jest.spyOn(os, 'arch').mockReturnValue('x64')
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {}) jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
jest.spyOn(toolCache, 'extractZip').mockResolvedValue('extractedPath') jest.spyOn(toolCache, 'extractZip').mockResolvedValue('extractedPath')
jest.spyOn(toolCache, 'cacheDir').mockResolvedValue('pathToCachedDir') jest.spyOn(toolCache, 'cacheDir').mockResolvedValue('pathToCachedDir')
@ -239,6 +249,7 @@ describe('run.ts', () => {
throw 'Unable to download' throw 'Unable to download'
}) })
jest.spyOn(os, 'platform').mockReturnValue('win32') jest.spyOn(os, 'platform').mockReturnValue('win32')
jest.spyOn(os, 'arch').mockReturnValue('x64')
const downloadUrl = 'https://test.tld/helm-v3.2.1-windows-amd64.zip' const downloadUrl = 'https://test.tld/helm-v3.2.1-windows-amd64.zip'
await expect(run.downloadHelm(downloadBaseURL, 'v3.2.1')).rejects.toThrow( await expect(run.downloadHelm(downloadBaseURL, 'v3.2.1')).rejects.toThrow(
@ -254,6 +265,7 @@ describe('run.ts', () => {
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool') jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool')
jest.spyOn(toolCache, 'extractZip').mockResolvedValue('extractedPath') jest.spyOn(toolCache, 'extractZip').mockResolvedValue('extractedPath')
jest.spyOn(os, 'platform').mockReturnValue('win32') jest.spyOn(os, 'platform').mockReturnValue('win32')
jest.spyOn(os, 'arch').mockReturnValue('x64')
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {}) jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
jest jest
.spyOn(fs, 'readdirSync') .spyOn(fs, 'readdirSync')
@ -283,6 +295,7 @@ describe('run.ts', () => {
jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool') jest.spyOn(toolCache, 'downloadTool').mockResolvedValue('pathToTool')
jest.spyOn(toolCache, 'extractZip').mockResolvedValue('extractedPath') jest.spyOn(toolCache, 'extractZip').mockResolvedValue('extractedPath')
jest.spyOn(os, 'platform').mockReturnValue('win32') jest.spyOn(os, 'platform').mockReturnValue('win32')
jest.spyOn(os, 'arch').mockReturnValue('x64')
jest.spyOn(fs, 'chmodSync').mockImplementation() jest.spyOn(fs, 'chmodSync').mockImplementation()
jest.spyOn(fs, 'readdirSync').mockImplementation((file, _) => []) jest.spyOn(fs, 'readdirSync').mockImplementation((file, _) => [])
jest.spyOn(fs, 'statSync').mockImplementation((file) => { jest.spyOn(fs, 'statSync').mockImplementation((file) => {

View file

@ -10,7 +10,7 @@ import * as toolCache from '@actions/tool-cache'
import * as core from '@actions/core' import * as core from '@actions/core'
const helmToolName = 'helm' const helmToolName = 'helm'
const stableHelmVersion = 'v3.18.3' export const stableHelmVersion = 'v3.18.3'
export async function run() { export async function run() {
let version = core.getInput('version', {required: true}) let version = core.getInput('version', {required: true})