From 542c748b20b6dbd625df1c30db86dde5a8bf1a9e Mon Sep 17 00:00:00 2001 From: Pierre Equoy Date: Tue, 12 Nov 2024 15:42:01 +0100 Subject: [PATCH] Expose Checkbox version in JSON output (submission.json) (new) (#1595) * Add Checkbox version to the Jinja2 template data The Jinja2 template data already has `client_version`, which internally uses the `plainbox.get_version_string()` function to return either the Checkbox version as a string like Checkbox 3.3.1.dev333+gbe9508960.d20240701 either information about the Snap being used, if Checkbox is run as a snap: checkbox 4.2.0-dev127 (10238) This commit adds a `checkbox_version` field that always contains only the Checkbox version, without any additional string, such as : 3.3.1.dev333+gbe9508960.d20240701 This allows for a more precise tracking of what version of the Checkbox framework is used for debugging purposes. Fix #1580 * Add client_version and checkbox_version to submission JSON output * Update JSON schema reference to include client_version and checkbox_version --- checkbox-ng/plainbox/impl/exporter/jinja2.py | 4 ++++ .../plainbox/impl/providers/exporters/data/checkbox.json | 2 ++ submission-schema/schema.json | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/checkbox-ng/plainbox/impl/exporter/jinja2.py b/checkbox-ng/plainbox/impl/exporter/jinja2.py index 7b76a2260..78081e353 100644 --- a/checkbox-ng/plainbox/impl/exporter/jinja2.py +++ b/checkbox-ng/plainbox/impl/exporter/jinja2.py @@ -45,6 +45,7 @@ from plainbox import get_version_string +from plainbox import __version__ as checkbox_version from plainbox.abc import ISessionStateExporter from plainbox.impl.exporter import SessionStateExporterBase from plainbox.impl.result import OUTCOME_METADATA_MAP @@ -109,6 +110,7 @@ def __init__( self._client_version = client_version or get_version_string() # Remember client name self._client_name = client_name + self._checkbox_version = checkbox_version self.option_list = None self.template = None @@ -195,6 +197,7 @@ def dump_from_session_manager(self, session_manager, stream): "OUTCOME_METADATA_MAP": OUTCOME_METADATA_MAP, "client_name": self._client_name, "client_version": self._client_version, + "checkbox_version": self._checkbox_version, "manager": session_manager, "app_blob": app_blob_data, "options": self.option_list, @@ -220,6 +223,7 @@ def dump_from_session_manager_list(self, session_manager_list, stream): "OUTCOME_METADATA_MAP": OUTCOME_METADATA_MAP, "client_name": self._client_name, "client_version": self._client_version, + "checkbox_version": self._checkbox_version, "manager_list": session_manager_list, "app_blob": {}, "options": self.option_list, diff --git a/checkbox-ng/plainbox/impl/providers/exporters/data/checkbox.json b/checkbox-ng/plainbox/impl/providers/exporters/data/checkbox.json index f55659542..fca270195 100644 --- a/checkbox-ng/plainbox/impl/providers/exporters/data/checkbox.json +++ b/checkbox-ng/plainbox/impl/providers/exporters/data/checkbox.json @@ -6,6 +6,8 @@ {%- set system_information = state.system_information -%} { "title": {{ state.metadata.title | jsonify | safe }}, + "client_version": {{ client_version | jsonify | safe }}, + "checkbox_version": {{ checkbox_version | jsonify | safe }}, {%- if "testplan_id" in app_blob %} {%- if app_blob['testplan_id'] %} "testplan_id": {{ app_blob['testplan_id'] | jsonify | safe }}, diff --git a/submission-schema/schema.json b/submission-schema/schema.json index 6037fd187..baaa98aa0 100644 --- a/submission-schema/schema.json +++ b/submission-schema/schema.json @@ -11,6 +11,12 @@ "title": { "type": "string" }, + "client_version": { + "type": "string" + }, + "checkbox_version": { + "type": "string" + }, "testplan_id": { "type": "string" },