diff options
author | zaverden <zaverden@yandex-team.com> | 2024-04-22 08:48:33 +0300 |
---|---|---|
committer | zaverden <zaverden@yandex-team.com> | 2024-04-22 08:58:08 +0300 |
commit | 1d77668624e2483b5664ae4999537d7086be576b (patch) | |
tree | c49b3ba06de3f542cd62a7eb4b0a19eb8ba578ac /build/plugins/lib/nots/package_manager | |
parent | 55f0e9fe0e7fe7ccba9365d822352dec9cf5332c (diff) | |
download | ydb-1d77668624e2483b5664ae4999537d7086be576b.tar.gz |
feat(conf): support prebuilder v1 in conf validation (with fallback to v0 logic)
Integration is added in backward-compatible manner with `v0.x.x`
1f45f7b3235314fb1ee8d2051ff6d592c95813f0
Diffstat (limited to 'build/plugins/lib/nots/package_manager')
3 files changed, 39 insertions, 0 deletions
diff --git a/build/plugins/lib/nots/package_manager/base/lockfile.py b/build/plugins/lib/nots/package_manager/base/lockfile.py index b6b9952602..fde0ee2b49 100644 --- a/build/plugins/lib/nots/package_manager/base/lockfile.py +++ b/build/plugins/lib/nots/package_manager/base/lockfile.py @@ -74,3 +74,7 @@ class BaseLockfile(object): @abstractmethod def validate_has_addons_flags(self): pass + + @abstractmethod + def get_requires_build_packages(self): + pass diff --git a/build/plugins/lib/nots/package_manager/base/package_json.py b/build/plugins/lib/nots/package_manager/base/package_json.py index 2438511800..449b386556 100644 --- a/build/plugins/lib/nots/package_manager/base/package_json.py +++ b/build/plugins/lib/nots/package_manager/base/package_json.py @@ -222,3 +222,28 @@ class PackageJson(object): """ ws_map = self.get_workspace_map() return {pj.get_name(): path for path, (pj, _) in ws_map.items()} + + def validate_prebuilds(self, requires_build_packages: list[str]): + pnpm_overrides: dict[str, str] = self.data.get("pnpm", {}).get("overrides", {}) + use_prebuild_flags: dict[str, bool] = self.data.get("@yatool/prebuilder", {}).get("usePrebuild", {}) + + def covered(k: str) -> bool: + if k.startswith("@yandex-prebuild/"): + return True + return k in use_prebuild_flags + + not_covered = [key for key in requires_build_packages if not covered(key)] + use_prebuild_keys = [key for key in use_prebuild_flags if use_prebuild_flags[key]] + missing_overrides = [key for key in use_prebuild_keys if key not in pnpm_overrides] + + messages = [] + + if not_covered: + messages.append("These packages possibly have addons but are not checked yet:") + messages.extend([f" - {key}" for key in not_covered]) + + if missing_overrides: + messages.append("These packages have addons but overrides are not set:") + messages.extend([f" - {key}" for key in missing_overrides]) + + return (not messages, messages) diff --git a/build/plugins/lib/nots/package_manager/pnpm/lockfile.py b/build/plugins/lib/nots/package_manager/pnpm/lockfile.py index 46558861bd..fb8d688dea 100644 --- a/build/plugins/lib/nots/package_manager/pnpm/lockfile.py +++ b/build/plugins/lib/nots/package_manager/pnpm/lockfile.py @@ -112,6 +112,16 @@ class PnpmLockfile(BaseLockfile): return (not invalid_keys, invalid_keys) + def get_requires_build_packages(self): + packages = self.data.get("packages", {}) + requires_build_packages = [] + + for key, meta in iteritems(packages): + if meta.get("requiresBuild"): + requires_build_packages.append(key[1:]) # strip leading slash from key + + return requires_build_packages + def _parse_package_meta(key, meta, allow_file_protocol=False): """ |