checkout: Newly added sparse checkout functionality is not cleaning up after itself
Thanks @dscho for contributing #1369 . We have started using it and noticed the following issue
repo-a / .github/workflows/workflow-a.yml
jobs:
job-1:
runs-on: internal-runner
- uses: actions/checkout@v3
with:
sparse-checkout: |
.github
src
running just the above works as expected. But consider another workflow in the same repo
repo-a / .github/workflows/workflow-b.yml
jobs:
job-12:
runs-on: internal-runner
- uses: actions/checkout@v3
- run: ls ./not-src
When running workflow-a, then workflow workflow-b, workflow-b will not find any files in ./not-src.
This is because workflow workflow-b runs in the same _work directory as workflow-a. On the first run of workflow-a, we have polluted the repo in a way this action doesn’t know about (and thus can’t clean up).
Notice that, even in workflow-b:
git config --list will show core.sparseCheckout true
git sparse-checkout list will still include the listed paths
and a simple
ls will only show the sparse directories for workflow-a
It seems that - similar to the auth cleanup (and other pre-run steps) this action does - we need to disable sparse checkout in the pre steps of this action
Note: this is likely only an issue for self-hosted runners which dont get the same cleaning/re-init process github-hosted runners get
Similar-ish issue to recently reported https://github.com/actions/checkout/commit/47fbe2df0ad0e27efb67a70beac3555f192b062f (for submodules, instead of sparse checkout). @megamanics
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 5
- Comments: 17 (5 by maintainers)
Links to this issue
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- actions/checkout - checkout - Gitea: Git with a cup of tea
- checkout/git-auth-helper.test.ts at jww3-minversion-v5 - checkout - Gitea: Git with a cup of tea
- checkout/git-directory-helper.test.ts at jww3-minversion-v5 - checkout - Gitea: Git with a cup of tea
- checkout/test.yml at jww3-minversion-v5 - checkout - Gitea: Git with a cup of tea
- Explicitly disable sparse checkout unless asked for (#1598) · aadec89964 - checkout - Gitea: Git with a cup of tea
Commits related to this issue
- If no `sparse-checkout` parameter is specified, disable it This should allow users to reuse existing folders when running `actions/checkout` where a previous run asked for a sparse checkout but the c... — committed to dscho/checkout by dscho 3 years ago
- Explicitly disable sparse checkout unless asked for (#1598) When a worktree is reused by actions/checkout and the first time sparse checkout was enabled, we need to ensure that the second time it is ... — committed to actions/checkout by dscho 3 years ago
We are looking to use such a workaround in the interim, but it seems this is something that should be fixed here within actions/checkout, no?
Indeed.
The working directory’s path typically contains the workflow name, e.g.
D:\a\_work\repo-a\repo-a, but not the workflow name.A solid work-around would be to scorch the worktree (if it exists), right before the
actions/checkoutstep.A more surgical work-around would be to use a shell script like this:
This is the current way to fix this issue since newer versions of git require GitHub Authentication, and I’m not usually logged in to my GitHub account on my production machines. (hello world 🙄) It would really be nice if this could be fixed.
If I add another step in the action where I run
git sparse-checkout disablethen it works.