Skip to content

reviewdog/action-black

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Black action

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

github-pr-check demo

This action runs the black formatter with reviewdog on pull requests to improve code review experience.

Quick Start

In it's simplest form this action can be used to annotate the changes the black formatter would make if it was run on the code.

name: reviewdog
on: [pull_request]
jobs:
  linter_name:
    name: runner / black formatter
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      # Install specific version black (this step is not required. default is "black[jupyter]")
      - run: pip install black==23.1.0
      - uses: reviewdog/action-black@v3
        with:
          github_token: ${{ secrets.github_token }}
          # Change reviewdog reporter if you need [github-pr-check, github-check].
          reporter: github-pr-check
          # Change reporter level if you need.
          # GitHub Status Check won't become failure with a warning.
          level: warning

Inputs

github_token

Required. The GITHUB_TOKEN. Must be in form of github_token: ${{ secrets.github_token }}. Defaults to ${{ github.token }}.

workdir

Optional. The directory to run remark-lint in. Defaults to ..

black_args

Optional. Additional black input arguments. Defaults to "".

Warning Because this action uses the black output to create the annotations, it does not work with the black --quiet flag.

verbose

Optional. Set to true to print the black output to the github action console. Defaults to false.

tool_name

Optional. Tool name to use for reviewdog reporter. Defaults to remark-lint.

level

Optional. Report level for reviewdog [info, warning, error]. It's same as -level flag of reviewdog. Defaults to error.

reporter

Optional. Reporter of reviewdog command [github-pr-check, github-pr-review, github-check]. Default is github-pr-check.

filter_mode

Optional. Filtering mode for the reviewdog command [added, diff_context, file, nofilter]. Defaults to added.

fail_on_error

Optional. Exit code for when reviewdog when errors are found [true, false]. Defaults to false.

reviewdog_flags

Optional. Additional reviewdog flags. Defaults to "".

Outputs

Environment variables

BLACK_CHECK_FILE_PATHS

Contains all the files that would be changed by black.

Format your code

This action is meant to annotate any possible changes that would need to be made to make your code adhere to the black formatting guidelines. It does not apply these changes to your codebase. If you also want to apply the changes to your repository, you can use the reviewdog/action-suggester. You can find examples of how this is done can be found in rickstaa/action-black