From 9a7567e9c62d5f8991125694f783950796e1d71a Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Fri, 28 Jun 2024 17:50:35 +0200 Subject: [PATCH 1/7] add option to upload a minimal test report that is only the table. Will be useful for large tests (e.g. weekly CI) where the size of the full reort is to large for GITHUB_STEP_SUMMARY --- planemo/galaxy/test/actions.py | 2 +- planemo/options.py | 7 +++++ planemo/reports/report_markdown_minimal.tpl | 32 +++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 planemo/reports/report_markdown_minimal.tpl diff --git a/planemo/galaxy/test/actions.py b/planemo/galaxy/test/actions.py index 2bb7d44bb..3c9f43873 100644 --- a/planemo/galaxy/test/actions.py +++ b/planemo/galaxy/test/actions.py @@ -80,7 +80,7 @@ def handle_reports(ctx, structured_data, kwds): except Exception as e: exceptions.append(e) - for report_type in ["html", "markdown", "text", "xunit", "junit", "allure"]: + for report_type in ["html", "markdown", "markdown_minimal", "text", "xunit", "junit", "allure"]: try: _handle_test_output_file(ctx, report_type, structured_data, kwds) except Exception as e: diff --git a/planemo/options.py b/planemo/options.py index 7ceff7de4..867d637c2 100644 --- a/planemo/options.py +++ b/planemo/options.py @@ -1531,6 +1531,13 @@ def test_report_options(): help=("Output test report (Markdown style - for humans & " "computers)"), default=None, ), + planemo_option( + "--test_output_markdown_minimal", + type=click.Path(file_okay=True, resolve_path=True), + use_global_config=True, + help=("Output test report (Minimal markdown style - jost the table)"), + default=None, + ), planemo_option( "--test_output_xunit", type=click.Path(file_okay=True, resolve_path=True), diff --git a/planemo/reports/report_markdown_minimal.tpl b/planemo/reports/report_markdown_minimal.tpl new file mode 100644 index 000000000..ce3f961fd --- /dev/null +++ b/planemo/reports/report_markdown_minimal.tpl @@ -0,0 +1,32 @@ +{% from 'macros.tmpl' import render_invocation_details, render_invocation_messages, render_job_parameters, render_steps %} +{% if title %} +# {{ execution_type }} {{ title }} + +{% endif %} +## {{ execution_type }} Summary +{% set state = namespace(found=false) %} +{% set state.success = raw_data.results.total - raw_data.results.errors - raw_data.results.failures - raw_data.results.skips | default(0) %} +{% set state.error = raw_data.results.errors | default(0) %} +{% set state.failure = raw_data.results.failures | default(0) %} +{% set state.skipped = raw_data.results.skipped | default(0) %} + +{% if raw_data.results.total %} +
+
+
+
+
+
+
+
+{% endif %} + +| {{ execution_type }} State | Count | +| ---------- | ----- | +| Total | {{ raw_data.results.total | default(0) }} | +| Passed | {{ state.success }} | +| Error | {{ state.error }} | +| Failure | {{ state.failure }} | +| Skipped | {{ state.skipped }} | + + From 23bd9c52b926376b708616c70c93fe99516e456a Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Fri, 28 Jun 2024 17:57:20 +0200 Subject: [PATCH 2/7] add test --- tests/test_cmd_test_reports.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_cmd_test_reports.py b/tests/test_cmd_test_reports.py index f2bdcd987..2ba943797 100644 --- a/tests/test_cmd_test_reports.py +++ b/tests/test_cmd_test_reports.py @@ -20,3 +20,20 @@ def test_allure(self): assert os.path.exists(results_path) assert os.path.isdir(results_path) assert len(os.listdir(results_path)) + + def test_markdown(self): + with self._isolate() as f: + json_path = os.path.join(TEST_DATA_DIR, "issue381.json") + results_path = os.path.join(f, "minimal_markdown_results") + self._check_exit_code(["test_reports", "--test_output_minimal_markdown", results_path, json_path], exit_code=0) + assert os.path.exists(results_path) + assert os.path.isdir(results_path) + assert len(os.listdir(results_path)) + + minimal_results_path = os.path.join(f, "minimal_markdown_results") + self._check_exit_code(["test_reports", "--test_output_minimal_markdown", minimal_results_path, json_path], exit_code=0) + assert os.path.exists(minimal_results_path) + assert os.path.isdir(minimal_results_path) + assert len(os.listdir(minimal_results_path)) + + assert os.path.getsize(minimal_markdown_results) < os.path.getsize(markdown_results) From 5d4058d6b9e628540025b6525ac1754a1ce0f765 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 1 Jul 2024 17:47:59 +0200 Subject: [PATCH 3/7] add test IDs to minimal markdown report template --- planemo/reports/report_markdown_minimal.tpl | 23 +++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/planemo/reports/report_markdown_minimal.tpl b/planemo/reports/report_markdown_minimal.tpl index ce3f961fd..5d1d36116 100644 --- a/planemo/reports/report_markdown_minimal.tpl +++ b/planemo/reports/report_markdown_minimal.tpl @@ -30,3 +30,26 @@ | Skipped | {{ state.skipped }} | +{% set display_job_attributes = {'command_line': 'Command Line', 'exit_code': 'Exit Code', 'stderr': 'Standard Error', 'stdout': 'Standard Output', 'traceback': 'Traceback'} %} +{% for status, desc in {'error': 'Errored', 'failure': 'Failed', 'success': 'Passed'}.items() if state[status]%} +{% set expanded = "open" if status in ("error", "failure") else "" %} +
{{ desc }} {{ execution_type }}s +{% for test in raw_data.tests %} +{% if test.data.status == status %} +{% if test.data.status == 'success' %} + +*
✅ {{ test.id|replace("#","# ") }} + +{% else %} + +*
❌ {{ test.id|replace("#","# ") }} + +{% endif %} + +
+ +{% endif %} +{% endfor %} + +
+{% endfor %} From ec78cc51a77bb61530d16d9ca29e331023e8433f Mon Sep 17 00:00:00 2001 From: M Bernt Date: Mon, 1 Jul 2024 17:33:22 +0200 Subject: [PATCH 4/7] Update tests/test_cmd_test_reports.py Co-authored-by: Marius van den Beek --- tests/test_cmd_test_reports.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_cmd_test_reports.py b/tests/test_cmd_test_reports.py index 2ba943797..6b2b72041 100644 --- a/tests/test_cmd_test_reports.py +++ b/tests/test_cmd_test_reports.py @@ -36,4 +36,5 @@ def test_markdown(self): assert os.path.isdir(minimal_results_path) assert len(os.listdir(minimal_results_path)) + minimal_markdown_results = os.path.join(minimal_results_path, "tool_test_output.md") assert os.path.getsize(minimal_markdown_results) < os.path.getsize(markdown_results) From 1afa34cb771dc51f575d323c7f7bd7fcf2c9cd14 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 1 Jul 2024 17:42:43 +0200 Subject: [PATCH 5/7] Fix up the test --- tests/test_cmd_test_reports.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/test_cmd_test_reports.py b/tests/test_cmd_test_reports.py index 6b2b72041..cfe69402b 100644 --- a/tests/test_cmd_test_reports.py +++ b/tests/test_cmd_test_reports.py @@ -24,17 +24,13 @@ def test_allure(self): def test_markdown(self): with self._isolate() as f: json_path = os.path.join(TEST_DATA_DIR, "issue381.json") - results_path = os.path.join(f, "minimal_markdown_results") - self._check_exit_code(["test_reports", "--test_output_minimal_markdown", results_path, json_path], exit_code=0) + results_path = os.path.join(f, "markdown_results") + self._check_exit_code(["test_reports", "--test_output_markdown", results_path, json_path], exit_code=0) assert os.path.exists(results_path) - assert os.path.isdir(results_path) - assert len(os.listdir(results_path)) + # Run minimal version minimal_results_path = os.path.join(f, "minimal_markdown_results") - self._check_exit_code(["test_reports", "--test_output_minimal_markdown", minimal_results_path, json_path], exit_code=0) + self._check_exit_code(["test_reports", "--test_output_markdown_minimal", minimal_results_path, json_path], exit_code=0) assert os.path.exists(minimal_results_path) - assert os.path.isdir(minimal_results_path) - assert len(os.listdir(minimal_results_path)) - - minimal_markdown_results = os.path.join(minimal_results_path, "tool_test_output.md") - assert os.path.getsize(minimal_markdown_results) < os.path.getsize(markdown_results) + # Make sure minimal markdown is compacted + assert os.path.getsize(minimal_results_path) < os.path.getsize(results_path) From 0b17f5355fe8b8c84bdc72fda8b29142738c8af1 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 1 Jul 2024 18:11:49 +0200 Subject: [PATCH 6/7] remove unnecessary code --- planemo/reports/report_markdown_minimal.tpl | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/planemo/reports/report_markdown_minimal.tpl b/planemo/reports/report_markdown_minimal.tpl index 5d1d36116..6d44fcefd 100644 --- a/planemo/reports/report_markdown_minimal.tpl +++ b/planemo/reports/report_markdown_minimal.tpl @@ -29,25 +29,16 @@ | Failure | {{ state.failure }} | | Skipped | {{ state.skipped }} | - -{% set display_job_attributes = {'command_line': 'Command Line', 'exit_code': 'Exit Code', 'stderr': 'Standard Error', 'stdout': 'Standard Output', 'traceback': 'Traceback'} %} {% for status, desc in {'error': 'Errored', 'failure': 'Failed', 'success': 'Passed'}.items() if state[status]%} {% set expanded = "open" if status in ("error", "failure") else "" %}
{{ desc }} {{ execution_type }}s {% for test in raw_data.tests %} {% if test.data.status == status %} {% if test.data.status == 'success' %} - -*
✅ {{ test.id|replace("#","# ") }} - +* ✅ {{ test.id|replace("#","# ") }} {% else %} - -*
❌ {{ test.id|replace("#","# ") }} - +* ❌ {{ test.id|replace("#","# ") }} {% endif %} - -
- {% endif %} {% endfor %} From 0a7a87b8255b88d72f7d8296b5a7b43ece10c382 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Mon, 1 Jul 2024 18:12:08 +0200 Subject: [PATCH 7/7] fix lint --- tests/test_cmd_test_reports.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_cmd_test_reports.py b/tests/test_cmd_test_reports.py index cfe69402b..30c013f1e 100644 --- a/tests/test_cmd_test_reports.py +++ b/tests/test_cmd_test_reports.py @@ -30,7 +30,9 @@ def test_markdown(self): # Run minimal version minimal_results_path = os.path.join(f, "minimal_markdown_results") - self._check_exit_code(["test_reports", "--test_output_markdown_minimal", minimal_results_path, json_path], exit_code=0) + self._check_exit_code( + ["test_reports", "--test_output_markdown_minimal", minimal_results_path, json_path], exit_code=0 + ) assert os.path.exists(minimal_results_path) # Make sure minimal markdown is compacted assert os.path.getsize(minimal_results_path) < os.path.getsize(results_path)