Skip to content

tests: do not hard code repo paths (bug 2022618)#985

Open
zzzeid wants to merge 1 commit intomainfrom
zeid/bug-2022618-repo-mc-fix
Open

tests: do not hard code repo paths (bug 2022618)#985
zzzeid wants to merge 1 commit intomainfrom
zeid/bug-2022618-repo-mc-fix

Conversation

@zzzeid
Copy link
Contributor

@zzzeid zzzeid commented Mar 11, 2026

No description provided.

@zzzeid zzzeid requested a review from a team as a code owner March 11, 2026 17:32
@github-actions
Copy link

View this pull request in Lando to land it once approved.

Copy link
Member

@cgsheeh cgsheeh left a comment

Choose a reason for hiding this comment

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

LGTM but want to clarify if we should apply this to git_repo also.

"pull_path": str(git_repo),
"push_path": str(git_repo),
"required_permission": SCM_LEVEL_3,
"system_path": repos_dir / "git_repo",
Copy link
Member

Choose a reason for hiding this comment

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

Looks like we also hard-code the repo name as git_repo in the git_repo fixture, should this be resolved there as well? Seems that the pull_path and push_path will be .../git_repo as a result.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes actually working on that now, we likely need to randomize the actual (remote) git_repo path.

@zzzeid zzzeid changed the title lando.conftest: do not hard code system_path (bug 2022618) tests: do not hard code repo paths (bug 2022618) Mar 11, 2026
@zzzeid zzzeid marked this pull request as draft March 11, 2026 19:40
@zzzeid zzzeid force-pushed the zeid/bug-2022618-repo-mc-fix branch from e2c4cbb to f5ea52b Compare March 12, 2026 18:44
@zzzeid zzzeid force-pushed the zeid/bug-2022618-repo-mc-fix branch from f5ea52b to 457e3c1 Compare March 19, 2026 19:12
@zzzeid zzzeid marked this pull request as ready for review March 19, 2026 20:02
revision_id = revision_id or (last_revision.id + 1 if last_revision else 1)
revision = Revision.objects.create(
revision_id=revision_id,
diff_id=revision_id * 10,
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a comment explaining why we multiply by 10?

Why have we split out revision_id from number? Any reason they couldn't stay as a single kwarg, and if a user wants to use a non-standard revision/patch, they can just pass patch in the caller?

epoch = "1970-01-01T00:00:00"
monkeypatch.setenv("GIT_COMMITTER_DATE", epoch)

repo_dir = tmp_path / str(uuid.uuid4())
Copy link
Member

Choose a reason for hiding this comment

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

Could we have something more deterministic than a UUID here? This would be easier when debugging failing tests and looking in /tmp.

Maybe just a monotonically incrementing number. We'd risk more collisions, but it would be caught by the code just below (or, alternatively, we could keep a static variable somewhere to keep count of how many repos were created).

Comment on lines +1257 to +1259
def make_commit_maps(make_git_repo: Callable) -> Callable:
def _make_commit_maps(git_repo=None):
git_repo = git_repo or make_git_repo()
Copy link
Member

Choose a reason for hiding this comment

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

Should the make_git_repo fixture be one of the arguments of make_commit_maps now?

landing_worker_instance: Callable,
make_landing_job: Callable,
commit_maps: list[CommitMap],
make_commit_maps: Callable,
Copy link
Member

Choose a reason for hiding this comment

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

+1 on the naming. We have been a bit wobbly (or maybe just me?) on naming fixtures that return objects vs. those that return Callables. Making the latter start with active verbs make it much clearer!

Comment on lines +20 to +22
@pytest.fixture
def git_repo(make_git_repo: Callable) -> Path:
return make_git_repo()
Copy link
Member

Choose a reason for hiding this comment

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

We could leave this one in conftest? Unless the intent is to fence off and deprecate its use?

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