Skip to content

reviewdog/action-ast-grep

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

24 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

GitHub Action: Run ast-grep with reviewdog

Test reviewdog depup release GitHub release (latest SemVer) action-bumpr supported

This is an action to run ast-grep(sg) with reviewdog.

Examples

demo1 demo2

Inputs

github_token

GITHUB_TOKEN The default is ${{ github.token }}.

workdir

Working directory relative to the root directory. The default is ..

tool_name

Tool name to use for reviewdog reporter. The default is ast-grep.

level

Report level for reviewdog [info,warning,error]. The default is error.

reporter

Reporter of reviewdog command [github-check,github-pr-review,github-pr-check]. The default is github-check.

filter_mode

Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. Default is added except that sarif reporter uses nofilter.

fail_level

Optional. If set to none, always use exit code 0 for reviewdog. Otherwise, exit code 1 for reviewdog if it finds at least 1 issue with severity greater than or equal to the given level. Possible values: [none, any, info, warning, error] Default is none.

fail_on_error

Deprecated, use fail_level instead. Exit code for reviewdog when errors are found [true,false]. The default is false.

reviewdog_flags

Additional reviewdog flags.

output_dir

Output directory of reviewdog result. Useful for -reporter=sarif The default is ../reviewdog-results.

sg_version

ast-grep version.

sg_config

The path to the ast-grep config file. The default is sgconfig.yml.

sg_flags

Additional ast-grep flags.

Usage

Basic

Create sgconfig.yml and some rules in your repository by following the project setup guide.

Add a workflow to run action-ast-grep that triggered by pull request event.

name: reviewdog
on: [pull_request]
jobs:
  ast-grep:
    name: runner / ast-grep
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: reviewdog/action-ast-grep@v1
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          # Change reviewdog reporter if you need [github-check,github-pr-review,github-pr-check].
          reporter: github-pr-review
          # Change reporter level if you need.
          # GitHub Status Check won't become failure with warning.
          level: warning
          # path to the sgconfig.yml
          sg_config: sgconfig.yml

Reviewdog will report ast-grep scan result.

Advanced: Use Custom Language Parser

ast-grep experimentally supports custom languages. (ref)

To use this feature with this action, build tree-sitter parsers before calling this action on your workflow.

For building tree-sitter parsers, rinx/setup-tree-sitter-parser is useful.

name: reviewdog
on: [pull_request]
jobs:
  ast-grep:
    name: runner / ast-grep / fennel
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build tree-sitter grammar for fennel
        uses: rinx/setup-tree-sitter-parser@v1
        with:
          # this action will place the build artifact here.
          parser_dir: ./
          parser_repository: alexmozaidze/tree-sitter-fennel
      - name: Run ast-grep with reviewdog
        uses: reviewdog/action-ast-grep@v1
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          level: info
          reporter: github-pr-review

Development

Release

You can bump version on merging Pull Requests with specific labels (bump:major,bump:minor,bump:patch). Pushing tag manually by yourself also work.

This action updates major/minor release tags on a tag push. e.g. Update v1 and v1.2 tag when released v1.2.3. ref: https://help.github.com/en/articles/about-actions#versioning-your-action

Lint - reviewdog integration

This reviewdog action itself is integrated with reviewdog to run lints which is useful for action composition based actions.

reviewdog integration

Supported linters:

Dependencies Update Automation

This repository uses reviewdog/action-depup to update reviewdog version.

reviewdog depup demo