Skip to content

Commit

Permalink
Avoid expected warnings when running on docker images
Browse files Browse the repository at this point in the history
- They can be enabled using the `--warn-ci-cd` command line option
- They currenly include:
  - W009 KiCad config without environment.vars section
  - W010 For missing user templates and 3D models

Related to #564
  • Loading branch information
set-soft committed Mar 27, 2024
1 parent 1fa0d85 commit 9b41491
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Panelize: support for all new options (upto 1.5.1)

### Changed
- CI/CD: we now filter some warnings that are always generated by docker
images when we detect a CI/CD environment. They can be enabled using the
`--warn-ci-cd` command line option. (See #564)
- KiRi: continue even on corrupted schematics (#583)
- Variants: avoid W045 on nameless pads. Assuming they are on purpose and not
real pads. (See #584)
Expand Down
3 changes: 3 additions & 0 deletions docs/source/Changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Added
Changed
~~~~~~~

- CI/CD: we now filter some warnings that are always generated by
docker images when we detect a CI/CD environment. They can be enabled
using the ``--warn-ci-cd`` command line option. (See #564)
- KiRi: continue even on corrupted schematics (#583)
- Variants: avoid W045 on nameless pads. Assuming they are on purpose
and not real pads. (See #584)
Expand Down
6 changes: 4 additions & 2 deletions docs/source/usage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ KiBot: KiCad automation tool for documents generation
Usage:
kibot [-b BOARD] [-e SCHEMA] [-c CONFIG] [-d OUT_DIR] [-s PRE]
[-q | -v...] [-L LOGFILE] [-C | -i | -n] [-m MKFILE] [-A] [-g DEF] ...
[-E DEF] ... [--defs-from-env] [-w LIST] [-D | -W] [--banner N]
[TARGET...]
[-E DEF] ... [--defs-from-env] [-w LIST] [-D | -W] [--warn-ci-cd]
[--banner N] [TARGET...]
kibot [-v...] [-b BOARD] [-e SCHEMA] [-c PLOT_CONFIG] [--banner N]
[-E DEF] ... [--defs-from-env] [--config-outs]
[--only-pre|--only-groups] [--only-names] [--output-name-first] --list
Expand Down Expand Up @@ -69,6 +69,8 @@ Options:
-V, --version Show program's version number and exit
-w, --no-warn LIST Exclude the mentioned warnings (comma sep)
-W, --stop-on-warnings Stop on warnings
--warn-ci-cd Don't disable warnings expected on CI/CD
environments
-x, --example Create a template configuration file

Quick start options:
Expand Down
26 changes: 19 additions & 7 deletions kibot/__main__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2020-2023 Salvador E. Tropea
# Copyright (c) 2020-2023 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2020-2024 Salvador E. Tropea
# Copyright (c) 2020-2024 Instituto Nacional de Tecnología Industrial
# Copyright (c) 2018 John Beard
# License: GPL-3.0
# License: AGPL-3.0
# Project: KiBot (formerly KiPlot)
# Adapted from: https://github.com/johnbeard/kiplot
"""KiBot: KiCad automation tool for documents generation
Usage:
kibot [-b BOARD] [-e SCHEMA] [-c CONFIG] [-d OUT_DIR] [-s PRE]
[-q | -v...] [-L LOGFILE] [-C | -i | -n] [-m MKFILE] [-A] [-g DEF] ...
[-E DEF] ... [--defs-from-env] [-w LIST] [-D | -W] [--banner N]
[TARGET...]
[-E DEF] ... [--defs-from-env] [-w LIST] [-D | -W] [--warn-ci-cd]
[--banner N] [TARGET...]
kibot [-v...] [-b BOARD] [-e SCHEMA] [-c PLOT_CONFIG] [--banner N]
[-E DEF] ... [--defs-from-env] [--config-outs]
[--only-pre|--only-groups] [--only-names] [--output-name-first] --list
Expand Down Expand Up @@ -76,6 +76,8 @@
-V, --version Show program's version number and exit
-w, --no-warn LIST Exclude the mentioned warnings (comma sep)
-W, --stop-on-warnings Stop on warnings
--warn-ci-cd Don't disable warnings expected on CI/CD
environments
-x, --example Create a template configuration file
Quick start options:
Expand Down Expand Up @@ -361,18 +363,28 @@ def parse_global_redef(args):


class SimpleFilter(object):
def __init__(self, num):
def __init__(self, num, regex=''):
self.number = num
self.regex = re.compile('')
self.regex = re.compile(regex)
self.error = ''


def detect_ci_env():
return os.path.isfile('/etc/kiauto_tag') or ('GITLAB_CI' in os.environ) or ('GITHUB_RUN_ID' in os.environ)


def apply_warning_filter(args):
if args.no_warn:
try:
log.set_filters([SimpleFilter(int(n)) for n in args.no_warn.split(',')])
except ValueError:
GS.exit_with_error(f'-w/--no-warn must specify a comma separated list of numbers ({args.no_warn})', EXIT_BAD_ARGS)
if detect_ci_env() and not args.warn_ci_cd:
# Disable warnings we always get on docker images
# 9: KiCad config without environment.vars section
# 10: Missing user templates and 3D models
logger.debug('Filtering warnings we always get on CI/CD')
log.set_filters([SimpleFilter(n, regex=r) for n, r in ((9, ''), (10, '(3D models|user templates)'))])


def debug_arguments(args):
Expand Down

0 comments on commit 9b41491

Please sign in to comment.