diff --git a/devenv/checks/test.py b/.devenv/checks/test.py similarity index 100% rename from devenv/checks/test.py rename to .devenv/checks/test.py diff --git a/.github/workflows/bootstrap.yml b/.github/workflows/bootstrap.yml index 017bcef3..fb82c496 100644 --- a/.github/workflows/bootstrap.yml +++ b/.github/workflows/bootstrap.yml @@ -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: @@ -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: diff --git a/devenv/doctor.py b/devenv/doctor.py index ee7f2e3c..d0e5e728 100644 --- a/devenv/doctor.py +++ b/devenv/doctor.py @@ -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: @@ -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"}: - 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}") diff --git a/devenv/lib/config.py b/devenv/lib/config.py index ca2f0c48..976a4799 100644 --- a/devenv/lib/config.py +++ b/devenv/lib/config.py @@ -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 diff --git a/devenv/sync.py b/devenv/sync.py index e8c5898a..60661d12 100644 --- a/devenv/sync.py +++ b/devenv/sync.py @@ -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 diff --git a/tests/doctor/test_load_checks.py b/tests/doctor/test_load_checks.py index e2b8ae85..d3a7a0af 100644 --- a/tests/doctor/test_load_checks.py +++ b/tests/doctor/test_load_checks.py @@ -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 @@ -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 @@ -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 diff --git a/tests/lib/test_venv.py b/tests/lib/test_venv.py index 12e32444..43b12707 100644 --- a/tests/lib/test_venv.py +++ b/tests/lib/test_venv.py @@ -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(