E521 perf(test): optimize git checkouts in pypi tests by baszalmstra · Pull Request #5035 · prefix-dev/pixi · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@baszalmstra
Copy link
Contributor

Description

Optimizes the git PyPI update tests by replacing network-dependent GitHub clones with a local git fixture. The tests previously took 11-15 seconds each due to cloning from GitHub. Now they complete in ~4-5 seconds using a local fixture.

Changes:

  • Add GitRepoFixture helper that creates temporary git repositories from versioned fixture directories (e.g., 001_v0.1.0/, 002_v0.2.0/)
  • Store fixture files in tests/data/git-fixtures/minimal-pypi-package/ without embedded .git directory
  • Use no_install mode since these tests only verify lock file contents, not package installation
  • Use cross-platform URL handling with url::Url::from_directory_path() for Windows compatibility

Before: ~39 seconds total (3 tests × ~13s each, hitting GitHub)
After: ~14 seconds total (3 tests × ~4.5s each, local only)

How Has This Been Tested?

cargo nextest run -p pixi test_update_conda_package_doesnt_update_git_pypi test_update_git_pypi_when_requested

All 3 tests pass:

  • test_update_conda_package_doesnt_update_git_pypi: 5.1s
  • test_update_conda_package_doesnt_update_git_pypi_pinned: 4.3s
  • test_update_git_pypi_when_requested: 4.7s

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.

Tools: Claude Code

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added sufficient tests to cover my changes.

Replace GitHub-based git dependency tests with a local git fixture
that's dynamically created at test time. This eliminates network
dependency and significantly improves test performance.

Changes:
- Add GitRepoFixture helper that creates git repos from versioned
  fixture directories (001_v0.1.0, 002_v0.2.0, etc.)
- Add fixture files in tests/data/git-fixtures/minimal-pypi-package/
- Update tests to use GitRepoFixture with dynamic commit hashes
- Remove explicit with_no_install(false) calls since tests only
  verify lock file contents

Performance: ~39s -> ~5s (90% faster)
- Extract GitRepoFixture to git_fixture.rs for better organization
- Store all commit hashes in a Vec instead of just first/latest
- Add first_commit() and latest_commit() helper methods
- Update tests to use method calls and pass fixture name
Copy link
Contributor
@Hofer-Julian Hofer-Julian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great.

I had two comments, feel free to ignore and merge if you disagree

Co-authored-by: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com>
@baszalmstra baszalmstra enabled auto-merge (squash) December 3, 2025 13:35
@baszalmstra baszalmstra merged commit 505b18c into prefix-dev:main Dec 3, 2025
37 of 38 checks passed
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

0