Ensure default branch is created before using repo in E2E tests
In gitlab-org/gitlab#428930 (comment 1631245048), the test failed due to the test creating a branch before the default branch was created. This resulted in the expected default branch not being created.
The failure can be replicated by removing :with_readme
when creating project. I think what is happening is that the git push of the branch secure-mr
is arriving before the creation of the default main
branch so secure-mr
is becoming the default branch. Looking at the project in staging there is no main:
And looking in the logs, at the time of cloning the repository is empty (this message isn't present when the test passes):
[Nov 01 2023 23:55:04 UTC (QA Tests)] DEBUG -- Git: pwd=[/tmp/d20231101-27-hu8bbl], command=[HOME="/tmp/qa-netrc-credentials/27" git clone https://gitlab-qa@staging.gitlab.com/gitlab-qa-sandbox-group-4/qa-test-2023-11-01-23-54-52-30c067e0cd4b5fc4/project-with-secure.git ./ 2>&1]
[Nov 01 2023 23:55:05 UTC (QA Tests)] DEBUG -- Git: output=[Cloning into '.'...
warning: You appear to have cloned an empty repository.], exitstatus=[0]
I think this could be a source of flakiness in other tests also, as it results in having an unexpected default branch. I chose an arbitrary run and can see this message 6 times:
~/Downloads/gitlab-qa-run-2023-10-13-03-22-33-7df37395 ······································································································· at 12:16:24
❯ grep -r . | grep "warning: You appear to have cloned an empty repository"
./gitlab-ee-qa-ddc0d7bb/qa-tests.log:warning: You appear to have cloned an empty repository.], exitstatus=[0]
./gitlab-ee-qa-ddc0d7bb/qa-tests.log:warning: You appear to have cloned an empty repository.], exitstatus=[0]
./gitlab-ee-qa-ddc0d7bb/qa-tests.log:warning: You appear to have cloned an empty repository.], exitstatus=[0]
./gitlab-ee-qa-ddc0d7bb/qa-tests.log:warning: You appear to have cloned an empty repository.], exitstatus=[0]
./gitlab-ee-qa-ddc0d7bb/qa-tests.log:warning: You appear to have cloned an empty repository.], exitstatus=[0]
./gitlab-ee-qa-ddc0d7bb/qa-tests.log:warning: You appear to have cloned an empty repository.], exitstatus=[0]
Perhaps we should wait for the default branch to be present before cloning?