aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvturov <vturov@yandex-team.com>2024-09-15 22:40:25 +0300
committervturov <vturov@yandex-team.com>2024-09-15 22:51:11 +0300
commit90b4b3b737e53ea7c2d679cc73fbad2a06a68a6a (patch)
tree20bb68f5056aef5fb3a2672bbee04ce70159f7b4
parent652e26979af322802fc3f9a6fa7800b574e47ae5 (diff)
downloadydb-90b4b3b737e53ea7c2d679cc73fbad2a06a68a6a.tar.gz
nots: readability updates done during playwright runner creation
Small updates to the plugin code to be reviewed separately from playwright runner change commit_hash:58e5b083f3b65c75ff94e4edac714d0213d08a09
-rw-r--r--build/plugins/lib/nots/package_manager/base/constants.py2
-rw-r--r--build/plugins/nots.py49
2 files changed, 34 insertions, 17 deletions
diff --git a/build/plugins/lib/nots/package_manager/base/constants.py b/build/plugins/lib/nots/package_manager/base/constants.py
index cd90b78b53..4b77ed2218 100644
--- a/build/plugins/lib/nots/package_manager/base/constants.py
+++ b/build/plugins/lib/nots/package_manager/base/constants.py
@@ -6,4 +6,4 @@ NODE_MODULES_WORKSPACE_BUNDLE_FILENAME = "workspace_node_modules.tar"
NPM_REGISTRY_URL = "http://npm.yandex-team.ru"
OUTPUT_TAR_FILENAME = "output.tar"
PACKAGE_JSON_FILENAME = "package.json"
-PNPM_LOCKFILE = "pnpm-lock.yaml"
+PNPM_LOCKFILE_FILENAME = "pnpm-lock.yaml"
diff --git a/build/plugins/nots.py b/build/plugins/nots.py
index dcc418ea5c..8e3735671e 100644
--- a/build/plugins/nots.py
+++ b/build/plugins/nots.py
@@ -20,12 +20,29 @@ from _dart_fields import create_dart_record
# 0.2 is 300 files per chunk for TIMEOUT(60) - default timeout for SIZE(SMALL)
ESLINT_FILE_PROCESSING_TIME_DEFAULT = 0.2 # seconds per file
+COLOR_CODES = {
+ "red": "31",
+ "green": "32",
+ "yellow": "33",
+ "cyan": "36",
+ "reset": "49",
+}
+
+
+class ConsoleColors(dict):
+ def __init__(self, color_codes):
+ for k, v in color_codes.items():
+ self.__dict__[k] = f"\033[0;{v}m"
+
+
+COLORS = ConsoleColors(COLOR_CODES)
+
class TsTestType(StrEnum):
- JEST = auto()
+ ESLINT = auto()
HERMIONE = auto()
+ JEST = auto()
PLAYWRIGHT = auto()
- ESLINT = auto()
TSC_TYPECHECK = auto()
TS_STYLELINT = auto()
@@ -47,15 +64,12 @@ TS_TEST_FIELDS_BASE = (
)
TS_TEST_SPECIFIC_FIELDS = {
- TsTestType.JEST: (
+ TsTestType.ESLINT: (
df.Size.from_unit,
+ df.TestCwd.moddir,
df.Tag.from_unit,
df.Requirements.from_unit,
- df.ConfigPath.value,
- df.TsTestDataDirs.value,
- df.TsTestDataDirsRename.value,
- df.TsResources.value,
- df.TsTestForPath.value,
+ df.EslintConfigPath.value,
),
TsTestType.HERMIONE: (
df.Tag.from_unit_fat_external_no_retries,
@@ -66,7 +80,7 @@ TS_TEST_SPECIFIC_FIELDS = {
df.TsResources.value,
df.TsTestForPath.value,
),
- TsTestType.PLAYWRIGHT: (
+ TsTestType.JEST: (
df.Size.from_unit,
df.Tag.from_unit,
df.Requirements.from_unit,
@@ -76,12 +90,15 @@ TS_TEST_SPECIFIC_FIELDS = {
df.TsResources.value,
df.TsTestForPath.value,
),
- TsTestType.ESLINT: (
+ TsTestType.PLAYWRIGHT: (
df.Size.from_unit,
- df.TestCwd.moddir,
df.Tag.from_unit,
df.Requirements.from_unit,
- df.EslintConfigPath.value,
+ df.ConfigPath.value,
+ df.TsTestDataDirs.value,
+ df.TsTestDataDirsRename.value,
+ df.TsResources.value,
+ df.TsTestForPath.value,
),
TsTestType.TSC_TYPECHECK: (
df.Size.from_unit,
@@ -118,7 +135,7 @@ class PluginLogger(object):
parts.append(m if isinstance(m, str) else repr(m))
# cyan color (code 36) for messages
- return "\033[0;32m{}\033[0;49m\n\033[0;36m{}\033[0;49m".format(self.prefix, " ".join(parts))
+ return f"{COLORS.green}{self.prefix}{COLORS.reset}\n{COLORS.cyan}{" ".join(parts)}{COLORS.reset}"
def info(self, *messages):
if self.unit:
@@ -735,7 +752,7 @@ def on_node_modules_configure(unit):
# YATOOL_PREBUILDER_0_7_0_RESOURCE_GLOBAL
prebuilder_major = unit.get("YATOOL_PREBUILDER-ROOT-VAR-NAME").split("_")[2]
- logger.info(f"Detected prebuilder \033[0;32mv{prebuilder_major}.x.x\033[0;49m")
+ logger.info(f"Detected prebuilder {COLORS.green}{prebuilder_major}.x.x{COLORS.reset}")
if prebuilder_major == "0":
# TODO: FBP-1408
@@ -746,7 +763,7 @@ def on_node_modules_configure(unit):
ymake.report_configure_error(
"Project is configured to use @yatool/prebuilder. \n"
+ "Some packages in the pnpm-lock.yaml are misconfigured.\n"
- + "Run \033[0;32m`ya tool nots update-lockfile`\033[0;49m to fix lockfile.\n"
+ + "Run {COLORS.green}`ya tool nots update-lockfile`{COLORS.reset} to fix lockfile.\n"
+ "All packages with `requiresBuild:true` have to be marked with `hasAddons:true/false`.\n"
+ "Misconfigured keys: \n"
+ " - "
@@ -761,7 +778,7 @@ def on_node_modules_configure(unit):
ymake.report_configure_error(
"Project is configured to use @yatool/prebuilder. \n"
+ "Some packages are misconfigured.\n"
- + "Run \033[0;32m`ya tool nots update-lockfile`\033[0;49m to fix pnpm-lock.yaml and package.json.\n"
+ + "Run {COLORS.green}`ya tool nots update-lockfile`{COLORS.reset} to fix pnpm-lock.yaml and package.json.\n"
+ "Validation details: \n"
+ "\n".join(validation_messages)
)