Skip to content
This repository was archived by the owner on Oct 13, 2023. It is now read-only.

Conversation

flip1995
Copy link
Contributor

@flip1995 flip1995 commented Jun 25, 2020

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

Comment on lines +8 to +20
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'];
}
Copy link
Contributor Author

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

Comment on lines +96 to +107
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);
}
}
Copy link
Contributor Author

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(
Copy link
Contributor Author

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.

@flip1995
Copy link
Contributor Author

flip1995 commented Jul 6, 2020

Friendly ping @svartalf. Not sure, if you get notified for new PRs.

@flip1995
Copy link
Contributor Author

flip1995 commented Aug 3, 2020

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.

@svartalf
Copy link
Member

svartalf commented Aug 4, 2020

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.
I'll try my best to review your PR today!

@flip1995
Copy link
Contributor Author

flip1995 commented Aug 4, 2020

Thanks for the reply! Personal stuff always comes first. :)

@svartalf svartalf merged commit b76c0bf into actions-rs:master Aug 5, 2020
@svartalf
Copy link
Member

svartalf commented Aug 5, 2020

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 actions-rs/install PR then

@flip1995
Copy link
Contributor Author

flip1995 commented Aug 5, 2020

Thanks for taking the time!

@flip1995 flip1995 deleted the install_cached_pr branch August 5, 2020 15:49
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Use @actions/tool-cache in Cargo.installCached

2 participants