checkout
checkout copied to clipboard
Add a 'clean-exclude' option (to avoid cleaning node_modules)
Currently, the checkout action will delete node_modules
with git clean -ffdx
. Since I use (mostly) persistent self-hosted runners, it's extremely inefficient to constantly be deleting and recreating node_modules
. It takes about a minute just to do the deletion in git clean
and another 3 minutes to repopulate node_modules
after that.
It would be much much faster to be able to pass the exclude flag to clean, for example:
git clean -ffdxe '/node_modules/'
# Or, more explicit...
git clean -ffdx --exclude='/node_modules/'
This could just be another argument to the action, so usage might be...
- name: Checkout
uses: actions/checkout@v3
with:
clean-exclude: /node_modules/
As further clarification, it is handy to have the git clean run, so you know the workspace matches the repo. But for some builds, we don't have control of where the build artifacts get dropped (e.g. with Unity, it produces a Library directory at the top level of the workspace). And those can be expensive to reproduce each time. So we'd like to have their deletion be controlled with a flag, like this. So we can sometimes do clean builds, and sometimes not.
Use of a cache to handle that can be expensive, since the artifacts are so large.
This can be easily done in gitlab by setting GIT_CLEAN_FLAGS to override the args passed to git clean
. But in github actions, the work around is very tedious. I have to set clean: false
on every checkout of every job, and then add another step to manually do the correct git clean. But that doesn't work without adding a 'safe.directory'. It would be so much easier if a custom clean-exclude
attribute, or env var was supported.
One way to simplify that I tried was to create a bash script action (we have others in the same repo, in the .github folder) that does the checkout and the git setup, and the clean, but all in one place. But this doesn't work, as you can't reference other actions in the same repo until you've done the checkout. So either you need a separate repo, or to do a lot of duplication.