Skip to content

Commit

Permalink
do not check releases for known versions (#95)
Browse files Browse the repository at this point in the history
This avoids hitting rate limits when not necessary.
  • Loading branch information
eifinger authored Oct 28, 2023
1 parent 5cca91d commit 4967d35
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 14 deletions.
10 changes: 10 additions & 0 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ test('checksum should match', async () => {
const isValid = await utils.validateCheckSum(filePath, validChecksum)
expect(isValid).toBeTruthy()
})

test('known checksum should be true', () => {
const isKnown = utils.isknownVersion('0.12.0')
expect(isKnown).toBeTruthy()
})

test('unknown checksum should be false', () => {
const isKnown = utils.isknownVersion('0.09.0')
expect(isKnown).toBeFalsy()
})
7 changes: 6 additions & 1 deletion dist/save-cache/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/save-cache/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/setup/37.index.js.map

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion dist/setup/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/setup/index.js.map

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"devDependencies": {
"@types/node": "^20.8.9",
"@typescript-eslint/parser": "^5.62.0",
"@vercel/ncc": "^0.38.0",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.52.0",
"eslint-plugin-github": "^4.10.1",
"eslint-plugin-jest": "^27.6.0",
Expand Down
7 changes: 6 additions & 1 deletion src/setup-rye.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
REPO,
KNOWN_CHECKSUMS,
validateCheckSum,
getArch
getArch,
isknownVersion
} from './utils'

async function run(): Promise<void> {
Expand Down Expand Up @@ -49,6 +50,10 @@ async function run(): Promise<void> {
}

async function resolveVersion(versionInput: string): Promise<string> {
if (isknownVersion(versionInput)) {
core.debug(`Version ${versionInput} is known.`)
return versionInput
}
const availableVersion = await getAvailableVersions()
if (!availableVersion.includes(versionInput)) {
if (versionInput === 'latest') {
Expand Down
5 changes: 5 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ export async function validateCheckSum(
})
}

export function isknownVersion(version: string): boolean {
const pattern = new RegExp(`^.*-.*-${version}$`)
return Object.keys(KNOWN_CHECKSUMS).some(key => pattern.test(key))
}

export function getArch(): Architecture | undefined {
const arch = process.arch
const archMapping: {[key: string]: Architecture} = {
Expand Down

0 comments on commit 4967d35

Please sign in to comment.