Skip to content

actions/checkout@v2 breaks on a (self-hosted runner, repository) pair with submodules; no way to revert #385

Open
@yeputons

Description

@yeputons

How to reproduce:

  1. 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.
  2. Ensure that an arbitrary workflow containing actions/checkout@v2 succeeds. Let's say that you have it in a repository main-repo.
  3. Accidentally clone another random repository other-repo inside main-repo, and then git add . && git commit -m"" && git push, effectively adding other-repo as a submodule to main-repo.
  4. Ensure that the workflow runs on push the first time only.
  5. Re-run. Ensure that it fails like this (here labs-yeputons is main-repo, and labs is the other-repo that 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions