From c82485acc893ba06d0699989d7ab45d0b23b45d2 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 22 Feb 2021 12:55:02 -0300 Subject: [PATCH] Added remove of forced video in GitLab CI Note that this video recording is needed in the tests, but I don't know why. --- kibot/kiplot.py | 6 ++++-- kibot/out_pdf_pcb_print.py | 6 +++++- kibot/out_pdf_sch_print.py | 6 +++++- kibot/out_svg_sch_print.py | 6 +++++- kibot/pre_drc.py | 7 ++++++- kibot/pre_erc.py | 7 ++++++- kibot/pre_update_xml.py | 7 ++++++- 7 files changed, 37 insertions(+), 8 deletions(-) diff --git a/kibot/kiplot.py b/kibot/kiplot.py index 9a4f53ff..261a0721 100644 --- a/kibot/kiplot.py +++ b/kibot/kiplot.py @@ -153,9 +153,11 @@ def exec_with_retry(cmd): def add_extra_options(cmd): + is_gitlab_ci = 'GITLAB_CI' in os.environ + video_remove = (not GS.debug_enabled) and is_gitlab_ci if GS.debug_enabled: cmd.insert(1, '-'+'v'*GS.debug_level) - if GS.debug_enabled or 'GITLAB_CI' in os.environ: + if GS.debug_enabled or is_gitlab_ci: # Forcing record on GitLab CI/CD (black magic) cmd.insert(1, '-r') if GS.global_kiauto_time_out_scale: @@ -164,7 +166,7 @@ def add_extra_options(cmd): if GS.global_kiauto_wait_start: cmd.insert(1, str(GS.global_kiauto_wait_start)) cmd.insert(1, '--wait_start') - return cmd + return cmd, video_remove def load_board(pcb_file=None): diff --git a/kibot/out_pdf_pcb_print.py b/kibot/out_pdf_pcb_print.py index dad42350..9c8da3e9 100644 --- a/kibot/out_pdf_pcb_print.py +++ b/kibot/out_pdf_pcb_print.py @@ -111,7 +111,7 @@ class PDF_Pcb_PrintOptions(VariantOptions): cmd.append('--mirror') board_name, proj_name = self.filter_components(GS.board) cmd.extend([board_name, output_dir]) - cmd = add_extra_options(cmd) + cmd, video_remove = add_extra_options(cmd) # Add the layers cmd.extend([la.layer for la in layers]) # Execute it @@ -124,6 +124,10 @@ class PDF_Pcb_PrintOptions(VariantOptions): if ret: logger.error(CMD_PCBNEW_PRINT_LAYERS+' returned %d', ret) exit(PDF_PCB_PRINT) + if video_remove: + video_name = os.path.join(GS.out_dir, 'pcbnew_export_screencast.ogv') + if os.path.isfile(video_name): + os.remove(video_name) @output_class diff --git a/kibot/out_pdf_sch_print.py b/kibot/out_pdf_sch_print.py index 120a133b..d09dbba4 100644 --- a/kibot/out_pdf_sch_print.py +++ b/kibot/out_pdf_sch_print.py @@ -47,7 +47,7 @@ class PDF_Sch_PrintOptions(VariantOptions): sch_dir = None sch_file = GS.sch_file cmd = [CMD_EESCHEMA_DO, 'export', '--all_pages', '--file_format', 'pdf', sch_file, output_dir] - cmd = add_extra_options(cmd) + cmd, video_remove = add_extra_options(cmd) ret = exec_with_retry(cmd) if ret: logger.error(CMD_EESCHEMA_DO+' returned %d', ret) @@ -63,6 +63,10 @@ class PDF_Sch_PrintOptions(VariantOptions): if sch_dir: logger.debug('Removing temporal variant dir `{}`'.format(sch_dir)) rmtree(sch_dir) + if video_remove: + video_name = os.path.join(GS.out_dir, 'export_eeschema_screencast.ogv') + if os.path.isfile(video_name): + os.remove(video_name) @output_class diff --git a/kibot/out_svg_sch_print.py b/kibot/out_svg_sch_print.py index ff84607c..c3e7260e 100644 --- a/kibot/out_svg_sch_print.py +++ b/kibot/out_svg_sch_print.py @@ -44,7 +44,7 @@ class SVG_Sch_PrintOptions(VariantOptions): sch_dir = None sch_file = GS.sch_file cmd = [CMD_EESCHEMA_DO, 'export', '--all_pages', '--file_format', 'svg', sch_file, output_dir] - cmd = add_extra_options(cmd) + cmd, video_remove = add_extra_options(cmd) ret = exec_with_retry(cmd) if ret: logger.error(CMD_EESCHEMA_DO+' returned %d', ret) @@ -60,6 +60,10 @@ class SVG_Sch_PrintOptions(VariantOptions): if sch_dir: logger.debug('Removing temporal variant dir `{}`'.format(sch_dir)) rmtree(sch_dir) + if video_remove: + video_name = os.path.join(GS.out_dir, 'export_eeschema_screencast.ogv') + if os.path.isfile(video_name): + os.remove(video_name) @output_class diff --git a/kibot/pre_drc.py b/kibot/pre_drc.py index 56627919..cf0ac8c5 100644 --- a/kibot/pre_drc.py +++ b/kibot/pre_drc.py @@ -3,6 +3,7 @@ # Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial # License: GPL-3.0 # Project: KiBot (formerly KiPlot) +import os from sys import (exit) from .macros import macros, pre_class # noqa: F401 from .error import (KiPlotConfigurationError) @@ -43,9 +44,13 @@ class Run_DRC(BasePreFlight): # noqa: F821 cmd.append('-i') cmd.extend([GS.pcb_file, GS.out_dir]) # If we are in verbose mode enable debug in the child - cmd = add_extra_options(cmd) + cmd, video_remove = add_extra_options(cmd) logger.info('- Running the DRC') ret = exec_with_retry(cmd) + if video_remove: + video_name = os.path.join(GS.out_dir, 'pcbnew_run_drc_screencast.ogv') + if os.path.isfile(video_name): + os.remove(video_name) if ret: if ret > 127: ret = -(256-ret) diff --git a/kibot/pre_erc.py b/kibot/pre_erc.py index c1eeff57..df0d85e1 100644 --- a/kibot/pre_erc.py +++ b/kibot/pre_erc.py @@ -3,6 +3,7 @@ # Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial # License: GPL-3.0 # Project: KiBot (formerly KiPlot) +import os from sys import (exit) from .macros import macros, pre_class # noqa: F401 from .gs import (GS) @@ -43,9 +44,13 @@ class Run_ERC(BasePreFlight): # noqa: F821 cmd.extend(['-f', GS.filter_file]) cmd.extend([GS.sch_file, GS.out_dir]) # If we are in verbose mode enable debug in the child - cmd = add_extra_options(cmd) + cmd, video_remove = add_extra_options(cmd) logger.info('- Running the ERC') ret = exec_with_retry(cmd) + if video_remove: + video_name = os.path.join(GS.out_dir, 'run_erc_eeschema_screencast.ogv') + if os.path.isfile(video_name): + os.remove(video_name) if ret: if ret > 127: ret = -(256-ret) diff --git a/kibot/pre_update_xml.py b/kibot/pre_update_xml.py index d2dfdbf3..8f3f8c69 100644 --- a/kibot/pre_update_xml.py +++ b/kibot/pre_update_xml.py @@ -3,6 +3,7 @@ # Copyright (c) 2020-2021 Instituto Nacional de Tecnología Industrial # License: GPL-3.0 # Project: KiBot (formerly KiPlot) +import os from sys import (exit) from .macros import macros, pre_class # noqa: F401 from .error import (KiPlotConfigurationError) @@ -34,9 +35,13 @@ class Update_XML(BasePreFlight): # noqa: F821 check_eeschema_do() cmd = [CMD_EESCHEMA_DO, 'bom_xml', GS.sch_file, GS.out_dir] # If we are in verbose mode enable debug in the child - cmd = add_extra_options(cmd) + cmd, video_remove = add_extra_options(cmd) logger.info('- Updating BoM in XML format') ret = exec_with_retry(cmd) if ret: logger.error('Failed to update the BoM, error %d', ret) exit(BOM_ERROR) + if video_remove: + video_name = os.path.join(GS.out_dir, 'bom_xml_eeschema_screencast.ogv') + if os.path.isfile(video_name): + os.remove(video_name)