From 7d3e46b06fe2b611a0ff2fed4de4ba503979e6ec Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 24 Feb 2023 17:49:32 -0300 Subject: [PATCH 1/9] [Tests] Added KiCad 7 test for all iBoM options --- tests/yaml_samples/ibom_all_ops7.kibot.yaml | 1 + 1 file changed, 1 insertion(+) create mode 120000 tests/yaml_samples/ibom_all_ops7.kibot.yaml diff --git a/tests/yaml_samples/ibom_all_ops7.kibot.yaml b/tests/yaml_samples/ibom_all_ops7.kibot.yaml new file mode 120000 index 00000000..6bb5ea24 --- /dev/null +++ b/tests/yaml_samples/ibom_all_ops7.kibot.yaml @@ -0,0 +1 @@ +ibom_all_ops6.kibot.yaml \ No newline at end of file From 94264726d7eb2bd3628d2d471769a9bcd707b7b9 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 24 Feb 2023 18:46:43 -0300 Subject: [PATCH 2/9] [DRC] Ensure KiCad 7 vars are defined before DRC --- kibot/pre_run_drc.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kibot/pre_run_drc.py b/kibot/pre_run_drc.py index d9400231..21b68fae 100644 --- a/kibot/pre_run_drc.py +++ b/kibot/pre_run_drc.py @@ -15,6 +15,7 @@ from .macros import macros, pre_class # noqa: F401 from .error import KiPlotConfigurationError from .gs import GS from .optionable import Optionable +from .kicad.config import KiConf from .kiplot import load_board from .misc import DRC_ERROR from .log import get_logger @@ -51,6 +52,9 @@ class Run_DRC(BasePreFlight): # noqa: F821 def run(self): command = self.ensure_tool('KiAuto') + if GS.ki7: + # KiCad 7 can do some library parity checks, but we need to be sure that the KICAD7* vars are defined + KiConf.init(GS.pcb_file) output = self.get_targets()[0] os.makedirs(os.path.dirname(output), exist_ok=True) logger.debug('DRC report: '+output) From 3d1e5389c8adf546500f19ad7729f560c1b129c4 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 24 Feb 2023 18:47:19 -0300 Subject: [PATCH 3/9] [Tests] Ignore footprint missmatches in test_import_7 --- tests/test_plot/test_misc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_plot/test_misc.py b/tests/test_plot/test_misc.py index 2403f257..705022dd 100644 --- a/tests/test_plot/test_misc.py +++ b/tests/test_plot/test_misc.py @@ -855,7 +855,8 @@ def test_import_7(test_dir): if context.ki7(): ctx.board_file.replace('kicad_pcb', 'kicad_pro') with open(ctx.board_file.replace('kicad_pcb', 'kicad_pro'), 'wt') as f: - f.write(json.dumps({"board": {"design_settings": {"rule_severities": {"lib_footprint_issues": "ignore"}}}})) + f.write(json.dumps({"board": {"design_settings": {"rule_severities": {"lib_footprint_issues": "ignore", + "lib_footprint_mismatch": "ignore"}}}})) ctx.run(extra=[]) ctx.expect_out_file('3Rs-drc.txt') ctx.clean_up() From b7f90580049638185e852fd62050d0c273a963d0 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 24 Feb 2023 19:45:24 -0300 Subject: [PATCH 4/9] [Tests][DRC] Filter footprint missmatches --- tests/yaml_samples/drc_filter.kibot.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/yaml_samples/drc_filter.kibot.yaml b/tests/yaml_samples/drc_filter.kibot.yaml index d320535e..5364fe93 100644 --- a/tests/yaml_samples/drc_filter.kibot.yaml +++ b/tests/yaml_samples/drc_filter.kibot.yaml @@ -34,3 +34,6 @@ preflight: - filter_msg: 'Ignore library issues' error: lib_footprint_issues regexp: '.*' + - filter_msg: 'Ignore library missmatches' + error: lib_footprint_mismatch + regexp: '.*' From 423f5e33597c051b8172f173aad9c9d619df103d Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Fri, 24 Feb 2023 19:46:12 -0300 Subject: [PATCH 5/9] [Tests] Ignore convert errors for v7 PDFs - Not sure if they are important --- tests/utils/context.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/utils/context.py b/tests/utils/context.py index 6755a2e0..7856ef3b 100644 --- a/tests/utils/context.py +++ b/tests/utils/context.py @@ -521,7 +521,12 @@ class TestContext(object): # m = re.match(r'([\d\.e-]+) \(([\d\.e-]+)\)', res.decode()) # assert m # logging.debug('MSE={} ({})'.format(m.group(1), m.group(2))) - ae = int(res.decode()) + s = res.decode() + # Remove error messages generated by KiCad 7 plotted PDFs + s = re.sub(r'^\s+\*+.*', '', s, 0, re.M) + s = re.sub(r'^\s+Output may be incorrect.*', '', s, 0, re.M) + s = s.strip() + ae = int(s) logging.debug('AE=%d' % ae) if png_ref: os.remove(png_ref) From f91bb5c01f9ca27f6c4f5b7edc8ff7cede7d2363 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sat, 25 Feb 2023 14:33:38 -0300 Subject: [PATCH 6/9] [Tests] Added some schematic PS, HPGL and DXF examples - Used to verify kicad-cli patches --- tests/test_plot/test_print_sch.py | 33 ++++++++++++++++++++ tests/yaml_samples/print_sch_dxf.kibot.yaml | 11 +++++++ tests/yaml_samples/print_sch_hpgl.kibot.yaml | 11 +++++++ tests/yaml_samples/print_sch_ps.kibot.yaml | 11 +++++++ 4 files changed, 66 insertions(+) create mode 100644 tests/yaml_samples/print_sch_dxf.kibot.yaml create mode 100644 tests/yaml_samples/print_sch_hpgl.kibot.yaml create mode 100644 tests/yaml_samples/print_sch_ps.kibot.yaml diff --git a/tests/test_plot/test_print_sch.py b/tests/test_plot/test_print_sch.py index 87687cc7..77441c11 100644 --- a/tests/test_plot/test_print_sch.py +++ b/tests/test_plot/test_print_sch.py @@ -58,6 +58,39 @@ def test_print_sch_svg_ok(test_dir): ctx.clean_up() +# @pytest.mark.slow +# @pytest.mark.eeschema +# def test_print_sch_ps_ok(test_dir): +# prj = 'test_v5' +# ctx = context.TestContext(test_dir, prj, 'print_sch_ps') +# ctx.run() +# # Check all outputs are there +# ctx.expect_out_file(SVG_FILE.replace('svg', 'ps')) +# ctx.clean_up() + + +# @pytest.mark.slow +# @pytest.mark.eeschema +# def test_print_sch_dxf_ok(test_dir): +# prj = 'test_v5' +# ctx = context.TestContext(test_dir, prj, 'print_sch_dxf') +# ctx.run() +# # Check all outputs are there +# ctx.expect_out_file(SVG_FILE.replace('svg', 'dxf')) +# ctx.clean_up() + + +# @pytest.mark.slow +# @pytest.mark.eeschema +# def test_print_sch_hpgl_ok(test_dir): +# prj = 'test_v5' +# ctx = context.TestContext(test_dir, prj, 'print_sch_hpgl') +# ctx.run() +# # Check all outputs are there +# ctx.expect_out_file(SVG_FILE.replace('svg', 'hpgl')) +# ctx.clean_up() + + @pytest.mark.slow @pytest.mark.eeschema def test_print_sch_svg_fail(test_dir): diff --git a/tests/yaml_samples/print_sch_dxf.kibot.yaml b/tests/yaml_samples/print_sch_dxf.kibot.yaml new file mode 100644 index 00000000..373fda77 --- /dev/null +++ b/tests/yaml_samples/print_sch_dxf.kibot.yaml @@ -0,0 +1,11 @@ +# Example KiBot config file +kibot: + version: 1 + +outputs: + - name: 'print_dxf_svg' + comment: "Plot schematic (DXF)" + type: dxf_sch_print + dir: . + options: + output: Schematic.dxf diff --git a/tests/yaml_samples/print_sch_hpgl.kibot.yaml b/tests/yaml_samples/print_sch_hpgl.kibot.yaml new file mode 100644 index 00000000..61365770 --- /dev/null +++ b/tests/yaml_samples/print_sch_hpgl.kibot.yaml @@ -0,0 +1,11 @@ +# Example KiBot config file +kibot: + version: 1 + +outputs: + - name: 'print_hpgl_svg' + comment: "Plot schematic (HPGL)" + type: hpgl_sch_print + dir: . + options: + output: Schematic.plt diff --git a/tests/yaml_samples/print_sch_ps.kibot.yaml b/tests/yaml_samples/print_sch_ps.kibot.yaml new file mode 100644 index 00000000..6eea87f6 --- /dev/null +++ b/tests/yaml_samples/print_sch_ps.kibot.yaml @@ -0,0 +1,11 @@ +# Example KiBot config file +kibot: + version: 1 + +outputs: + - name: 'print_ps_svg' + comment: "Plot schematic (PS)" + type: ps_sch_print + dir: . + options: + output: Schematic.ps From 5c0f94f564507a72ea793fbae4b02cdca981f7e4 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sat, 25 Feb 2023 14:47:42 -0300 Subject: [PATCH 7/9] [CI/CD] Added KiCad 6+7 (nightly) dev image generation --- .github/workflows/pythonapp.yml | 49 +++++++++++++++++++++++++++++++++ tools/dev_image_k7/Dockerfile | 22 +++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 tools/dev_image_k7/Dockerfile diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index 12043250..eb5ee19d 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -263,6 +263,55 @@ jobs: ghcr.io/inti-cmnb/kicad6_auto_full:dev labels: ${{ steps.meta.outputs.labels }} + push_to_registry_ng: + name: Push Docker image to Docker Hub (KiCad 7) + runs-on: ubuntu-latest + needs: test + permissions: + packages: write + contents: read + # Don't create `dev` images using the `master` + if: github.ref == 'refs/heads/dev' + + steps: + - name: Check out the repo + uses: actions/checkout@v3 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: | + setsoft/kicad_auto_test + ghcr.io/inti-cmnb/kicad_auto_test + ghcr.io/inti-cmnb/kicad7_auto_full + tags: | + type=raw,dev_k7 + + - name: Build and push Docker image + uses: docker/build-push-action@v3 + with: + context: tools/dev_image_k7 + push: true + tags: | + setsoft/kicad_auto_test:dev_k7 + ghcr.io/inti-cmnb/kicad_auto_test:dev_k7 + # ghcr.io/inti-cmnb/kicad7_auto_full:dev + labels: ${{ steps.meta.outputs.labels }} + coveralls: name: Finish Coveralls needs: test diff --git a/tools/dev_image_k7/Dockerfile b/tools/dev_image_k7/Dockerfile new file mode 100644 index 00000000..4fe91da3 --- /dev/null +++ b/tools/dev_image_k7/Dockerfile @@ -0,0 +1,22 @@ +FROM setsoft/kicad_auto_test:nightly +MAINTAINER Salvador E. Tropea +LABEL Description="KiCad 6 with KiBot and other automation scripts" + +RUN dpkg --remove kicost kibot && \ + apt-get update && \ + curl https://codeload.github.com/INTI-CMNB/KiBot/zip/refs/heads/dev --output pp.zip && \ + unzip pp.zip && \ + pip3 install --no-compile KiBot-dev/ && \ + rm -rf KiBot-dev pp.zip && \ + curl https://codeload.github.com/hildogjr/KiCost/zip/refs/heads/master --output pp.zip && \ + unzip pp.zip && \ + pip3 install KiCost-master/ && \ + rm -rf KiCost-master pp.zip && \ + rm -rf /var/lib/apt/lists/* + +# kidiff depends on KiAuto +# dpkg --remove kiauto && \ +# curl https://codeload.github.com/INTI-CMNB/KiAuto/zip/refs/heads/master --output pp.zip && \ +# unzip pp.zip && \ +# pip3 install KiAuto-master/ && \ +# rm -rf KiAuto-master/ pp.zip && \ From 774cb7a67307c7dfbb3f8c27313c48c342120acb Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sat, 25 Feb 2023 14:50:24 -0300 Subject: [PATCH 8/9] [Windows] Use os.pathsep instead of ':' - Good idea by MDW mentioned in #392 --- kibot/__main__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kibot/__main__.py b/kibot/__main__.py index 9c33d5fb..e1b32408 100644 --- a/kibot/__main__.py +++ b/kibot/__main__.py @@ -93,7 +93,7 @@ if os.environ.get('KIAUS_USE_NIGHTLY'): # pragma: no cover (nightly) sys_path.insert(0, pcbnew_path) # This helps other tools like iBoM to pick-up the right pcbnew module if 'PYTHONPATH' in os.environ: - os.environ['PYTHONPATH'] += ':'+pcbnew_path + os.environ['PYTHONPATH'] += os.pathsep+pcbnew_path else: os.environ['PYTHONPATH'] = pcbnew_path nightly = True From f2f186f5fd79e602acd87c52549295767fdc9c48 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Sat, 25 Feb 2023 15:08:52 -0300 Subject: [PATCH 9/9] [CI/CD] Removed commented line that GitHub missinterprets --- .github/workflows/pythonapp.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pythonapp.yml b/.github/workflows/pythonapp.yml index eb5ee19d..8cafb9fd 100644 --- a/.github/workflows/pythonapp.yml +++ b/.github/workflows/pythonapp.yml @@ -309,7 +309,6 @@ jobs: tags: | setsoft/kicad_auto_test:dev_k7 ghcr.io/inti-cmnb/kicad_auto_test:dev_k7 - # ghcr.io/inti-cmnb/kicad7_auto_full:dev labels: ${{ steps.meta.outputs.labels }} coveralls: