Skip to content

Commit

Permalink
Set RYE_HOME before installing rye
Browse files Browse the repository at this point in the history
  • Loading branch information
eifinger committed Mar 4, 2024
1 parent f8aec3f commit 720e7bf
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 73 deletions.
16 changes: 5 additions & 11 deletions 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.

56 changes: 31 additions & 25 deletions 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.

3 changes: 2 additions & 1 deletion dist/update-checksums/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/update-checksums/index.js.map

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions src/download/download-version.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
import * as core from '@actions/core'
import * as tc from '@actions/tool-cache'
import {Architecture, OWNER, REPO, extract, validateChecksum} from '../utils'
import * as io from '@actions/io'
import {
Architecture,
OWNER,
REPO,
extract,
toolsCacheName,
validateChecksum
} from '../utils'
import {ryeHomePath} from '../restore-cache'

export function tryGetFromCache(
arch: Architecture,
version: string
): string | undefined {
core.debug(`Trying to get Rye from cache for ${version}...`)
const cachedVersions = tc.findAllVersions('rye', arch)
const cachedVersions = tc.findAllVersions(toolsCacheName, arch)
core.debug(`Cached versions: ${cachedVersions}`)
return tc.find('rye', version, arch)
const foundPath = tc.find(toolsCacheName, version, arch)
if (foundPath) {
core.info(`Found Rye in cache for ${version}`)
io.cp(foundPath, ryeHomePath, {
copySourceDirectory: true,
recursive: true
})
return ryeHomePath
}
}

export async function downloadVersion(
Expand Down
7 changes: 2 additions & 5 deletions src/restore-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const workingDirInput = core.getInput('working-directory')
export const workingDir = workingDirInput ? `/${workingDirInput}` : ''
export const venvPath = `${process.env['GITHUB_WORKSPACE']}${workingDir}/.venv`
export const ryeHomePath = resolve(`${process.env['GITHUB_WORKSPACE']}/../.rye`)
const CACHE_VERSION = '3'
const CACHE_VERSION = '4'
const cacheLocalStoragePath =
`${core.getInput('cache-local-storage-path')}` || ''
const cacheDependencyPath = `${process.env['GITHUB_WORKSPACE']}${workingDir}/requirements**.lock`
Expand All @@ -33,7 +33,7 @@ export async function restoreCache(
try {
matchedKey = cacheLocalStoragePath
? await restoreCacheLocal(cacheKey)
: await cache.restoreCache([venvPath, ryeHomePath], cacheKey)
: await cache.restoreCache([venvPath], cacheKey)
} catch (err) {
const message = (err as Error).message
core.warning(message)
Expand Down Expand Up @@ -82,8 +82,5 @@ async function restoreCacheLocal(
await cp(`${storedCache}/.venv`, venvPath, {
recursive: true
})
await cp(`${storedCache}/.rye`, ryeHomePath, {
recursive: true
})
return primaryKey
}
6 changes: 1 addition & 5 deletions src/save-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@ async function saveCache(): Promise<void> {
return
}
core.info(`Saving .venv path: ${venvPath}`)
core.info(`Saving .rye path: ${ryeHomePath}`)
cacheLocalStoragePath
? await saveCacheLocal(cacheKey)
: await cache.saveCache([venvPath, ryeHomePath], cacheKey)
: await cache.saveCache([venvPath], cacheKey)

core.info(`Cache saved with the key: ${cacheKey}`)
}
Expand All @@ -52,9 +51,6 @@ async function saveCacheLocal(cacheKey: string): Promise<void> {
await cp(venvPath, `${targetPath}/.venv`, {
recursive: true
})
await cp(ryeHomePath, `${targetPath}/.rye`, {
recursive: true
})
}

run()
Loading

0 comments on commit 720e7bf

Please sign in to comment.