Skip to content
Merged
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
29 changes: 29 additions & 0 deletions scripts/ci/prek/check_system_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,38 @@
r"test_run = get_test_run"
)

DAG_WITH_ARGS = re.compile(
r"with\s+DAG\s*\(\s*(?P<args>.*?)\)\s*as\s+\w+\s*:",
re.DOTALL,
)
REQUIRES_SCHEDULE_ERROR = (
"[red]System test DAG must set the 'schedule' parameter (e.g. schedule='@once').[/]\n\n"
"[yellow]Example:[/]\n\n"
"with DAG(\n"
" DAG_ID,\n"
" schedule='@once',\n"
" start_date=datetime(2021, 1, 1),\n"
" catchup=False,\n"
" tags=[...],\n"
") as dag:\n"
)


def _check_file(file: Path):
content = file.read_text()
console.print("----------file path: ", file)
for m in DAG_WITH_ARGS.finditer(content):
args = m.group("args")
if "schedule" not in args:
errors.append(
f"In {file}: System test DAG must include the 'schedule' parameter "
f"(e.g. schedule='@once') inside DAG(...).\n"
)
elif "providers/google/" in str(file).replace("\\", "/") and "schedule=None" in args:
errors.append(
f"In {file}: System test DAG should not include the 'schedule' parameter "
f"with value 'None' inside DAG(...): this configuration will make the automated run not possible for the test.\n"
)
if "from tests_common.test_utils.watcher import watcher" in content:
index = content.find(WATCHER_APPEND_INSTRUCTION_SHORT)
if index == -1:
Expand Down