From f6dde91b9c0c8efee41bb1b96c729b330f649656 Mon Sep 17 00:00:00 2001 From: Daniel Keller Date: Fri, 20 Feb 2026 11:06:00 +0100 Subject: [PATCH 1/3] ci: Fix flatdict dependency --- requirements.txt | 1 - util/mario/tracer.py | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 1bfe7864..3bef2fab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,4 +8,3 @@ sphinx-rtd-theme recommonmark sphinxcontrib-svg2pdfconverter pylint -flatdict diff --git a/util/mario/tracer.py b/util/mario/tracer.py index ce83f266..cb161dbe 100644 --- a/util/mario/tracer.py +++ b/util/mario/tracer.py @@ -8,9 +8,21 @@ # - Thomas Benz """ MARIO tracer interaction""" -import flatdict from mako.template import Template + +def _flatten_dict(d, parent_key='', delimiter='_'): + """Flatten a nested dict, joining keys with *delimiter*.""" + items = [] + for k, v in d.items(): + new_key = f'{parent_key}{delimiter}{k}' if parent_key else k + if isinstance(v, dict): + items.extend(_flatten_dict(v, new_key, delimiter).items()) + else: + items.append((new_key, v)) + return dict(items) + + TRACER_BODY = ''' // The tracer for the ${identifier} iDMA `define IDMA_TRACER_${identifier_cap}(__backend_inst, __out_f) <%text>\\ @@ -110,14 +122,14 @@ def render_tracer(prot_ids: dict, db: dict, tpl_file: str) -> str: # handle read ports for read_prot in prot_ids[prot_id]['ar']: - sig_dict = flatdict.FlatDict(db[read_prot]['trace_signals']['read'], delimiter='_') + sig_dict = _flatten_dict(db[read_prot]['trace_signals']['read']) for signal in sig_dict: signals += ' ' signals += f'"{read_prot}_{signal}": __backend_inst``.{sig_dict[signal]}' signals += ', \\\n' for write_prot in prot_ids[prot_id]['aw']: - sig_dict = flatdict.FlatDict(db[write_prot]['trace_signals']['write'], delimiter='_') + sig_dict = _flatten_dict(db[write_prot]['trace_signals']['write']) for signal in sig_dict: signals += ' ' signals += f'"{write_prot}_{signal}": __backend_inst``.{sig_dict[signal]}' From 7d4c9ba920b735b508dc370916c7e0f1b0e01557 Mon Sep 17 00:00:00 2001 From: Daniel Keller Date: Fri, 20 Feb 2026 13:37:30 +0100 Subject: [PATCH 2/3] ci: Chain workflows with workflow_call orchestrator --- .github/workflows/analyze.yml | 9 +------ .github/workflows/build.yml | 9 +------ .github/workflows/ci.yml | 48 +++++++++++++++++++++++++++++++++ .github/workflows/deploy.yml | 5 ++-- .github/workflows/gitlab-ci.yml | 10 ++----- .github/workflows/lint.yml | 9 +------ .gitlab-ci.yml | 6 +++-- 7 files changed, 59 insertions(+), 37 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml index 5909476e..9b2db9a4 100644 --- a/.github/workflows/analyze.yml +++ b/.github/workflows/analyze.yml @@ -9,15 +9,8 @@ name: analyze on: - push: - branches-ignore: - - '__deploy__**' - pull_request: - branches-ignore: - - '__deploy__**' + workflow_call: workflow_dispatch: - branches-ignore: - - '__deploy__**' jobs: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8af2a79e..6068359c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,15 +9,8 @@ name: build on: - push: - branches-ignore: - - '__deploy__**' - pull_request: - branches-ignore: - - '__deploy__**' + workflow_call: workflow_dispatch: - branches-ignore: - - '__deploy__**' jobs: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..6ac4bfab --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,48 @@ +# Copyright 2026 ETH Zurich and University of Bologna. +# Licensed under the Apache License, Version 2.0, see LICENSE for details. +# SPDX-License-Identifier: Apache-2.0 + +# Author: +# - Daniel Keller + +name: ci + +on: + push: + branches-ignore: + - '__deploy__**' + pull_request: + branches-ignore: + - '__deploy__**' + workflow_dispatch: + +concurrency: + group: ci-${{ github.ref }} + cancel-in-progress: true + +jobs: + + lint: + uses: ./.github/workflows/lint.yml + secrets: inherit + + build: + needs: lint + uses: ./.github/workflows/build.yml + secrets: inherit + + analyze: + needs: lint + uses: ./.github/workflows/analyze.yml + secrets: inherit + + gitlab-ci: + needs: build + uses: ./.github/workflows/gitlab-ci.yml + secrets: inherit + + deploy: + needs: build + if: github.event_name == 'push' + uses: ./.github/workflows/deploy.yml + secrets: inherit diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bbaea1a7..935d4e9c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -8,9 +8,8 @@ name: deploy on: - push: - branches-ignore: - - '__deploy__**' + workflow_call: + workflow_dispatch: jobs: diff --git a/.github/workflows/gitlab-ci.yml b/.github/workflows/gitlab-ci.yml index abdf3009..3fadcafe 100644 --- a/.github/workflows/gitlab-ci.yml +++ b/.github/workflows/gitlab-ci.yml @@ -9,20 +9,14 @@ name: gitlab-ci on: - push: - branches-ignore: - - '__deploy__**' - pull_request: - branches-ignore: - - '__deploy__**' + workflow_call: workflow_dispatch: - branches-ignore: - - '__deploy__**' jobs: check: runs-on: ubuntu-latest + timeout-minutes: 200 steps: - name: Mirror and check diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 01333be8..7d6c570d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,15 +9,8 @@ name: lint on: - push: - branches-ignore: - - '__deploy__**' - pull_request: - branches-ignore: - - '__deploy__**' + workflow_call: workflow_dispatch: - branches-ignore: - - '__deploy__**' jobs: diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cf4bcece..774b6e00 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,8 +21,10 @@ init: idma: stage: idma needs: [ init ] - except: - - /^__deploy__.*$/ + rules: + - if: $CI_COMMIT_BRANCH =~ /^__deploy__/ + when: never + - when: always trigger: include: - artifact: nonfree/ci/ci.yml From 0a4fe9912c17ed6684d1265caa81c1730ddcc5e7 Mon Sep 17 00:00:00 2001 From: Daniel Keller Date: Fri, 20 Feb 2026 14:36:12 +0100 Subject: [PATCH 3/3] ci: Add flake8 and yamllint pre-commit hooks --- .gitlint | 25 +++++++++++++++++++++++++ .pre-commit-config.yaml | 29 +++++++++++++++++++++++++++++ requirements.txt | 1 + 3 files changed, 55 insertions(+) create mode 100644 .gitlint create mode 100644 .pre-commit-config.yaml diff --git a/.gitlint b/.gitlint new file mode 100644 index 00000000..d03220a6 --- /dev/null +++ b/.gitlint @@ -0,0 +1,25 @@ +# Copyright 2026 ETH Zurich and University of Bologna. +# Solderpad Hardware License, Version 0.51, see LICENSE for details. +# SPDX-License-Identifier: SHL-0.51 + +# Matches rules enforced by util/lint-commits.py in CI. + +[general] +ignore=body-is-missing + +# Subject line: max 100 characters +[title-max-length] +line-length=100 + +# Subject line: no trailing period +[title-trailing-punctuation] + +# Subject line: must be capitalized, with optional "area: " prefix +# Valid: "Fix bug in backend" +# Valid: "backend: Fix bug in AXI read path" +# Invalid: "fixup! something" "lowercase start" +[title-match-regex] +regex=^([a-zA-Z_\-]+(/[a-zA-Z_\-]+)*: )?[A-Z] + +# Body: second line must be blank +[body-first-line-empty] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..b18c464a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,29 @@ +# Copyright 2026 ETH Zurich and University of Bologna. +# Solderpad Hardware License, Version 0.51, see LICENSE for details. +# SPDX-License-Identifier: SHL-0.51 + +# Run `pre-commit install && pre-commit install --hook-type commit-msg` to enable locally. + +default_language_version: + python: python3.11 + +repos: + - repo: https://github.com/jorisroovers/gitlint + rev: v0.19.1 + hooks: + - id: gitlint + stages: [commit-msg] + + - repo: https://github.com/PyCQA/flake8 + rev: 7.1.1 + hooks: + - id: flake8 + args: ['--max-line-length=100', '--extend-ignore=E128'] + files: ^util/ + + - repo: https://github.com/adrienverge/yamllint + rev: v1.35.1 + hooks: + - id: yamllint + args: ['-c', '.github/yamllint-conf.yml'] + files: (^Bender\.yml$|^src/db/.*\.yml$) diff --git a/requirements.txt b/requirements.txt index 3bef2fab..55c3f8e8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ GitPython +pre-commit hjson tabulate pyyaml