Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 3, 2025

What are you trying to accomplish?

The test "creates a git credentials store that contains private git credentials" intermittently fails, expecting private.com credentials but receiving github.com credentials instead.

The issue stems from with_git_configured writing all git credential stores to a static git.store file in Dir.pwd, while the gitconfig uses a random suffix. When tests run concurrently or sequentially, they overwrite each other's credential files, causing flakes.

Anything you want to highlight for special attention from reviewers?

Changes made:

  • Add unique random suffix to git.store filename (e.g., XXXXXXXXXXXXXXXX.git.store)
  • Pass git_store_path parameter through configure_git_to_use_https_with_credentials
  • Clean up git.store file in ensure block alongside gitconfig cleanup
  • Update test expectations to use mocked random suffix and allow FileUtils cleanup of both files

This mirrors the existing pattern for gitconfig files, ensuring test isolation.

How will you know you've accomplished your goal?

  • All 73 tests in shared_helpers_spec.rb pass
  • 20 parallel test runs with varying seeds show no flakes
  • No leftover git.store files remain after test execution

Checklist

  • I have run the complete test suite to ensure all tests and linters pass.
  • I have thoroughly tested my code changes to ensure they work as expected, including adding additional tests for new functionality.
  • I have written clear and descriptive commit messages.
  • I have provided a detailed description of the changes in the pull request, including the problem it addresses, how it fixes the problem, and any relevant details about the implementation.
  • I have ensured that the code is well-documented and easy to understand.
Original prompt

We get this flake intermittently in the common specs, can you figure out why it's happening and fix it?

Failures:

  1) Dependabot::SharedHelpers.with_git_configured when providing private git_source credentials creates a git credentials store that contains private git credentials
     Failure/Error: expect(configured_git_credentials).to eq("***private.com\n")

       expected: "***private.com\n"
            got: "***github.com\n"

       (compared using ==)

       Diff:
       @@ -1 +1 @@
       -***private.com
       +***github.com
     # ./spec/dependabot/shared_helpers_spec.rb:749:in 'block (4 levels) in <top (required)>'
     # ./spec/spec_helper.rb:77:in 'block (2 levels) in <top (required)>'
     # /home/dependabot/dependabot-updater/vendor/ruby/3.4.0/gems/webmock-3.25.1/lib/webmock/rspec.rb:39:in 'block (2 levels) in <top (required)>'

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Fix intermittent flake in common specs Fix race condition in git credentials test causing intermittent failures Nov 3, 2025
Copilot AI requested a review from jakecoffman November 3, 2025 18:35
Copilot finished work on behalf of jakecoffman November 3, 2025 18:35
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.

2 participants