Run with a worktree
benjaminjkraft opened this issue · comments
We are using this action in a large repository (with a blobless clone to keep things efficient). We've found that in many cases the slowest step is actually the git clean
! (It often takes 30-60s, whereas the actual fetch can be as fast as 15s, and the checkout 5-10s.) We don't want to skip that entirely -- who knows what mess the last job left in the repo.
What I'm thinking we should do is to have our jobs share a git directory, but run in a fresh worktree. This would make the checkout a bit slower (more files to write) but save the clean entirely (and perhaps make the fetch faster too, if it means we can share the git directory more aggressively than we can share a checkout).
So: I'd love to see this action able to run in that style! I can't imagine we're the only ones who have such needs. Is that something y'all would be open to as an option?
I'm thinking it would look something like this (although I'm very flexible on the details):
- a config option to point at the shared git directory, which if set makes the checkout a worktree of that git directory
- setup would run
git worktree add
instead ofgit clone
(TBD: what if the worktree already exists?) - cleanup would run
git worktree remove
- most other things work fine