actions / actions/checkout

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

Open
#385 9 comments 32 reactions 0 assignees View on GitHub

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:

  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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.