cki_lib.kcidb.ready_for_test

Build ready-for-test messages from checkout-all payloads

cki_lib.kcidb.ready_for_test builds the CKI ready-for-test message from a DataWarehouse checkout-all payload, i.e. the plain JSON dict returned by GET /api/1/kcidb/checkouts/<id>/all. It is used by cki-notifier and the DataWarehouse merge-request ready-for-test endpoint.

from cki_lib import yaml
from cki_lib.kcidb import ready_for_test

message = ready_for_test.build_message(
    payload,
    datawarehouse_url="https://datawarehouse.cki-project.io",
    overall_status=overall_status,  # None for pre-test messages
    mr_info=ready_for_test.merge_request_info(mr_url),
)
yaml.validate(message, ready_for_test.load_schema())

build_message() does not access the network and does not validate the message. Passing an overall_status (see cki_lib.kcidb.checks) builds a post-test message with a status field, otherwise a pre-test message is built. Builds without a kernel_package_url are skipped silently; callers that need complete data must check builds_missing_kernel_package_url() first.

The mr_info argument controls the merge_request section:

  • merge_request_info(mr_url) queries GitLab for draft/KEV status, head pipeline URL, Bugzilla/Jira references, and subsystem and ExternalCI labels.
  • empty_merge_request_info() provides empty defaults for checkouts without a merge request.
  • None reduces the section to the merge request and head pipeline URLs stored in the payload. Values that only GitLab knows, like the draft status, are left out instead of being reported as empty, so the resulting message does not conform to the schema.

message_type_from_checkout() derives the message type from the checkout ready_to_report and notification_sent_build_setups_finished flags.