Skip to content
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

ref: reporoot/devenv to reporoot/.devenv #101

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
File renamed without changes.
6 changes: 3 additions & 3 deletions .github/workflows/bootstrap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-22.04
timeout-minutes: 60
env:
SENTRY_BRANCH: master
SENTRY_BRANCH: upgrade-devenv
SNTY_DEVENV_BRANCH:
"${{ github.event.pull_request && github.head_ref || github.ref_name }}"
steps:
Expand All @@ -42,11 +42,11 @@ jobs:
bootstrap-macos-13:
# This job takes half an hour and costs a lot of money.
# Let's just run on main commits.
if: ${{ github.ref == 'refs/heads/main' }}
# if: ${{ github.ref == 'refs/heads/main' }}
runs-on: macos-13
timeout-minutes: 60
env:
SENTRY_BRANCH: master
SENTRY_BRANCH: upgrade-devenv
SNTY_DEVENV_BRANCH:
"${{ github.event.pull_request && github.head_ref || github.ref_name }}"
steps:
Expand Down
17 changes: 5 additions & 12 deletions devenv/doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,13 @@ def __init__(self, module: ModuleType):
super().__init__()


def load_checks(context: Dict[str, str], match_tags: set[str]) -> List[Check]:
def load_checks(from_dir: str, match_tags: set[str]) -> List[Check]:
"""
Load all checks from the checks directory.
Optionally filter by tags.
Load checks from a dir and optionally filter by tags.
If a check doesn't have the required attributes, skip it.
"""
checks: list[Check] = []
for module_finder, module_name, _ in walk_packages(
(f'{context["reporoot"]}/devenv/checks',)
):
for module_finder, module_name, _ in walk_packages((from_dir,)):
module_spec = module_finder.find_spec(module_name, None)

# it "should be" impossible to fail these:
Expand Down Expand Up @@ -173,12 +170,8 @@ def main(context: Dict[str, str], argv: Sequence[str] | None = None) -> int:

match_tags: set[str] = set(args.tag if args.tag else ())

repo = context["repo"]
if repo not in {"sentry", "getsentry", "devenv"}:
Copy link
Member Author

Choose a reason for hiding this comment

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

repo not supported yet is outdated, i've been getting rid of it

last one is removed in #77

print(f"repo {repo} not supported yet!")
return 1

checks = load_checks(context, match_tags)
checks_dir = f'{context["reporoot"]}/.devenv/checks'
checks = load_checks(checks_dir, match_tags)

if not checks:
print(f"No checks found for tags: {args.tag}")
Expand Down
2 changes: 1 addition & 1 deletion devenv/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@functools.lru_cache(maxsize=None)
def get_repo(reporoot: str) -> configparser.ConfigParser:
config = configparser.ConfigParser()
config.read(f"{reporoot}/devenv/config.ini")
config.read(f"{reporoot}/.devenv/config.ini")
return config


Expand Down
6 changes: 3 additions & 3 deletions devenv/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
def main(context: Dict[str, str], argv: Sequence[str] | None = None) -> int:
reporoot = context["reporoot"]

if not os.path.exists(f"{reporoot}/devenv/sync.py"):
print(f"{reporoot}/devenv/sync.py not found!")
if not os.path.exists(f"{reporoot}/.devenv/sync.py"):
print(f"{reporoot}/.devenv/sync.py not found!")
return 1

spec = importlib.util.spec_from_file_location(
"sync", f"{reporoot}/devenv/sync.py"
"sync", f"{reporoot}/.devenv/sync.py"
)
module = importlib.util.module_from_spec(spec) # type: ignore
spec.loader.exec_module(module) # type: ignore
Expand Down
22 changes: 8 additions & 14 deletions tests/doctor/test_load_checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

from devenv import doctor

here = os.path.join(os.path.dirname(__file__))


def test_load_checks_no_checks() -> None:
assert doctor.load_checks({"reporoot": "not a real path"}, set()) == []
assert doctor.load_checks(here, set()) == []


def test_load_checks_test_checks(capsys: pytest.CaptureFixture[str]) -> None:
loaded_checks = doctor.load_checks(
{"reporoot": os.path.join(os.path.dirname(__file__))}, set()
)
loaded_checks = doctor.load_checks(f"{here}/devenv/checks", set())
loaded_check_names = [check.name for check in loaded_checks]
assert len(loaded_check_names) == 5
assert "passing check" in loaded_check_names
Expand All @@ -34,18 +34,14 @@ def test_load_checks_test_checks(capsys: pytest.CaptureFixture[str]) -> None:


def test_load_checks_only_passing_tag() -> None:
loaded_checks = doctor.load_checks(
{"reporoot": os.path.join(os.path.dirname(__file__))}, {"pass"}
)
loaded_checks = doctor.load_checks(f"{here}/devenv/checks", {"pass"})
loaded_check_names = [check.name for check in loaded_checks]
assert len(loaded_check_names) == 1
assert "passing check" in loaded_check_names


def test_load_checks_only_failing_tag() -> None:
loaded_checks = doctor.load_checks(
{"reporoot": os.path.join(os.path.dirname(__file__))}, {"fail"}
)
loaded_checks = doctor.load_checks(f"{here}/devenv/checks", {"fail"})
loaded_check_names = [check.name for check in loaded_checks]
assert len(loaded_check_names) == 2
assert "failing check" in loaded_check_names
Expand All @@ -54,16 +50,14 @@ def test_load_checks_only_failing_tag() -> None:

def test_load_checks_passing_and_failing_tag() -> None:
loaded_checks = doctor.load_checks(
{"reporoot": os.path.join(os.path.dirname(__file__))}, {"pass", "fail"}
f"{here}/devenv/checks", {"pass", "fail"}
)
loaded_check_names = [check.name for check in loaded_checks]
assert len(loaded_check_names) == 0


def test_load_checks_test_tag() -> None:
loaded_checks = doctor.load_checks(
{"reporoot": os.path.join(os.path.dirname(__file__))}, {"test"}
)
loaded_checks = doctor.load_checks(f"{here}/devenv/checks", {"test"})
loaded_check_names = [check.name for check in loaded_checks]
assert len(loaded_check_names) == 5
assert "passing check" in loaded_check_names
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

def test_get_ensure(tmp_path: pathlib.Path) -> None:
reporoot = f"{tmp_path}/ops"
os.makedirs(f"{reporoot}/devenv")
with open(f"{reporoot}/devenv/config.ini", "w") as f:
os.makedirs(f"{reporoot}/.devenv")
with open(f"{reporoot}/.devenv/config.ini", "w") as f:
f.write(mock_config)

venv_dir, python_version, requirements, editable_paths, bins = venv.get(
Expand Down
Loading