Skip to content

Commit

Permalink
Merge pull request MaterializeInc#24162 from def-/pr-ci_test_selection
Browse files Browse the repository at this point in the history
ci: Support CI_TEST_SELECTION env variable
  • Loading branch information
def- authored Jan 2, 2024
2 parents 5c1e0ce + cb8ad44 commit efc0768
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
3 changes: 2 additions & 1 deletion bin/ci-builder
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ case "$cmd" in
--env AWS_SESSION_TOKEN
--env CI
--env CI_COVERAGE_ENABLED
--env CI_TEST_SELECTION
--env CONFLUENT_CLOUD_DEVEX_KAFKA_PASSWORD
--env CONFLUENT_CLOUD_DEVEX_KAFKA_USERNAME
--env GITHUB_TOKEN
Expand All @@ -179,6 +180,7 @@ case "$cmd" in
--env LAUNCHDARKLY_SDK_KEY
--env NIGHTLY_CANARY_APP_PASSWORD
--env MZ_CLI_APP_PASSWORD
--env MZ_SOFT_ASSERTIONS
--env NO_COLOR
--env NPM_TOKEN
--env POLAR_SIGNALS_API_TOKEN
Expand All @@ -190,7 +192,6 @@ case "$cmd" in
--env SCHEMA_REGISTRY_URL
--env POSTGRES_URL
--env COCKROACH_URL
--env MZ_SOFT_ASSERTIONS
)

if [[ $detach_container == "true" ]]; then
Expand Down
31 changes: 30 additions & 1 deletion ci/mkpipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ def visit(step: dict[str, Any]) -> None:

permit_rerunning_successful_steps(pipeline)

add_test_selection_block(pipeline, args.pipeline)
if test_selection := os.getenv("CI_TEST_SELECTION"):
trim_test_selection(pipeline, set(test_selection.split(",")))
else:
add_test_selection_block(pipeline, args.pipeline)

check_depends_on(pipeline, args.pipeline)

Expand Down Expand Up @@ -240,6 +243,32 @@ def visit(step: dict[str, Any]) -> None:
visit(inner_step)


def trim_test_selection(pipeline: Any, steps_to_run: set[str]) -> None:
def visit(step: dict[str, Any]) -> None:
if (
step.get("id") not in steps_to_run
and "prompt" not in step
and "wait" not in step
and "group" not in step
and step.get("id")
not in (
"coverage-pr-analyze",
"analyze",
"build-x86_64",
"build-aarch64",
"build-wasm",
)
and not step.get("async")
):
step["skip"] = True

for step in pipeline["steps"]:
visit(step)
if "group" in step:
for inner_step in step.get("steps", []):
visit(inner_step)


def add_test_selection_block(pipeline: Any, pipeline_name: str) -> None:
selection_step = {
"prompt": "What tests would you like to run? As a convenience, leaving all tests unchecked will run all tests.",
Expand Down

0 comments on commit efc0768

Please sign in to comment.