actions/checkout@v2 breaks on a (self-hosted runner, repository) pair with submodules; no way to revert
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 8.9k
- Forks
- 2.8k
- PR merge metrics
- No merged PRs in 30d
Description
How to reproduce:
- Spin off a self-hosted GitHub Actions runner. This is important because for reasons I do not understand or accept (to put it mildly) self-hosted runners are fully stateful and do not clean up in any ways between runs for a specific repository.
- Ensure that an arbitrary workflow containing
actions/checkout@v2succeeds. Let's say that you have it in a repositorymain-repo. - Accidentally clone another random repository
other-repoinsidemain-repo, and thengit add . && git commit -m"" && git push, effectively addingother-repoas a submodule tomain-repo. - Ensure that the workflow runs on push the first time only.
- Re-run. Ensure that it fails like this (here
labs-yeputonsismain-repo, andlabsis theother-repothat was accidentally add as a submodule):
Run actions/checkout@v2
with:
repository: hse-spb-2020-cpp/labs-yeputons
token: ***
ssh-strict: true
persist-credentials: true
clean: true
fetch-depth: 1
lfs: false
submodules: false
Syncing repository: hse-spb-2020-cpp/labs-yeputons
Getting Git version info
Working directory is '/home/platypus/git/actions-runner/_work/labs-yeputons/labs-yeputons'
/usr/bin/git version
git version 2.25.1
/usr/bin/git config --local --get remote.origin.url
https://github.com/hse-spb-2020-cpp/labs-yeputons
Removing previously created refs, to avoid conflicts
/usr/bin/git rev-parse --symbolic-full-name --verify --quiet HEAD
refs/heads/lab03-list-heap
/usr/bin/git checkout --detach
HEAD is now at d5cced7 break everything by adding submodule
/usr/bin/git rev-parse --symbolic-full-name --branches
refs/heads/lab03-list-heap
/usr/bin/git branch --delete --force lab03-list-heap
Deleted branch lab03-list-heap (was d5cced7).
/usr/bin/git rev-parse --symbolic-full-name --remotes=origin
refs/remotes/origin/lab03-list-heap
Cleaning the repository
/usr/bin/git clean -ffdx
/usr/bin/git reset --hard HEAD
HEAD is now at d5cced7 break everything by adding submodule
Disabling automatic garbage collection
/usr/bin/git config --local gc.auto 0
Setting up auth
/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
Error: fatal: No url found for submodule path 'labs' in .gitmodules
Error: The process '/usr/bin/git' failed with exit code 128
So, after the first workflow run the working directory is forever contaminated and all subsequent builds break even if we reset branch to the previous state. The only way to fix this is to either manually clean up working directory on each affected worker, or to add an extra step to nuke repository before checking it out from scratch.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the actions/checkout@v2 checkout and cleanup flow, focusing on the git submodule command that fails when a stale working directory contains a submodule missing from .gitmodules. Reproduce the documented self-hosted runner sequence, then verify that rerunning checkout succeeds after the repository state is reset.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, github-actions, typescript
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100