blob: 8d63c88ee04d2cb506db7c6d09536edc5124bdb7 [file] [edit]
# Copyright 2026 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Supported integration profiles for bazel tests."""
def _integration_profile(env = {}, sidecars = [], has_bm = False, has_rs = False):
"""Creates a struct representing an integration profile's properties."""
return struct(
env = env,
sidecars = sidecars,
has_bm = has_bm,
has_rs = has_rs,
)
_INTEGRATION_PROFILES = {
# Standard Bazel build without any sidecars or wrappers.
"PLAIN": _integration_profile(),
# Buildminder-only build (uses the integrated proxy for job status).
"BUILDMINDER": _integration_profile(
sidecars = ["//cmd/buildminder:buildminder_sidecar_wrapper"],
has_bm = True,
),
# ResultStore-only build (uses the integrated proxy for uploads).
"RESULTSTORE": _integration_profile(
sidecars = ["//cmd/fake_resultstore:fake_resultstore_wrapper"],
has_rs = True,
),
# Full stack integration: Buildminder + ResultStore.
"BUILDMINDER_RESULTSTORE": _integration_profile(
sidecars = [
"//cmd/buildminder:buildminder_sidecar_wrapper",
"//cmd/fake_resultstore:fake_resultstore_wrapper",
],
has_bm = True,
has_rs = True,
),
}
# Exported list of all supported integration names.
INTEGRATIONS = _INTEGRATION_PROFILES.keys()
def get_integration_env(integration):
"""Returns the environment variables for a given integration."""
return _INTEGRATION_PROFILES[integration].env
def get_integration_sidecars(integration):
"""Returns the list of sidecar labels for a given integration."""
return _INTEGRATION_PROFILES[integration].sidecars
def get_integration_verifiers(integration, outcome):
"""Returns the list of verifier labels for a given integration and outcome.
Args:
integration: The name of the integration (e.g., 'RESULTSTORE').
outcome: A behavioral profile struct, typically created by the
bazel_outcome factory function in outcomes.bzl.
Returns:
A list of verifier labels (strings) to be added to the test chain.
"""
profile = _INTEGRATION_PROFILES[integration]
verifiers = []
if profile.has_bm and outcome.bm_verifier:
verifiers.append(outcome.bm_verifier)
if profile.has_rs and outcome.rs_verifier:
verifiers.append(outcome.rs_verifier)
return verifiers