actions / checkout

Action for checking out a repo
https://github.com/features/actions
MIT License
5.85k stars 1.73k forks source link

Broken submodule kills self-hosted runners completely #590

Open rtsisyk opened 3 years ago

rtsisyk commented 3 years ago
  1. Add a submodule which points to missing commit
  2. Run GH actions using a self-hosted runner
  3. The self-hosted runner will be completely handicapped after that - all further tasks will fail, even from different branches:
[REDACTED]
Run actions/checkout@v2
  with:
    repository: xxx/yyy
    token: ***
    ssh-strict: true
    persist-credentials: true
    clean: true
    fetch-depth: 1
    lfs: false
    submodules: false
Syncing repository: xxx/yyy
Getting Git version info
  Working directory is '/home/runner/_work/xxx/yyy'
  /usr/bin/git version
  git version 2.25.1
/usr/bin/git config --local --get remote.origin.url
https://github.com/xxx/yyy
Removing previously created refs, to avoid conflicts
  /usr/bin/git rev-parse --symbolic-full-name --verify --quiet HEAD
  HEAD
  /usr/bin/git rev-parse --symbolic-full-name --branches
  /usr/bin/git rev-parse --symbolic-full-name --remotes=origin
  refs/remotes/origin/master
Cleaning the repository
  /usr/bin/git clean -ffdx
  /usr/bin/git reset --hard HEAD
  HEAD is now at d12323f XXXXXXXX
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 'broken/submodule' in .gitmodules
  Error: The process '/usr/bin/git' failed with exit code 128

To clarify - you need to run CI on this branch ONCE and all further runs on ALL branches will fail.

aibaars commented 2 years ago

We ran into the same issue, except that instead of adding a submodule that references a non-existing commit we accidentally committed a submodule reference in a pull request without having the submodule mentioned in .gitmodules.

The problem is that the actions/checkout action stays on the broken commit forever because and gets stuck in the "setup auth" step which will fail for every subsequent job. I think this problem can be avoided by splitting the setup auth steps for the main repo from the setup auth steps of the submodules. Something like:

I think this way the action can switch away from the broken commit and recover.

gh2o commented 2 years ago

I've been working around the issue by running this command before the checkout step:

git checkout -f $(git -c user.name=x -c user.email=x@x commit-tree $(git hash-object -t tree /dev/null) < /dev/null) || :

This sets HEAD to a dummy commit before checking out the tree. The checkout step will then do a git clean which will wipe the tree before the auth step, preventing this issue from occurring again.

jsoref commented 2 years ago

This appears to be a duplicate of #385

jokreliable commented 1 year ago

this should be resolved now... with some changes to the checkout code in #964..