-
Notifications
You must be signed in to change notification settings - Fork 19
Use GitHub Actions cache in installCached #92
Conversation
export async function resolveVersion(crate: string): Promise<string> { | ||
const url = `https://crates.io/api/v1/crates/${crate}`; | ||
const client = new http.HttpClient( | ||
'@actions-rs (https://github.com/actions-rs/)', | ||
); | ||
|
||
const resp: any = await client.getJson(url); | ||
if (resp.result == null) { | ||
throw new Error('Unable to fetch latest crate version'); | ||
} | ||
|
||
return resp.result['crate']['newest_version']; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function was moved from actions-rs/install, since it is required in this repo to resolve the crate version, when latest
is chosen. Otherwise it would not be possible to update the cache, since the name <crate>-latest-<key>
would always be the same
try { | ||
core.info(`Caching \`${program}\` with key ${programKey}`); | ||
await cache.saveCache(paths, programKey); | ||
} catch (error) { | ||
if (error.name === cache.ValidationError.name) { | ||
throw error; | ||
} else if (error.name === cache.ReserveCacheError.name) { | ||
core.info(error.message); | ||
} else { | ||
core.info('[warning]' + error.message); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error handling code is copied from the actions/cache
repository.
.filter((item: string) => item.length > 0); | ||
} | ||
|
||
export function getInputAsArray( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is used in actions-rs/install
and copied from @actions/core
, but using the getInput
wrapper function of this package.
Friendly ping @svartalf. Not sure, if you get notified for new PRs. |
Hey @svartalf, are you still maintaining the projects in the @actions-rs org? It would be great if you could take a look here, or if you don't have time right now, let me know, so I can find another solution, apart from the actions provided here. |
Hey, @flip1995! I'm sorry for not handling this properly, I have a lot of personal stuff to handle right now, that barely leaves time to handle any other activities. |
Thanks for the reply! Personal stuff always comes first. :) |
Looks great for me, thank you! I'll try to find time in a next couple days to publish these changes to that Github packages registry, so we can proceed with |
Thanks for taking the time! |
Fixes #31
This doesn't use tool-cache, like mentioned in the issue, but rather the GitHub Actions cache directly.
For easier review, I'll comment some of the code changes.
This is the first time I'm writing TS code ever, so I'm not confident that this is the right way to do it. I think the version of this package has to be bumped after merging this PR.
This change has to be merged together with/before actions-rs/install#5
I tested this in my GHA test repo:
Workflow run where RTIM has to be build: https://github.com/flip1995/gha_playground/runs/807533735?check_suite_focus=true
Workflow run where RTIM was already chached: https://github.com/flip1995/gha_playground/runs/807555956?check_suite_focus=true