Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH#354 Avoid auth configuration for submodules when settings.submodules is false #424

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

cosimo
Copy link

@cosimo cosimo commented Jan 13, 2021

This patch appears to solve the problems detailed in #354 and possibly #385.
The question is: is this the correct way to solve the problem? Not sure.

The conditions to reproduce the problem are the following:

  • use self-hosted github runners (in our case within docker containers, I have no idea if that's a general way to do things)
  • have a private (org-wide) shared actions repository in addition to marketplace actions like actions/checkout, etc...
  • use the workaround detailed in https://github.community/t/github-action-action-in-private-repository/16063/43 to checkout a private org-wide actions, thus using two actions/checkout@v2 steps, one for the main project and one for the private shared actions repository.

Something happens in the "Setting up auth" stage: the additional directory used for the private shared actions repository checkout within the existing project checkout (whatever that directory is called), is interpreted as a submodule (?) when running the auth helper removeGitConfig() and this results in the following error messages:

/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 '.github/my-org-github-actions' in .gitmodules
  Error: The process '/usr/bin/git' failed with exit code 128

Note that no repository involved has submodules here.

An alternative solution that seems to work is manual removal of the private actions repository checkout directory of the entire project checkout.

UPDATE:
I see now that the git index is being updated with the shared actions checkout directory, even though I don't think I have done that explicitly.

Here's most of the failing checkout messages:

  /usr/bin/git rev-parse --symbolic-full-name --verify --quiet HEAD
  refs/heads/main
  /usr/bin/git checkout --detach
  HEAD is now at 090f36f <Description of commit here>
  D	.github/my-org-github-actions                                              <--- *** THIS ***
  /usr/bin/git rev-parse --symbolic-full-name --branches
  refs/heads/main
  /usr/bin/git branch --delete --force main
  Deleted branch main (was 090f36f).
  /usr/bin/git rev-parse --symbolic-full-name --remotes=origin
  refs/remotes/origin/main
Cleaning the repository
  /usr/bin/git clean -ffdx
  /usr/bin/git reset --hard HEAD
  HEAD is now at 090f36f <Description of commit here>
Disabling automatic garbage collection
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 '.github/my-org-github-actions' in .gitmodules
  Error: The process '/usr/bin/git' failed with exit code 128

This should help with actions#354.
The problem is that I have no idea whether such auth submodules configuration
is required even when settings.submodules is false.
Error: Unstaged changes detected. Locally try running: git clean -ffdx && npm ci && npm run format && npm run build
Error: Process completed with exit code 1.
@cosimo
Copy link
Author

cosimo commented Jan 21, 2021

We've found a good workaround, which is to simply add the directory name for the private actions checkout to .gitignore.

AndrewFasano pushed a commit to panda-re/panda that referenced this pull request Jul 1, 2021
Github Actions checkout@v2 fails to properly cleanup state in self-hosted runners
which leads to errors from prior CI runs.

actions/checkout#385

Adding the created submodule directory to gitignore should hopefully
prevent this from happening: actions/checkout#424 (comment).
jamcleod pushed a commit to panda-re/panda that referenced this pull request Jul 22, 2021
Github Actions checkout@v2 fails to properly cleanup state in self-hosted runners
which leads to errors from prior CI runs.

actions/checkout#385

Adding the created submodule directory to gitignore should hopefully
prevent this from happening: actions/checkout#424 (comment).
@jsoref
Copy link
Contributor

jsoref commented Aug 22, 2022

Please add fixes #354 to the description

@jsoref
Copy link
Contributor

jsoref commented Nov 29, 2022

I'm running with this merged into https://github.com/check-spelling/actions-checkout/releases/tag/v3 as part of check-spelling/check-spelling@407076c in order to resolve the problem that this PR fixes in repositories such as https://github.com/check-spelling/winget-cli/actions/runs/3570503478/attempts/1 -- with this applied, things are happy: https://github.com/check-spelling/winget-cli/actions/runs/3571395765/jobs/6003227245#step:2:1

I expect to leave this tag in place (and possibly pull in other things as needed) until it's merged into actions/checkout@v3 ...

@cory-miller: what would it take to move this along?

@cory-miller
Copy link
Contributor

Can you incorporate the fix from #964 to address the merge conflict? Other than that LGTM.

@jsoref
Copy link
Contributor

jsoref commented Jan 4, 2023

@cory-miller, I don't have write access to this PR, but I'm hosting a rebased version of the changes here: c12e728, you should be able to force push the branch to it.

I've moved https://github.com/check-spelling/actions-checkout/releases/tag/v3 to that commit.

kaidokert pushed a commit to kaidokert/checkout that referenced this pull request May 15, 2023
Error: Unstaged changes detected. Locally try running: git clean -ffdx && npm ci && npm run format && npm run build
Error: Process completed with exit code 1.

Rebased PR from actions#424
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants