2023-01-30 17:27:11 +08:00
"""
This module returns the pipeline used for integration tests.
"""
2022-07-20 21:43:19 +08:00
load(
2023-01-30 17:27:11 +08:00
"scripts/drone/steps/lib.star",
"compile_build_cmd",
"download_grabpl_step",
2023-02-02 00:55:49 +08:00
"enterprise_setup_step",
2023-01-30 17:27:11 +08:00
"identify_runner_step",
2023-04-05 16:55:55 +08:00
"memcached_integration_tests_step",
2023-01-30 17:27:11 +08:00
"mysql_integration_tests_step",
"postgres_integration_tests_step",
2023-04-05 16:55:55 +08:00
"redis_integration_tests_step",
2023-01-30 17:27:11 +08:00
"verify_gen_cue_step",
"verify_gen_jsonnet_step",
"wire_install_step",
2022-07-20 21:43:19 +08:00
)
load(
2023-01-30 17:27:11 +08:00
"scripts/drone/services/services.star",
"integration_test_services",
"integration_test_services_volumes",
2022-07-20 21:43:19 +08:00
)
load(
2023-01-30 17:27:11 +08:00
"scripts/drone/utils/utils.star",
"pipeline",
2022-07-20 21:43:19 +08:00
)
2023-02-02 00:55:49 +08:00
def integration_tests(trigger, prefix, ver_mode = "pr"):
2023-01-30 17:27:11 +08:00
"""Generate a pipeline for integration tests.
Args:
trigger: controls which events can trigger the pipeline execution.
prefix: used in the naming of the pipeline.
2023-02-02 00:55:49 +08:00
ver_mode: defines the event / origin of this build. In this function, if it is set to pr, then it will attempt to clone grafana-enterprise. Otherwise it has no effect.
2023-01-30 17:27:11 +08:00
Returns:
Drone pipeline.
"""
environment = {"EDITION": "oss"}
2022-12-07 15:13:57 +08:00
2023-04-05 16:55:55 +08:00
services = integration_test_services()
2022-07-20 21:43:19 +08:00
volumes = integration_test_services_volumes()
2022-12-07 15:13:57 +08:00
2023-02-02 00:55:49 +08:00
init_steps = []
verify_step = verify_gen_cue_step()
verify_jsonnet_step = verify_gen_jsonnet_step()
if ver_mode == "pr":
# In pull requests, attempt to clone grafana enterprise.
init_steps.append(enterprise_setup_step())
# Ensure that verif_gen_cue happens after we clone enterprise
# At the time of writing this, very_gen_cue is depended on by the wire step which is what everything else depends on.
verify_step["depends_on"].append("clone-enterprise")
verify_jsonnet_step["depends_on"].append("clone-enterprise")
init_steps += [
2022-07-20 21:43:19 +08:00
download_grabpl_step(),
2022-07-28 22:11:22 +08:00
compile_build_cmd(),
2022-07-20 21:43:19 +08:00
identify_runner_step(),
2023-02-02 00:55:49 +08:00
verify_step,
verify_jsonnet_step,
2022-07-20 21:43:19 +08:00
wire_install_step(),
]
2022-12-07 15:13:57 +08:00
2022-07-20 21:43:19 +08:00
test_steps = [
2022-12-07 15:13:57 +08:00
postgres_integration_tests_step(),
mysql_integration_tests_step(),
2023-04-05 16:55:55 +08:00
redis_integration_tests_step(),
memcached_integration_tests_step(),
2022-07-20 21:43:19 +08:00
]
return pipeline(
2023-01-30 17:27:11 +08:00
name = "{}-integration-tests".format(prefix),
edition = "oss",
trigger = trigger,
environment = environment,
services = services,
volumes = volumes,
steps = init_steps + test_steps,
2022-07-20 21:43:19 +08:00
)