CI: setup-test-env job takes too much time if a tested commit reference is absent in the gitlab-test repository
### Summary During development GitLab developers may add commits to the [gitlab-org/gitlab-test](https://gitlab.com/gitlab-org/gitlab-test) repository (who has appropriate permissions) and add appropriate reference into [spec/support/helpers/test_env.rb](spec/support/helpers/test_env.rb) file. A community developer may fork [gitlab-org/gitlab-test](https://gitlab.com/gitlab-org/gitlab-test) repository and add new commits there but if he will forget to up-to-date its fork with the [gitlab-org/gitlab-test](https://gitlab.com/gitlab-org/gitlab-test) then CI step `setup-test-env` goes into an infinite loop whith the messages like ``` ==> Setting up Gitaly... Gitaly setup in 0.000163683 seconds... remote: warning: refname '1942eed5cc108b19c7405106e81fa96125d0be22' is ambiguous. remote: Git normally never creates a ref that ends with 40 hex characters remote: because it will be ignored when you just specify 40-hex. These refs remote: may be created by mistake. For example, remote: remote: git checkout -b $br $(git rev-parse ...) remote: remote: where "$br" is somehow empty and a 40-hex ref is created. Please remote: examine these refs and maybe delete them. Turn this message off by remote: running "git config advice.objectNameWarning false" fatal: update refs/heads/2-mb-file: invalid <newvalue>: bf12d25 fatal: update refs/heads/2-mb-file: invalid <newvalue>: bf12d25 ... ``` Until ``` /usr/local/lib/ruby/2.4.0/fileutils.rb:1438:in `join': stack level too deep (SystemStackError) from /usr/local/lib/ruby/2.4.0/fileutils.rb:1126:in `path' from /usr/local/lib/ruby/2.4.0/fileutils.rb:1341:in `block in remove_file' from /usr/local/lib/ruby/2.4.0/fileutils.rb:1346:in `platform_support' from /usr/local/lib/ruby/2.4.0/fileutils.rb:1340:in `remove_file' from /usr/local/lib/ruby/2.4.0/fileutils.rb:1329:in `remove' from /usr/local/lib/ruby/2.4.0/fileutils.rb:689:in `block in remove_entry' from /usr/local/lib/ruby/2.4.0/fileutils.rb:1379:in `block (2 levels) in postorder_traverse' from /usr/local/lib/ruby/2.4.0/fileutils.rb:1379:in `block (2 levels) in postorder_traverse' ... 10272 levels... from /builds/ashumkin/gitlab-ce/spec/support/helpers/test_env.rb:231:in `setup_repo' from /builds/ashumkin/gitlab-ce/spec/support/helpers/test_env.rb:213:in `setup_factory_repo' from /builds/ashumkin/gitlab-ce/spec/support/helpers/test_env.rb:93:in `init' from -e:1:in `<main>' ``` So, `setup-test-env` step takes too much time to execute. ### Steps to reproduce 1. Add an inexistent reference to [spec/support/helpers/test_env.rb](spec/support/helpers/test_env.rb) file. 2. Run `rspec spec/lib/gitlab/git/commit_spec.rb`, for example. Tests will be run for a long time and finally will fail with the error ``` /usr/local/lib/ruby/2.4.0/fileutils.rb:1438:in `join': stack level too deep (SystemStackError) from /usr/local/lib/ruby/2.4.0/fileutils.rb:1126:in `path' from /usr/local/lib/ruby/2.4.0/fileutils.rb:1341:in `block in remove_file' from /usr/local/lib/ruby/2.4.0/fileutils.rb:1346:in `platform_support' from /usr/local/lib/ruby/2.4.0/fileutils.rb:1340:in `remove_file' from /usr/local/lib/ruby/2.4.0/fileutils.rb:1329:in `remove' from /usr/local/lib/ruby/2.4.0/fileutils.rb:689:in `block in remove_entry' from /usr/local/lib/ruby/2.4.0/fileutils.rb:1379:in `block (2 levels) in postorder_traverse' from /usr/local/lib/ruby/2.4.0/fileutils.rb:1379:in `block (2 levels) in postorder_traverse' ... 10272 levels... from /builds/ashumkin/gitlab-ce/spec/support/helpers/test_env.rb:231:in `setup_repo' from /builds/ashumkin/gitlab-ce/spec/support/helpers/test_env.rb:213:in `setup_factory_repo' from /builds/ashumkin/gitlab-ce/spec/support/helpers/test_env.rb:93:in `init' from -e:1:in `<main>' ``` ### Example Project Pipeline https://gitlab.com/ashumkin/gitlab-ce/pipelines/27297315. Job https://gitlab.com/ashumkin/gitlab-ce/-/jobs/87256498 ### What is the current *bug* behavior? `setup-test-env` takes too much time if a tested commit reference is absent in the [gitlab-org/gitlab-test](https://gitlab.com/gitlab-org/gitlab-test) repository ### What is the expected *correct* behavior? `setup-test-env` takes a reasonable time (with failed tests?) regardless of consistency of [gitlab-org/gitlab-test](https://gitlab.com/gitlab-org/gitlab-test) repository
issue