Giter Club home page Giter Club logo

action-black's Introduction

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

action-black's People

Contributors

chadsr avatar github-actions[bot] avatar haya14busa avatar renovate[bot] avatar review-dog avatar rickstaa avatar shogo82148 avatar sksat avatar tsuyoshicho avatar weargoggles avatar yamap55 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

action-black's Issues

Allow user to select the version of black to mitigate the effects of braking update of black

black can be updated brakingly in every year;

ref: https://black.readthedocs.io/en/stable/the_black_code_style/index.html#stability-policy

The first release in a new calendar year may contain formatting changes, although these will be minimised as much as possible. This is to allow for improved formatting enabled by newer Python language syntax as well as due to improvements in the formatting logic.

As a result, existing CIs may not be able to be passed, like https://github.com/ut-issl/c2a-core/actions/runs/4061389376/jobs/6991355742

Black and reviewdog exit codes reference

Here a small exit codes overview that can be used during the action development.

Reviewdog exit codes

As explained in the documentation reviewdog always returns 0 unless fail_on_error is enabled.

Black exit codes

Exit codes without formatting

Error type Exit code
Linting errors found 1
No linting errors found 0
Input argument error 2
Internal error (e.g. python syntax error) 123

Exit codes with formatting

Error type Exit code
Formatting not needed 0
Formatting successful 0
Input argument error 2
Internal error (e.g. python syntax error) 123

Stderr/stdout behavoir

Black writes the logs and errors to the stderr. The diff output is written to the stdout.

suggestion: black formatting suggest

suggestion

black skip github-pr-review reviewdog's report.
That's all right.

And I suggest reporting fixed result suggestion support.

see https://github.com/reviewdog/reviewdog#diff

$ black --help


  --diff                          Don't write the files back, just output a
                                  diff for each file on stdout.

process: --diff alternate --check and format diff or fix and git diff report.

How about trying this?

error: When repoter "github-pr-review" error occur

# remove last two lines of black output, since they are irrelevant
unset "black_check_file_paths[-1]"
unset "black_check_file_paths[-1]"

Nomally: reporter: "github-check" work fine
https://github.com/tsuyoshicho/pytest-sample/runs/6803763036?check_suite_focus=true

But, reporter: "github-pr-review" error occur
https://github.com/tsuyoshicho/pytest-sample/runs/6803765264?check_suite_focus=true

/home/runner/work/_actions/reviewdog/action-black/v3/entrypoint.sh: line 68: unset: [-1]: bad array subscript

github-pr-review using command are different output?

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/depup.yml
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • reviewdog/action-depup v1
  • peter-evans/create-pull-request v6
.github/workflows/release.yml
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • haya14busa/action-bumpr v1
  • haya14busa/action-update-semver v1
  • haya14busa/action-cond v1
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • haya14busa/action-bumpr v1
.github/workflows/reviewdog.yml
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • haya14busa/action-cond v1
  • reviewdog/action-shellcheck v1
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • reviewdog/action-misspell v1
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • reviewdog/action-alex v1
.github/workflows/test.yml
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332
  • actions/checkout v4.1.7@692973e3d937129bcbf40652eb9f2f61becf3332

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.