Skip to content

Commit fb4aa68

Browse files
author
tomcodgen
authored
Revert "skip tests requiring auth, remove hardcoded gh install (#47)"
This reverts commit 7baab10.
1 parent ed0a61c commit fb4aa68

File tree

3 files changed

+3
-52
lines changed

3 files changed

+3
-52
lines changed

tests/conftest.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import logging
22
import os
3-
from pathlib import Path
4-
5-
import pytest
63

74
from tests.shared.codemod.models import Size
85

@@ -77,39 +74,3 @@ def pytest_configure(config):
7774
filename=f"build/logs/tests_{worker_id}.log",
7875
level=config.getini("log_file_level"),
7976
)
80-
81-
82-
def is_git_lfs_pointer(file_path: Path) -> bool:
83-
"""Check if a file is a git LFS pointer file"""
84-
try:
85-
with open(file_path) as f:
86-
first_line = f.readline().strip()
87-
return first_line == "version https://git-lfs.github.com/spec/v1"
88-
except Exception:
89-
return False
90-
91-
92-
@pytest.hookimpl(hookwrapper=True)
93-
def pytest_runtest_makereport(item, call):
94-
outcome = yield
95-
report = outcome.get_result()
96-
97-
if report.when == "call" and report.failed:
98-
if "NodeJS or npm is not installed" in str(report.longrepr):
99-
pytest.skip("Test requires NodeJS and npm to be installed")
100-
101-
102-
@pytest.fixture(autouse=True)
103-
def skip_lfs_tests(request):
104-
"""Skip tests that depend on git LFS files if they haven't been pulled"""
105-
# Get the test module path
106-
test_path = Path(request.module.__file__)
107-
108-
# Only run for integration tests
109-
if not str(test_path).startswith(str(Path.cwd() / "tests" / "integration")):
110-
return
111-
112-
# Get the expected diff path from the test's expected fixture
113-
expected = request.getfixturevalue("expected")
114-
if isinstance(expected, Path) and is_git_lfs_pointer(expected):
115-
pytest.skip(f"Test requires git LFS file {expected} which hasn't been pulled")

tests/integration/codemod/conftest.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,6 @@ def token(request):
141141
def op(repo: Repo, token: str | None) -> YieldFixture[LocalRepoOperator]:
142142
with filelock.FileLock(BASE_TMP_DIR / "locks" / repo.name):
143143
op = repo.to_op(repo.name, token)
144-
if isinstance(op, tuple):
145-
# This means we got (None, error_message)
146-
_, msg = op
147-
pytest.skip(msg or "Could not create repo operator")
148144
yield op
149145

150146

tests/shared/codemod/models.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,17 @@ class Repo(BaseModel):
6060
def from_json(cls, json_str: str) -> "Repo":
6161
return cls.model_validate(json.loads(json_str))
6262

63-
def to_op(self, name: str, token: str | None) -> LocalRepoOperator | tuple[None, str | None]:
63+
def to_op(self, name: str, token: str | None) -> LocalRepoOperator:
6464
base_path = BASE_TMP_DIR / ("extra_repos" if self.extra_repo else "oss_repos") / name
6565
base_path.mkdir(exist_ok=True, parents=True)
6666
url = self.url
6767
if token:
6868
url = url.replace("://", f"://{token}@")
6969
elif self.repo_id is not None:
70-
# TODO: this is a very messy hack to check whether we should prompt the user for auth
71-
# if REPO_ID_TO_URL is not set, we probably don't need auth. this is assuming that for
72-
# OSS repos, we don't need to pull any private repos.
73-
if not REPO_ID_TO_URL:
74-
return (None, "Could not create repo operator - skipping test")
75-
70+
print("Setting up auth using the github cli")
7671
if not which("gh"):
77-
return (None, "GitHub CLI (gh) is not installed. Please install it first. Skipping test.")
72+
os.system("brew install gh")
7873
if '[credential "https://github.codegen.app"]' not in (Path.home() / ".gitconfig").read_text():
79-
print("Setting up auth using the github cli")
8074
os.system("gh auth login -h github.codegen.app")
8175
os.system("gh auth setup-git -h github.codegen.app")
8276
return LocalRepoOperator.create_from_commit(str(base_path), self.default_branch, self.commit, url)

0 commit comments

Comments
 (0)