Automatic SystemVerilog linting in github actions with the help of Verible

Overview

Verible Lint Action

Usage

See action.yml

This is a GitHub Action used to lint Verilog and SystemVerilog source files and comment erroneous lines of code in Pull Requests automatically. The GitHub Token input is used to provide reviewdog access to the PR. If you don't wish to use the automatic PR review, you can omit the github_token input. If you'd like to use a reporter of reviewdog other than github-pr-review, you can pass its name in the input reviewdog_reporter.

Here's a basic example to lint all *.v and *.sv files:

name: Verible linter example
on:
  pull_request:
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/[email protected]
    - uses: chipsalliance/[email protected]
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}

You can provide optional arguments to specify paths, exclude paths, a config file and extra arguments for verible-verilog-lint.

- uses: chipsalliance/[email protected]
  with:
    config_file: 'config.rules'
    paths: |
      ./rtl
      ./shared
    exclude_paths: |
      ./rtl/some_file
    extra_args: "--check_syntax=true"
    github_token: ${{ secrets.GITHUB_TOKEN }}

Automatic review on PRs from external repositories

In GitHub Actions, workflows triggered by external repositories may only have read access to the main repository. In order to have automatic reviews on external PRs, you need to create two workflows. One will be triggered on pull_request and upload the data needed by reviewdog as an artifact. The artifact shall store the file pointed by $GITHUB_EVENT_PATH as event.json. The other workflow will download the artifact and use the Verible action.

For example:

name: upload-event-file
on:
  pull_request:

...
      - run: cp "$GITHUB_EVENT_PATH" ./event.json
      - name: Upload event file as artifact
        uses: actions/[email protected]
        with:
          name: event.json
          path: event.json
{ return artifact.name == "event.json" })[0]; var download = await github.actions.downloadArtifact({ owner: context.repo.owner, repo: context.repo.repo, artifact_id: matchArtifact.id, archive_format: 'zip', }); var fs = require('fs'); fs.writeFileSync('${{github.workspace}}/event.json.zip', Buffer.from(download.data)); - run: | unzip event.json.zip - name: Run Verible action with Reviewdog uses: chipsalliance/[email protected] with: github_token: ${{ secrets.GITHUB_TOKEN }} ">
name: review-triggered
on:
  workflow_run:
    workflows: ["upload-event-file"]
    types:
      - completed

jobs:
  review_triggered:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/[email protected]
      - name: 'Download artifact'
        id: get-artifacts
        uses: actions/[email protected]
        with:
          script: |
            var artifacts = await github.actions.listWorkflowRunArtifacts({
               owner: context.repo.owner,
               repo: context.repo.repo,
               run_id: ${{github.event.workflow_run.id }},
            });
            var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
              return artifact.name == "event.json"
            })[0];
            var download = await github.actions.downloadArtifact({
               owner: context.repo.owner,
               repo: context.repo.repo,
               artifact_id: matchArtifact.id,
               archive_format: 'zip',
            });
            var fs = require('fs');
            fs.writeFileSync('${{github.workspace}}/event.json.zip', Buffer.from(download.data));
      - run: |
          unzip event.json.zip
      - name: Run Verible action with Reviewdog
        uses: chipsalliance/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
