install-action icon indicating copy to clipboard operation
install-action copied to clipboard

Merge cache-cargo-install-action

Open taiki-e opened this issue 3 years ago • 2 comments

As said in https://github.com/taiki-e/install-action/pull/54#issuecomment-1383149339, I would like to merge cache-cargo-install-action into install-action.

Ideally, I would like to merge cache-cargo-install-action into install-action, run cargo-binstall with --disable-strategies compile, and use cache-cargo-install-action when the installation fails, though...

TODO:

taiki-e avatar Feb 08 '23 05:02 taiki-e

Related: The binaries installed via cargo-binstall can also be cached. cargo-binstall by default, installs binaries to $CARGO_HOME and then updates $CARGO_HOME/.crates.toml and $CARGO_HOME/binstall/crates-v1.json.

So if you cache $CARGO_HOME/{bin, .crates.toml, binstall/crates-v1.json}, then you can also cache result of cargo-binstall if the binaries is up-to-date.

If a new version has released, then cargo-binstall will detect that and upgrade the binaries if the version_requirement is empty (default to *) or *, >=$VERSION, since cargo-binstall would always hit https://crates.io to find out the max_stable_version for the crate.

In the case of upgrade, you can detect that by checking the hash of the .crates.toml and then invalidates the cache.

NobodyXu avatar Mar 14 '23 01:03 NobodyXu

Regarding $CARGO_HOME, there's one catch though.

There's a PR in cargo-binstall to support install.root in $CARGO_HOME/config.toml https://github.com/cargo-bins/cargo-binstall/pull/884 which can overrides where the binaries are installed and manifests are updated.

NobodyXu avatar Mar 14 '23 01:03 NobodyXu