From 685ea0bc651c3b056133e72a0fd71cbfad575f3d Mon Sep 17 00:00:00 2001 From: Chris Bachhuber Date: Mon, 23 Sep 2024 13:37:24 +0200 Subject: [PATCH] Add Docker pre-commit hook (#5238) (#5452) --- .pre-commit-hooks.yaml | 8 ++++++++ ci/docker/buildenv/README.rst | 2 ++ docs/guide/install.rst | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 .pre-commit-hooks.yaml diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 000000000..9722691b3 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,8 @@ +--- +- id: verilator + name: verilator-lint + description: Runs verilator Docker image to lint (System) Verilog designs + args: [--lint-only] + language: docker_image + entry: verilator/verilator:latest + types_or: [verilog, system-verilog] diff --git a/ci/docker/buildenv/README.rst b/ci/docker/buildenv/README.rst index 1bb317e47..eac4307d2 100644 --- a/ci/docker/buildenv/README.rst +++ b/ci/docker/buildenv/README.rst @@ -1,6 +1,8 @@ .. Copyright 2003-2024 by Wilson Snyder. .. SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 +.. _Verilator Build Docker Container + Verilator Build Docker Container ================================ diff --git a/docs/guide/install.rst b/docs/guide/install.rst index 3029fa27e..6480d2475 100644 --- a/docs/guide/install.rst +++ b/docs/guide/install.rst @@ -26,6 +26,24 @@ package: For other distributions, refer to `Repology Verilator Distro Packages `__. +.. _pre-commit Quick Install: + +pre-commit Quick Install +============================= + +You can use verliator's `pre-commit `_ hook to lint your code before committing it. +It encapsulates the :ref:`Verilator Build Docker Container`_, so you need docker on your system to use it. +The verilator image will be downloaded automatically. +To use the hook, add the following entry to your :code:`.pre-commit-config.yaml`: + +.. code-block:: yaml + + repos: + - repo: https://github.com/verilator/verilator + rev: v5.026 # or later + hooks: + - id: verilator + .. _Git Install: Git Quick Install