hackage-server icon indicating copy to clipboard operation
hackage-server copied to clipboard

Should the Nix CI do caching

Open andreasabel opened this issue 3 years ago • 9 comments

@peterbecich You added a Nix CI: https://github.com/haskell/hackage-server/blob/2d4f3f7fe3a5e38cb959eea139160caf273227ac/.github/workflows/nix-shell.yml#L16-L18

Does this cache between builds?

If not, would caching be possible, maybe along the lines of: https://github.com/cachix/install-nix-action#how-do-i-add-a-binary-cache

I am asking because the Nix workflow takes at least 17min each time, whereas Haskell CI can get down to <10min (probably thanks to caching). (Haskell CI takes long when it cannot restore from the cache, see e.g.: https://github.com/haskell/hackage-server/runs/6437475007?check_suite_focus=true#step:16:23)

andreasabel avatar May 18 '22 17:05 andreasabel

Good idea, working on it

It doesn't seem to produce an improvement to use https://github.com/cachix/install-nix-action#how-do-i-add-a-binary-cache

It would be an improvement to have actions/[email protected] working and cache /nix/store in Github; I'm trying to make this work: https://github.com/cachix/install-nix-action/issues/56#issuecomment-1030697681

The current errors are:

...
/usr/bin/tar: ../../../../../nix/store/01dww3kbj952cbbacnwbpzc4y3qr7clc-glibc-2.34-115-bin/sbin: 
Cannot create symlink to ‘bin’: File exists
/usr/bin/tar: ../../../../../nix/store/01dww3kbj952cbbacnwbpzc4y3qr7clc-glibc-2.34-115-bin/bin/xtrace: 
Cannot open: File exists
/usr/bin/tar: ../../../../../nix/store/01dww3kbj952cbbacnwbpzc4y3qr7clc-glibc-2.34-115-bin/bin/zic: 
Cannot open: File exists
/usr/bin/tar: ../../../../../nix/store/01dww3kbj952cbbacnwbpzc4y3qr7clc-glibc-2.34-115-bin/bin/getent: 
Cannot open: File exists
/usr/bin/tar: ../../../../../nix/store/01dww3kbj952cbbacnwbpzc4y3qr7clc-glibc-2.34-115-bin/bin/ldd: 
Cannot open: File exists
...

https://github.com/peterbecich/hackage-server/runs/6567988004?check_suite_focus=true

peterbecich avatar May 24 '22 06:05 peterbecich

As far as I can tell, the Cachix GitHub Action (https://github.com/cachix/install-nix-action) is designed to only cache on Cachix, and is not compatible with https://github.com/actions/cache

Can we set up a free Cachix account for hackage-server (https://www.cachix.org/pricing)? If you set secrets.CACHIX_SIGNING_KEY and secrets.CACHIX_AUTH_TOKEN in GitHub, then I should be able to implement this https://nix.dev/tutorials/continuous-integration-github-actions#setting-up-github-actions

peterbecich avatar May 24 '22 22:05 peterbecich

Can we set up a free Cachix account for hackage-server (cachix.org/pricing)?

I suppose yes. The conditions are:

Users have a free 5 GB limit for open source projects.

andreasabel avatar May 25 '22 07:05 andreasabel

Should be enough. i.i.r.c. the GitHub caching action indicated this needs less than three GB. (It progressed far enough to inform me of that, but nonetheless could not successfully use the cache.)

peterbecich avatar May 25 '22 08:05 peterbecich

I created a personal account on cachix.org, but when I created organization hackage-server, I am told that this isn't free (except for a 14 day trial). Maybe it makes sense for you @peterbecich to set up the account there, since you will (supposedly) maintain the nix CI? If you need more rights on hackage-server to set up the connection, @gbaz is your man.

andreasabel avatar May 27 '22 12:05 andreasabel

Does this work yet? I see cachix cache jumping into action, but the build time is still 20min: https://github.com/haskell/hackage-server/runs/6777589545?check_suite_focus=true

andreasabel avatar Jun 07 '22 16:06 andreasabel

Apparently it is not working yet, I'll try a few more things: https://github.com/haskell/hackage-server/pull/1086

peterbecich avatar Jun 26 '22 04:06 peterbecich

Note that I've granted hackage-server organization 50GB free plan, let me know if that's enough!

domenkozar avatar Aug 20 '22 12:08 domenkozar

Thank you @domenkozar , I think 50GB is more than enough

peterbecich avatar Aug 23 '22 06:08 peterbecich

I have another project https://github.com/peterbecich/halogen-chess which has a GitHub Action for a Nix build. It uses haskell.nix https://github.com/input-output-hk/haskell.nix . The build time of that GitHub Action has decreased from 3 hours down to 15 minutes by moving the project to Nix Flakes: https://github.com/peterbecich/halogen-chess/actions/workflows/nix-cabal.yml

I know that hackage-server does not use haskell.nix so it is not directly applicable, but perhaps we can move to Flakes another way.

peterbecich avatar Oct 30 '22 07:10 peterbecich

I expect this will yield an improvement: https://github.com/haskell/hackage-server/pull/1154

peterbecich avatar Jan 03 '23 22:01 peterbecich

Cachix works for the Nix Flake

...
copying path '/nix/store/fgmxd2hkkchwlh8jdgc1h1z0v0kk4yi5-optparse-applicative-0.15.1.0-doc' from 'https://hackage-server.cachix.org/'...
...

https://github.com/haskell/hackage-server/actions/runs/4411857013/jobs/7730762854

peterbecich avatar Mar 14 '23 03:03 peterbecich

down to 8 minutes, https://github.com/haskell/hackage-server/actions/runs/4550618189 I think the caching is working, closing issue

peterbecich avatar Apr 01 '23 07:04 peterbecich