nix-community / cache-nix-action

Cache Nix store in GitHub Actions to speed up workflows [maintainer=@deemp]
MIT License
29 stars 6 forks source link

Alternative cache backend #32

Closed jgoux closed 1 month ago

jgoux commented 3 months ago

Hello, and thanks for this super useful action!

How hard would it be to accept alternative caches that are 💯 compatible with actions/cache?

I'm currently using https://github.com/BuildJet/cache as a drop-in replacement for actions/cache (cheaper and faster) and I'd love to use it for cache-nix-action as well!

deemp commented 3 months ago

Hi!

What you suggest may be doable.

However, I don't understand where did they write the alternative (buildjet-specific) code.

Can you show me such code?

jgoux commented 3 months ago

According to their tagged releases, it seems like they're swapping the actions/cache package in their package.json: https://github.com/BuildJet/cache/blob/2bbce90d3097805dadebea12a89c47be69eb1b64/package.json#L26

Their package is: https://www.npmjs.com/package/github-actions.cache-buildjet

deemp commented 2 months ago

@jgoux, I use a custom actions/cache with code available on the actions-toolkit branch.

So, the overall complexity of adopting cache-buildjet depends on the complexity of patching cache-buildjet.

jgoux commented 2 months ago

Hey @deemp, @avallete a colleague of mine forked and patched buidjet cache here: https://github.com/BuildJet/toolkit/compare/main...avallete:buildjet-toolkit:main He also forked cache-nix-action to make it work against the patched buildjet package: https://github.com/nix-community/cache-nix-action/compare/main...avallete:cache-nix-action:main

Now I guess we could have an option to pick either actions/cache (using your fork) or buildjet/cache (using our fork)? Then according to the option, we could dynamically import the right one in cache-nix-action.

deemp commented 1 month ago

Hi, @jgoux! I decided to store deps in this repo and access them as submodules. My current progress is in #40.

I also experiment in my fork on main (link).

deemp commented 1 month ago

@jgoux, where can I see BuildJet caches? I don't see them on https://app.buildjet.com

jgoux commented 1 month ago

@jgoux, where can I see BuildJet caches? I don't see them on https://app.buildjet.com

I'm not sure we can see the cache at all. 😅 I never tried and I just looked for it and you're right it doesn't seem to have a UI for them. Maybe that's worth asking their support.

deemp commented 1 month ago

@jgoux, buildjet backend seems to work on main. However, there is an issue with cache discovery - https://github.com/nix-community/cache-nix-action/issues/41