Skip to content

Commit

Permalink
Added remove of forced video in GitLab CI
Browse files Browse the repository at this point in the history
Note that this video recording is needed in the tests, but I don't know
why.
  • Loading branch information
set-soft committed Feb 22, 2021
1 parent 9e33b7a commit c82485a
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 8 deletions.
6 changes: 4 additions & 2 deletions kibot/kiplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
Expand Down
6 changes: 5 additions & 1 deletion kibot/out_pdf_pcb_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def run(self, output_dir, layers):
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
Expand All @@ -124,6 +124,10 @@ def run(self, output_dir, layers):
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
Expand Down
6 changes: 5 additions & 1 deletion kibot/out_pdf_sch_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def run(self, output_dir):
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)
Expand All @@ -63,6 +63,10 @@ def run(self, output_dir):
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
Expand Down
6 changes: 5 additions & 1 deletion kibot/out_svg_sch_print.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def run(self, output_dir):
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)
Expand All @@ -60,6 +60,10 @@ def run(self, output_dir):
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
Expand Down
7 changes: 6 additions & 1 deletion kibot/pre_drc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -43,9 +44,13 @@ def run(self):
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)
Expand Down
7 changes: 6 additions & 1 deletion kibot/pre_erc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -43,9 +44,13 @@ def run(self):
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)
Expand Down
7 changes: 6 additions & 1 deletion kibot/pre_update_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -34,9 +35,13 @@ def run(self):
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)

0 comments on commit c82485a

Please sign in to comment.