-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnoxfile.py
137 lines (97 loc) · 4.14 KB
/
noxfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import json
import os
from datetime import datetime
from pathlib import Path
import nox
# imports all nox task provided by the toolbox
from exasol.toolbox.nox.tasks import *
from nox import Session
from exasol.analytics.query_handler.deployment.slc import custom_slc_builder
from noxconfig import ROOT_DIR
# default actions to be run if nothing is explicitly specified with the -s option
nox.options.sessions = ["fix"]
SCRIPTS_DIRECTORY = ROOT_DIR / "scripts"
RUN_IN_DEV_SCRIPT = SCRIPTS_DIRECTORY / "run_in_dev_env.sh"
RUN_IN_DEV_SCRIPT_STR = str(RUN_IN_DEV_SCRIPT)
TEST_DIRECTORY = ROOT_DIR / "tests"
INTEGRATION_TEST_DIRECTORY = TEST_DIRECTORY / "integration_tests"
nox.options.sessions = []
def _run_in_dev_env_poetry_call(session: Session, *args: str):
session.run(RUN_IN_DEV_SCRIPT_STR, "poetry", "run", *args)
def _run_in_dev_env_call(session: Session, *args: str):
session.run(RUN_IN_DEV_SCRIPT_STR, *args)
@nox.session(python=False)
def run_in_dev_env(session: Session):
_run_in_dev_env_call(session, *session.posargs)
@nox.session(python=False)
def run_in_dev_env_poetry(session: Session):
_run_in_dev_env_poetry_call(session, *session.posargs)
@nox.session(python=False)
def run_python_test(session: Session):
_run_in_dev_env_poetry_call(session, "pytest", *session.posargs)
@nox.session(python=False)
def install_dev_env(session: Session):
install_script = SCRIPTS_DIRECTORY / "install_development_environment.sh"
session.run(str(install_script))
@nox.session(python=False)
def amalgate_lua_scripts(session: Session):
script = (
ROOT_DIR
/ "exasol"
/ "analytics"
/ "query_handler"
/ "deployment"
/ "regenerate_scripts.py"
)
_run_in_dev_env_poetry_call(session, "python", str(script))
@nox.session(python=False)
def run_lua_unit_tests(session: Session):
lua_tests_script = SCRIPTS_DIRECTORY / "lua_tests.sh"
_run_in_dev_env_call(session, str(lua_tests_script))
@nox.session(python=False)
def run_python_unit_tests(session: Session):
unit_test_directory = TEST_DIRECTORY / "unit_tests"
_run_in_dev_env_poetry_call(session, "pytest", str(unit_test_directory))
def _generate_test_matrix_entry(test_file: Path):
return {"name": str(test_file.name), "path": str(test_file)}
def _generate_github_integration_tests_without_db_matrix() -> str:
without_db_test_directory = INTEGRATION_TEST_DIRECTORY / "without_db"
test_files = without_db_test_directory.rglob("test_*.py")
output = [_generate_test_matrix_entry(test_file) for test_file in test_files]
json_str = json.dumps(output)
return json_str
@nox.session(python=False)
def generate_github_integration_tests_without_db_matrix_json(session: Session):
json_str = _generate_github_integration_tests_without_db_matrix()
print(json_str)
@nox.session(python=False)
def write_github_integration_tests_without_db_matrix(session: Session):
json_str = _generate_github_integration_tests_without_db_matrix()
github_output_definition = f"matrix={json_str}"
if "GITHUB_OUTPUT" in os.environ:
with open(os.environ["GITHUB_OUTPUT"], "a") as fh:
print(github_output_definition, file=fh)
else:
print(github_output_definition)
@nox.session(python=False)
def run_python_integration_tests_without_db(session: Session):
integration_test_directory = INTEGRATION_TEST_DIRECTORY / "without_db"
_run_in_dev_env_poetry_call(session, "pytest", str(integration_test_directory))
@nox.session(python=False)
def start_integration_test_environment(session: Session):
script_path = SCRIPTS_DIRECTORY / "start_integration_test_environment.sh"
_run_in_dev_env_call(session, str(script_path))
@nox.session(python=False)
def build_language_container(session: Session):
export_path = ROOT_DIR / ".slc"
with custom_slc_builder() as builder:
builder.export(export_path)
@nox.session(python=False)
def run_python_integration_tests_with_db(session: Session):
integration_test_directory = INTEGRATION_TEST_DIRECTORY / "with_db"
_run_in_dev_env_poetry_call(
session,
"pytest",
str(integration_test_directory),
*session.posargs,
)