Comments
  • Convert to Container Action

    Convert to Container Action

    Close #3

    Unfortunately, when the image is built automatically as part of a Container Action, it seems that global environment variables are not inherited. Therefore, enabling BuildKit globally through DOCKER_BUILDKIT does not work. That would be desirable in order to use https://github.com/moby/buildkit/blob/master/frontend/dockerfile/docs/syntax.md#build-mounts-run---mount in the dockerfile. For now, I worked around it by using a COPY statement (a layer) instead. Nonetheless, I kept the commit isolated, because it might be reverted when building the image is decoupled from the execution.

    I added a very simple CI workflow for testing the execution of the Action. Yet, since there is no "demo" project here, execution is rather useless. It would be interesting if someone familiar with Verible would contribute an example project in a follow-up PR.

    NOTE: Since GitHub Actions is not enabled in this repository yet, results are not shown below. See https://github.com/umarcor/verible-linter-action/actions

    opened by umarcor 4
  • Always use latest verible

    Always use latest verible

    Similar to the verible-formatter-action, fetch the most recent version of verible and perform the linting.

    Should the same arguments be used as before or should it be done the same way as the formatting action?

    • -f fail fast without html error document
    • -S shows an error message on fail
    • -L follows a redirect
    opened by mole99 3
  • Optimise execution by using a Container Action

    Optimise execution by using a Container Action

    The current implementation of this Action is of type Composite. In the first five steps, the dependencies are downloaded and installed: https://github.com/chipsalliance/verible-linter-action/blob/main/action.yml#L31-L51. In the last step, which is a single bash script, the actual functionality is implemented: https://github.com/chipsalliance/verible-linter-action/blob/main/action.yml#L52-L87.

    I recommend to convert this Action into a Container Action, since having it be a Composite does not provide any meaningful advantage in this use case.

    The advantage of spliting dependency installation into a Dockerfile is that it can be later decoupled. That means, building and deploying the container image on one side, and using it in the action on the other side. As a result, the Action will be executed faster.

    For reference, that approach is used in mithro/actions-includes:

    • https://github.com/mithro/actions-includes/blob/main/action.yml#L27-L29
    • https://github.com/mithro/actions-includes/blob/main/docker/Dockerfile
    • https://github.com/mithro/actions-includes/blob/main/.github/workflows/publish-docker-image.yml

    Similar strategy, without decoupling, in dbhi/qus:

    • https://github.com/dbhi/qus/blob/main/action/action.yml
    • https://github.com/dbhi/qus/blob/main/action/Dockerfile

    and eine/tip:

    • https://github.com/eine/tip/blob/master/action.yml
    • https://github.com/eine/tip/blob/master/Dockerfile
    opened by umarcor 2
  • Push container image to GHCR and use it in the Action

    Push container image to GHCR and use it in the Action

    This is a folloy-up of #4.

    As commented in #3, building the container image separatedly and the using it at runtime can reduce the execution time for users of this Action. In this PR, a workflow is added, which builds image ghcr.io/chipsalliance/verible-linter-action and pushes it to the GitHub Container Registry, using the default token. Then, in the Action, that image is used instead of the Dockerfile.

    • Current execution time (92s): https://github.com/chipsalliance/verible-linter-action/actions/runs/1192256099
    • Image build and push time (131s): https://github.com/umarcor/verible-linter-action/actions/runs/1194493666
    • Execution time using the image (22s): https://github.com/umarcor/verible-linter-action/actions/runs/1194493667

    The workflows are scheduled weekly. Feel free to adjust that to your needs.

    NOTE: CI will fail below because this PR does not have permission for pushing to ghcr.io/chipsalliance. That will work after this is merged to main. Precisely, workflow Container will work as soon as it is merged, and Test will need to be rerun afte the image is pushed for the first time. The references to my fork above did work because I temporarily used ghcr.io/umarcor instead.

    opened by umarcor 1
  • Always use latest verible

    Always use latest verible

    Re-opening of #19 due to an error on my end.

    Similar to the verible-formatter-action, fetch the most recent version of verible and perform the linting.

    opened by mole99 0
  • Colon is missing from error messages produced by reviewdog

    Colon is missing from error messages produced by reviewdog

    Reviewdog reports (e.g. here)

    Unpacked dimension range must be declared in big-endian ([0N-1]) order. Declare zero-based big-endian unpacked dimensions sized as [N]. [Style unpacked-ordering] [unpacked-dimensions-range-ordering]

    Look at the "[0N-1]" string, which should be "[0:N-1]" (the Verible source code agrees with me).

    We somewhere loose the colon in the path between Verible and the GH action reporting.

    opened by imphil 0
  • add GitHub token to test

    add GitHub token to test

    The test would fail because the default reporter is "github-pr-review" and there wasn't a token provided. The reason I change the test, and not the code of the action, is because I assume that the correct usage of the action is to either:

    1. Use a reporter that requires the token ("github-pr-review") AND provide the token.
    2. Use a reporter that doesn't require the token (for example "local").

    The workflow was successful here: https://github.com/antmicro/verible-linter-action/actions/runs/1266083502

    opened by wsipak 0
  • Add action input fail_on_error

    Add action input fail_on_error

    This allows to choose whether the action should fail or not, depending on the result of running Verible. Use fail_on_error: 'true' to fail the action if a rule violation that is relevant to a PR exists.

    For testing purposes, this PRs have been created:

    1. Failing disabled, errors were posted as code review, but the workflow was successful anyway: https://github.com/antmicro/gha-playground/pull/95
    2. Failing enabled, errors were posted as code review and the workflow failed: https://github.com/antmicro/gha-playground/pull/96
    3. Failing enabled, but no rule violations were found, thus the workflow succeeded: https://github.com/antmicro/gha-playground/pull/97
    opened by wsipak 0
  • exit the action without error

    exit the action without error

    Previously, the action would exit with non-zero code whenever rule violations were found, even if the violations did not belong to the changes in PR. We could either change it to return non-zero when violations are relevant, or always return zero. I'm changing this to always exit successfully and my reasoning here is that, if there are relevant violations, we'll see them in code review (so we don't really need the negative flag), and we can use non-zero exit codes for internal errors in the action, not related to output from Verible.

    opened by wsipak 0
  • Fix missing output from action.py

    Fix missing output from action.py

    The newer version of Verible:

    1. Prints rule violations to stderr, not stdout (This caused problems in Ibex repository).
    2. Uses different values for autofix argument (I thought I had added this change already, and I'm adding it now).

    A test PR was recreated here: https://github.com/antmicro/gha-playground/pull/93

    opened by wsipak 0
  • Fix remote url handling when a PR from a fork is created

    Fix remote url handling when a PR from a fork is created

    The action needs to handle two remotes. One for the main repo, and the other for the source of the PR. This wasn't handled properly and is fixed here. The problem appeared here: https://github.com/lowRISC/ibex/pull/1434

    Right now the script retrieves the URL of the remote from event.json and fetches the right branch from it. Additionally, hash of the HEAD is printed so that it's easy to confirm correctness of operation.

    I've checked these scenarios:

    1. The branch used in a PR doesn't exist in the main repo, and it works.
    2. The branch used in a PR does exist in the main repo, and it's actually fetched from the fork. (Previously the script tried to fetch it from mainline)
    opened by wsipak 0
  • List of repos where the action could be used

    List of repos where the action could be used

    We need to compile a list of repositories that contain SystemVerilog or Verilog (even simple test cases) where we could enable the Verible actions.

    Let me start with

    Please comment with suggestions of other repositories CC @hzeller @mkurc-ant @kgugala

    opened by tgorochowik 0
Releases(v1.4)
Owner
CHIPS Alliance
Common Hardware for Interfaces, Processors and Systems
CHIPS Alliance
AminoAutoRegFxck/AutoReg For AminoApps.com

AminoAutoRegFxck AminoAutoRegFxck/AutoReg For AminoApps.com Termux apt update -y apt upgrade -y pkg install python git clone https://github.com/deluvs

3 Jan 18, 2022
Telegram üzerinden paylaşılan kısa linkleri geçmenin daha hızlı bir yolu

Telegram Url skipper Telegramda paylaşılan kısa linkleri geçmenin daha hızlı bir yolu · Hata Raporla · Öneri Yap İçerik Tablosu Kurulum Kullanım Lisan

WarForPeace 6 Oct 07, 2022
Copier template for solving Advent of Code puzzles with Python

Advent of Code Python Template for Copier This template creates scaffolding for one day of Advent of Code. It includes tests and can download your per

Geir Arne Hjelle 6 Dec 25, 2022
Gets instagram public username and returns usefull informations like profilepic(b64), video_urls etc.

InstaSucker Gets instagram public username and returns usefull informations like profilepic(b64), video_urls etc. Information this project contains a

Armin Amiri 5 Apr 30, 2022
A discord bot that autobans blacklisted users by ID and Names

AutoBan A discord bot that autobans blacklisted users by ID and Names Getting Started Dependencies disnake @ git+https://github.com/DisnakeDev/disnake

Jason Martin 0 Oct 02, 2022
A Telegram Bot to display Codeforces Contest Ranklist

CFRankListBot A bot that displays the top ranks for a Codeforces contest. Participants' Details All the details of a participant is in the utils/__ini

Code IIEST 5 Dec 25, 2021
A discord bot that can detect Nitro Scam Links and delete them to protect other users

A discord bot that can detect Nitro Scam Links and delete them to protect other users. Add it to your server from here.

Kanak Mittal 9 Oct 20, 2022
❤️ Hi There Im EzilaX ❤️ A next gen powerful telegram group manager bot 😱 for manage your groups and have fun with other cool modules Made By Sadew Jayasekara 🔥

❤️ EzilaX v1 ❤️ Unmaintained. The new repo of @EzilaXBot is Public. (It is no longer based on this source code. The completely rewritten bot available

Sadew Jayasekara 18 Nov 24, 2021
A Bot To Get Info Of Telegram messages , Media , Channel id Group ID etc.

Info-Bot A Bot To Get Info Of Telegram messages , Media , Channel id Group ID etc. Get Info Of Your And Messages , Channels , Groups ETC... How to mak

Vɪᴠᴇᴋ 23 Nov 12, 2022
Using GNU Radio and HackRF One to Receive, Analyze and Send ASK/OOK signals

play_with_ask NIS-8016 Lab A code: Recv.grc/py: Receive signals and match with ASK button using HackRF and GNU radio. I use AM demod block(can also in

Chen Anxue 1 Jul 04, 2022
Wrapper around the latest Tuenti API

python-tuenti Overview Wrapper around the latest Tuenti API. Installation Install using pip, including any optional packages you want... $ pip install

Juan Riaza 10 Mar 07, 2022
veez music bot is a telegram music bot project, allow you to play music on voice chat group telegram.

🎶 Veez Music Bot Music bot for playing music on telegram voice chat group. Requirements 📝 FFmpeg NodeJS nodesource.com Python 3.7+ PyTgCalls 🧪 Get

levina 143 Jun 19, 2022
CyberTKR - CyberTK-API

CyberTKR - CyberTK-API

TKR 2 Apr 08, 2022
MashaRobot : New Generation Telegram Group Manager Bot (🔸Fast 🔸Python🔸Pyrogram 🔸Telethon 🔸Mongo db )

MashaRobot Me On Telegram ✨ MASHA ✨ This is just a demo bot.. Don't try to add to your group.. Create your own bot How To Host The easiest way to depl

Mr Dark Prince 40 Oct 09, 2022
The most versatile torrent leecher and youtube-dl bot for telegram

TorToolkit Telegram So basically Tortoolkit is aimed to be the most versatile torrent leecher and youtube-dl bot for telegram. This bot is highly cust

αвιנтн 1 Nov 11, 2021
Programa de código abierto para probar el API de Bitso, el exchange más importante de América Latina.

Bitso Semiautomático Programa de código abierto para probar el API de Bitso, el exchange más importante de América Latina. Desarrollador Fernando Mire

Fernando Mireles 17 Dec 07, 2022
We propose the adversarial blur attack (ABA) against visual object tracking.

ABA We propose the adversarial blur attack (ABA) against visual object tracking. The ICCV link: https://arxiv.org/abs/2107.12085 and, https://openacce

Qing Guo 13 Dec 01, 2022
A Telegram Bot to Play Audio in Voice Chats With Youtube and Deezer support. Supports Live streaming from youtube Supports Mega Radio Fm Streamings

Bot To Stream Musics on PyTGcalls with Channel Support. A Telegram Bot to Play Audio in Voice Chats With Supports Live streaming from youtube and Mega

Shamil Habeeb 37 Dec 15, 2022
A Telegram mirror bot which can be deployed using Heroku.

Slam Mirror Bot This is a telegram bot writen in python for mirroring files on the internet to our beloved Google Drive. Getting Google OAuth API cred

Hafitz Setya 1.2k Jan 01, 2023
Telegram bot that let's you flip a coin in a dialog

coin_flip Telegram bot that let's you flip a coin in a dialog Report issue · Request feature About Software development tool that lets you finally dec

Ivan Akostelov 2 Dec 12, 2021