taiki-e / install-action

GitHub Action for installing development tools (mainly from GitHub Releases).
Apache License 2.0
256 stars 30 forks source link

Merge cache-cargo-install-action #66

Open taiki-e opened 1 year ago

taiki-e commented 1 year ago

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:

NobodyXu commented 1 year ago

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 commented 1 year ago

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.