From 9a3939bfd71502f553f31f83507423866e8d1df9 Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Tue, 1 Oct 2024 14:59:25 +0200 Subject: [PATCH] [ci] Make the orchestrator choose which exec_env to run randomly The randomness is in fact deterministic and only depends on the test name. Signed-off-by: Amaury Pouly --- rules/opentitan/ci.bzl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/rules/opentitan/ci.bzl b/rules/opentitan/ci.bzl index 4dc2f3ce00a23..1c62676531bfa 100644 --- a/rules/opentitan/ci.bzl +++ b/rules/opentitan/ci.bzl @@ -29,12 +29,13 @@ def ci_orchestrator(test_name, exec_envs): that should be skipped in CI. """ exec_env_sets = sets.make(exec_envs) - found_one = False - skip_in_ci = [] - for env in _ONLY_RUN_ONE_IN_CI_SORTED: - if sets.contains(exec_env_sets, env): - if found_one: - skip_in_ci.append(env) - found_one = True + only_one_run_sets = sets.make(_ONLY_RUN_ONE_IN_CI_SORTED) + # List environments among which only one must run. + skip_in_ci = sets.to_list(sets.intersection(exec_env_sets, only_one_run_sets)) + # Choose one at random. + if len(skip_in_ci) > 0: + # FIXME This is not good randomness + the_one_index = hash(test_name) % len(skip_in_ci) + the_one = skip_in_ci.pop(the_one_index) return skip_in_ci