chipsalliance / verible-linter-action

Automatic SystemVerilog linting in github actions with the help of Verible
Apache License 2.0
27 stars 13 forks source link

Verible Linter Action

This action uses Verible to identify coding style issues in SystemVerilog code.

verible linter 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. If you want to declare Verible version to be used, you can pass its release tag in the input verible_version.

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/checkout@master
    - uses: chipsalliance/verible-linter-action@main
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}

You can provide optional arguments to specify paths, exclude paths, extensions of tested files, a config file, Verible version and extra arguments for verible-verilog-lint.

- uses: chipsalliance/verible-linter-action@main
  with:
    config_file: 'config.rules'
    paths: |
      ./rtl
      ./shared
    exclude_paths: |
      ./rtl/some_file
    extra_args: "--check_syntax=true"
    verible_version: "v0.0-3100-gd75b1c47"
    extensions: |
      .sv
      .v
      .vh
      .svh
    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 change your workflow to trigger on pull_request_target event and manually check out changes from pull request:


name: Verible linter example
on:
  pull_request_target:

jobs:
  lint:
    runs-on: ubuntu-latest
    permissions:
      checks: write
      contents: read
      pull-requests: write
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - name: Run Verible action
        uses: chipsalliance/verible-linter-action@main
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}