Skip to content

CG-10450 Integration tests improvements #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Jan 28, 2025
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
22b095b
patch
Jan 24, 2025
4490142
add nicer pytest skip message
Jan 24, 2025
fd3a5a9
Merge remote-tracking branch 'origin/develop' into tom-cg-10450-enabl…
Jan 24, 2025
2d10ce4
skip
Jan 25, 2025
c109e83
crude fix; skip when no node/npm
Jan 25, 2025
5a2d5e8
Merge remote-tracking branch 'origin/develop' into tom-cg-10450-enabl…
Jan 27, 2025
4cb549f
fix: url for graph widget (#114)
rushilpatel0 Jan 27, 2025
cb99fc1
Adds missing return types, Styling modifications (CG-10500, CG-10499,…
jemeza-codegen Jan 27, 2025
a47158b
Revert "skip tests requiring auth, remove hardcoded gh install" (#115)
Jan 27, 2025
62f01bd
Remove gs from codegen pkg (#118)
caroljung-cg Jan 27, 2025
bd0d9f2
Deprecate default_branch from LocalRepoOperator (#116)
Edward-Codegen Jan 27, 2025
737ce38
Update channel (#120)
eacodegen Jan 27, 2025
193c4d7
Move remote git tests into tests/integration (#122)
caroljung-cg Jan 27, 2025
bca3332
Tawsif add support for codebase exports (#117)
tawsifkamal Jan 27, 2025
89f65a5
update graph widget url (#123)
rushilpatel0 Jan 27, 2025
f25415f
Rpatel/update graph widget url (#126)
rushilpatel0 Jan 27, 2025
bdb3c7c
Update pyproject.toml metadata (#127)
eacodegen Jan 27, 2025
23d702b
feat: `codegen init` creates + perists .codegen/.venv (#124)
jayhack Jan 27, 2025
317c7ea
Update README.md (#131)
joelaguero Jan 27, 2025
c04b0f4
Make codebase.reset only reset changes made by the sdk (#74)
eacodegen Jan 27, 2025
bfc77ee
Automatically determine base_path and throw error on non-git repos (#…
Edward-Codegen Jan 27, 2025
a97f64c
Fix link (#132)
eacodegen Jan 27, 2025
fffe207
Fix gradio (#130)
eacodegen Jan 27, 2025
878abc7
Update README.md (#134)
joelaguero Jan 27, 2025
f0dab50
feat: enables `codegen create -d` (#135)
jayhack Jan 28, 2025
7b4e8cc
chore: CG-10545 remove codebase.commit warning (#136)
christinewangcw Jan 28, 2025
41da296
Add posthog and override (#140)
eacodegen Jan 28, 2025
5832f60
Sync sandbox runner code (#141)
caroljung-cg Jan 28, 2025
e055880
Documentation for set_session_options (#137)
kopekC Jan 28, 2025
f4af64b
New Codebase Init Flow (#139)
Edward-Codegen Jan 28, 2025
8b2f0f3
chore(deps): update dependency @types/node to v22.12.0 (#142)
renovate[bot] Jan 28, 2025
49bf424
skip tests that dont use expected fixture
Jan 28, 2025
dea4e45
Merge branch 'develop' into tom-cg-10450-enable-unauthenticated-codem…
Jan 28, 2025
9a38cc7
ruff ruff
Jan 28, 2025
d463168
satisfy precommit
Jan 28, 2025
7cd5033
Merge branch 'develop' into tom-cg-10450-enable-unauthenticated-codem…
Jan 28, 2025
08eefbb
address comments
Jan 28, 2025
daa0205
Merge branch 'develop' into tom-cg-10450-enable-unauthenticated-codem…
Jan 28, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import logging
import os
from pathlib import Path

import pytest

from tests.shared.codemod.models import Size

Expand Down Expand Up @@ -74,3 +77,45 @@ def pytest_configure(config):
filename=f"build/logs/tests_{worker_id}.log",
level=config.getini("log_file_level"),
)


def is_git_lfs_pointer(file_path: Path) -> bool:
"""Check if a file is a git LFS pointer file"""
try:
with open(file_path) as f:
first_line = f.readline().strip()
return first_line == "version https://git-lfs.github.com/spec/v1"
except Exception:
return False


@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
report = outcome.get_result()

if report.when == "call" and report.failed:
if "NodeJS or npm is not installed" in str(report.longrepr):
raise RuntimeError("This test requires NodeJS and npm to be installed. Please install them before running the tests.")


@pytest.fixture(autouse=True)
def skip_lfs_tests(request):
"""Skip tests that depend on git LFS files if they haven't been pulled"""
# Lets not run if we are in CI
if os.getenv("CI") == "true" or os.getenv("CIRCLECI") == "true":
return

# Get the test module path
test_path = Path(request.module.__file__)

# Only run for integration tests
if not str(test_path).startswith(str(Path.cwd() / "tests" / "integration")):
return

try:
expected = request.getfixturevalue("expected")
if isinstance(expected, Path) and is_git_lfs_pointer(expected):
pytest.skip(f"Test requires git LFS file {expected} which hasn't been pulled")
except Exception:
pass