axodotdev / cargo-dist

📦 shippable application packaging
https://axodotdev.github.io/cargo-dist/
Apache License 2.0
1.32k stars 56 forks source link

add support for setting the cache to use #1119

Closed arlyon closed 3 weeks ago

arlyon commented 3 weeks ago

swatinem/rust-cache supports two caching backends; github actions and buildjet.

This just plumbs that setting through defaulting to leaving the field empty.

Gankra commented 3 weeks ago

This looks useful, could you elaborate on the usecase for toggling this setting? Are you also using buildjet runners? (I'm wondering if we can maybe just notice a custom runner with "buildjet" in the name and auto-flip the setting).

arlyon commented 3 weeks ago

Yeah, essentially. I wanted to release on arm, noticed buildjet supports it, but also saw that the cache performance for non-gh runners is pretty awful (plus the cache is twice the size and free..)

Net result should be faster cache access and better cache hits for anyone with a buildjet account

Gankra commented 3 weeks ago

If you're interested in implementing the auto-detect approach (less config is always nice), I think the relevant change is to check if this value contains a string with substring "buildjet": https://github.com/axodotdev/cargo-dist/blob/57e1712d0164aa88a757fb333d7d7b95da093fe7/cargo-dist/src/backend/ci/github.rs#L145

Gankra commented 3 weeks ago

Pardon, the value of interest is github_custom_runners, although maybe you just want to look at the resulting local_runs

https://github.com/axodotdev/cargo-dist/blob/57e1712d0164aa88a757fb333d7d7b95da093fe7/cargo-dist/src/backend/ci/github.rs#L153-L158

Gankra commented 3 weeks ago

(Happy to take the PR over if that's a pain, but this is a great idea so I super want to land some version of it)

Gankra commented 3 weeks ago

Oh neat, just realized this value can be plumbed into GithubMatrixEntry to precisely set the cache provider per-target.

Gankra commented 3 weeks ago

thanks for this again! I ended up implementing the autodetect version in #1129, should be in the next release in a day or two