Compare commits

...

6 Commits
v1 ... v2

Author SHA1 Message Date
imranismail
2ba527d4d0 bump dependencies and add getPinnedVersion resolver to speed up pinned version lookups 2023-10-24 18:32:32 +13:00
Imran Ismail
a76db1c641 Update README.md 2022-10-17 02:28:13 +08:00
Imran Ismail
6691bdeb1b Set version to v2.0.0 2022-10-17 02:25:22 +08:00
Imran Ismail
86a0af5aa8 Use core.getBooleanInput (#280)
* Use core.getBooleanInput

* Update test
2022-10-17 02:22:29 +08:00
Imran Ismail
8757bab9d6 Default fail-fast to true (#279) 2022-10-17 02:13:54 +08:00
Imran Ismail
32e634d4e0 Increase per page limit to 100 (#278)
* Increase per page limit to 100

* Add build
2022-10-17 02:04:29 +08:00
13 changed files with 34708 additions and 23213 deletions

View File

@@ -44,7 +44,8 @@
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error"
"@typescript-eslint/unbound-method": "error",
"i18n-text/no-en": "off"
},
"env": {
"node": true,

View File

@@ -1 +1 @@
nodejs 17.7.1
nodejs 20.8.1

View File

@@ -12,7 +12,7 @@ Every argument is optional.
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `github-token` | PAT (Personal Access Token) for authorizing the repository.<br>_Defaults to **\${{ github.token }}**_ |
| `kustomize-version` | Semver of kustomize to use. Examples: `10.x`, `10.15.1`, `>=10.15.0`<br>_Defaults to **\***_ |
| `fail-fast` | When github rate limits us, fail immediately or retry after the timeout that github wishes from us? Note: When setting this to `false` (which is the default!), a github workflow might accrue a long (and possibly expensive) runtime. |
| `fail-fast` | When github rate limits us, fail immediately or retry after the timeout that github wishes from us? <br>Note: When this is set to `false`, a github workflow might accrue a long (and possibly expensive) runtime.<br>_Defaults to **true**_ |
## Usage
@@ -28,7 +28,7 @@ jobs:
needs:
- publish-image
steps:
- uses: imranismail/setup-kustomize@v1
- uses: imranismail/setup-kustomize@v2
- run: |
kustomize edit set image app:${GITHUB_SHA}
git add .

View File

@@ -8,6 +8,7 @@ const tempDir = path.join(__dirname, 'runner', 'temp')
process.env['RUNNER_TOOL_CACHE'] = toolDir
process.env['RUNNER_TEMP'] = tempDir
process.env['INPUT_FAIL-FAST'] = 'true'
import * as installer from '../src/installer'
@@ -34,6 +35,22 @@ describe('installer tests', () => {
}
})
it('Acquires kustomize version 5.2.1', async () => {
await installer.getKustomize('5.2.1')
const kustomizeDir = path.join(toolDir, 'kustomize', '5.2.1', os.arch())
expect(fs.existsSync(`${kustomizeDir}.complete`)).toBe(true)
if (IS_WINDOWS) {
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize.exe'))).toBe(true)
} else {
expect(fs.existsSync(path.join(kustomizeDir, 'kustomize'))).toBe(true)
expect(() =>
fs.accessSync(path.join(kustomizeDir, 'kustomize'), fs.constants.X_OK)
).not.toThrow()
}
})
it('Acquires kustomize version 3.2.0', async () => {
await installer.getKustomize('3.2.0')
const kustomizeDir = path.join(toolDir, 'kustomize', '3.2.0', os.arch())

View File

@@ -16,7 +16,7 @@ inputs:
fail-fast:
description: 'Fail quickly on github rate limit. "false" or "true".'
required: false
default: 'false'
default: 'true'
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'

41865
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

145
dist/licenses.txt vendored
View File

@@ -12,9 +12,27 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
@actions/exec
MIT
The MIT License (MIT)
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@actions/github
MIT
The MIT License (MIT)
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@actions/http-client
MIT
@@ -65,6 +83,28 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@fastify/busboy
MIT
Copyright Brian White. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
@octokit/auth-token
MIT
The MIT License
@@ -262,16 +302,6 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
@vercel/ncc
MIT
Copyright 2018 ZEIT, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
before-after-hook
Apache-2.0
Apache License
@@ -564,32 +594,6 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
node-fetch
MIT
The MIT License (MIT)
Copyright (c) 2016 David Frank
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
once
ISC
The ISC License
@@ -628,9 +632,6 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
tr46
MIT
tunnel
MIT
The MIT License (MIT)
@@ -656,6 +657,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
undici
MIT
MIT License
Copyright (c) Matteo Collina and Undici contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
universal-user-agent
ISC
# [ISC License](https://spdx.org/licenses/ISC)
@@ -680,47 +706,6 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
webidl-conversions
BSD-2-Clause
# The BSD 2-Clause License
Copyright (c) 2014, Domenic Denicola
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
whatwg-url
MIT
The MIT License (MIT)
Copyright (c) 20152016 Sebastian Mayr
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
wrappy
ISC
The ISC License

File diff suppressed because one or more lines are too long

15771
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{
"name": "setup-kustomize",
"version": "1.7.1",
"version": "2.1.0",
"private": true,
"description": "Github action to setup-kustomize",
"main": "lib/main.js",
@@ -26,26 +26,26 @@
"license": "MIT",
"dependencies": {
"@actions/core": "^1.2.6",
"@actions/github": "^4.0.0",
"@actions/github": "^6.0.0",
"@actions/io": "^1.1.1",
"@actions/tool-cache": "^1.7.1",
"@octokit/plugin-throttling": "^3.4.1",
"semver": "^7.3.2"
"@actions/tool-cache": "^2.0.1",
"@octokit/plugin-throttling": "^8.0.1",
"semver": "^7.5.4"
},
"devDependencies": {
"@types/jest": "^27.4.1",
"@types/node": "~17.0",
"@types/jest": "^29.5.6",
"@types/node": "^20.8.8",
"@types/semver": "^7.3.9",
"@typescript-eslint/parser": "^4.8.1",
"@vercel/ncc": "^0.33.3",
"eslint": "^7.32.0",
"eslint-plugin-github": "^4.1.1",
"eslint-plugin-jest": "^24.1.3",
"jest": "^26.6.3",
"jest-circus": "^26.6.3",
"@typescript-eslint/parser": "^6.9.0",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.52.0",
"eslint-plugin-github": "^4.10.1",
"eslint-plugin-jest": "^27.4.3",
"jest": "^29.7.0",
"jest-circus": "^29.7.0",
"js-yaml": "^4.1.0",
"prettier": "2.5.1",
"ts-jest": "^26.4.4",
"typescript": "^4.1.3"
"prettier": "^3.0.3",
"ts-jest": "^29.1.1",
"typescript": "^5.2.2"
}
}

View File

@@ -1,5 +1,5 @@
import {GitHub, getOctokitOptions} from '@actions/github/lib/utils'
import {OctokitOptions} from '@octokit/core/dist-types/types'
import {OctokitOptions} from '@octokit/core/dist-types/types.d'
import {throttling} from '@octokit/plugin-throttling'
import * as core from '@actions/core'
import * as cache from '@actions/tool-cache'
@@ -11,7 +11,7 @@ let tempDirectory = process.env['RUNNER_TEMPDIRECTORY'] || ''
const EnhancedOctokit = GitHub.plugin(throttling)
const githubToken = core.getInput('github-token')
const failFast = core.getInput('fail-fast') === 'true' ? true : false
const failFast = core.getBooleanInput('fail-fast')
let options: OctokitOptions = {
throttle: {
@@ -24,7 +24,7 @@ let options: OctokitOptions = {
}
return !failFast
},
onAbuseLimit: (retryAfter: Number, opts: OctokitOptions) => {
onSecondaryRateLimit: (retryAfter: Number, opts: OctokitOptions) => {
core.warning(`Abuse detected for request ${opts.method} ${opts.url}`)
if (!failFast) {
core.warning(`Retrying after ${retryAfter} seconds!`)
@@ -65,10 +65,14 @@ export async function getKustomize(targetVersion: string): Promise<void> {
if (!semver.validRange(targetVersion))
throw new Error(`invalid semver requested: ${targetVersion}`)
const resolver = semver.valid(targetVersion)
? getPinnedVersion
: getMaxSatisfyingVersion
let kustomizePath = cache.find('kustomize', targetVersion)
if (!kustomizePath) {
const version = await getMaxSatisfyingVersion(targetVersion)
const version = await resolver(targetVersion)
kustomizePath = await acquireVersion(version)
}
@@ -81,6 +85,55 @@ interface Version {
url: string
}
async function getPinnedVersion(targetVersion: string): Promise<Version> {
const prefix = semver.gt(targetVersion, '3.2.0') ? 'kustomize/v' : 'v'
try {
const response = await octokit.rest.repos.getReleaseByTag({
owner: 'kubernetes-sigs',
repo: 'kustomize',
tag: prefix + targetVersion
})
if (response.status !== 200) {
throw new Error(`Invalid response status ${response.status}`)
}
const release = response.data
const matchingAsset = release.assets.find(
asset =>
asset.name.includes('kustomize') &&
asset.name.includes(platform) &&
asset.name.includes(arch)
)
if (matchingAsset) {
const kustomizeVersion = (
versionRegex.exec(release.tag_name) || []
).shift()
if (kustomizeVersion != null) {
return {
target: targetVersion,
resolved: kustomizeVersion,
url: matchingAsset.browser_download_url
}
} else {
throw new Error(
`Could not find version in release tag ${release.tag_name}`
)
}
} else {
throw new Error(
`Could not find asset for platform '${platform}' and '${arch}'.`
)
}
} catch (err) {
throw new Error(`Could not satisfy version range ${targetVersion}: ${err}`)
}
}
async function getMaxSatisfyingVersion(
targetVersion: string
): Promise<Version> {
@@ -88,10 +141,11 @@ async function getMaxSatisfyingVersion(
const availableVersions: Map<string, string> = new Map()
for await (const response of octokit.paginate.iterator(
octokit.repos.listReleases,
octokit.rest.repos.listReleases,
{
owner: 'kubernetes-sigs',
repo: 'kustomize'
repo: 'kustomize',
per_page: 100
}
)) {
for (const release of response.data) {
@@ -124,7 +178,8 @@ async function getMaxSatisfyingVersion(
if (!resolved) {
throw new Error(
`Unable to find Kustomize version '${version.target}' for platform '${platform}' and architecture ${arch}.`
`Could not satisfy version '${version.target}': Could not find asset for platform '${platform}' and
${arch}'.`
)
}
@@ -141,7 +196,6 @@ async function acquireVersion(version: Version): Promise<string> {
try {
toolPath = await cache.downloadTool(version.url)
} catch (err) {
core.debug(err)
throw new Error(`Failed to download version ${version.target}: ${err}`)
}

View File

@@ -13,7 +13,7 @@ async function run(): Promise<void> {
await installer.getKustomize(version)
}
} catch (error) {
core.setFailed(error.message)
core.setFailed(`${error}`)
}
}