Giter Site home page Giter Site logo

action-suggester's Introduction

action-suggester

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

shfmt demo shellcheck demo gofmt demo multiline demo

action-suggester is a handy action which suggests any code changes based on diff through GitHub Multi-line code suggestions by using reviewdog.

You can use any formatters or linters with auto-fix feature for any languages and the reviewdog suggester support any changes including inline change, multi-line changes, insertion, and deletion.

Input

inputs:
  github_token:
    description: 'GITHUB_TOKEN'
    default: '${{ github.token }}'
  ### Flags for reviewdog ###
  tool_name:
    description: 'Tool name to use for reviewdog reporter'
    default: 'reviewdog-suggester'
  level:
    description: 'Report level for reviewdog [info,warning,error]'
    default: 'warning'
  filter_mode:
    description: |
      Filtering mode for the reviewdog command [added,diff_context,file,nofilter].
      Default is diff_context. GitHub suggestions only support added and diff_context.
    default: 'diff_context'
  fail_on_error:
    description: |
      Exit code for reviewdog when errors are found [true,false]
      Default is `false`.
    default: 'false'
  reviewdog_flags:
    description: 'Additional reviewdog flags'
    default: ''
  ### Flags for reviewdog suggester ###
  cleanup:
    description: 'Clean up non-committed changes after the action'
    default: 'true'

Required Permissions

The action requires the following permissions:

permissions:
  contents: read
  checks: write
  issues: write
  pull-requests: write

See Assigning permissions to jobs for more details.

Usage Example

name: reviewdog-suggester
on: [pull_request] # Support only pull_request event.
jobs:
  go:
    name: runner / suggester / gofmt
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - run: gofmt -w -s .
      - uses: reviewdog/action-suggester@v1
        with:
          tool_name: gofmt
  shell:
    name: runner / suggester / shell
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-go@v4
      - run: go install mvdan.cc/sh/v3/cmd/shfmt@latest

      - run: shfmt -i 2 -ci -w .
      - name: suggester / shfmt
        uses: reviewdog/action-suggester@v1
        with:
          tool_name: shfmt

      # Need to install latest shellcheck to use diff output format as of writing (2020/08/03).
      - name: install shellcheck
        run: |
          scversion="latest"
          wget -qO- "https://github.com/koalaman/shellcheck/releases/download/${scversion?}/shellcheck-${scversion?}.linux.x86_64.tar.xz" | tar -xJv
          sudo cp "shellcheck-${scversion}/shellcheck" /usr/local/bin/
          rm -rf "shellcheck-${scversion}/shellcheck"
      - run: shellcheck -f diff $(shfmt -f .) | patch -p1
      - name: suggester / shellcheck
        uses: reviewdog/action-suggester@v1
        with:
          tool_name: shellcheck

action-suggester's People

Contributors

github-actions[bot] avatar haya14busa avatar kengotoda avatar renovate-bot avatar renovate[bot] avatar review-dog avatar shogo82148 avatar sksat avatar

Stargazers

 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  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  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  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-suggester's Issues

Suggester with Rubocop and Github Actions

How can I use this action suggester with action-rubocop and github actions?

This is my .rubocop.yml file

name: Rubocop
on: [pull_request]
jobs:
  rubocop:
    name: Rubocop
    runs-on: ubuntu-latest
    env:
      RAILS_ENV: development
    steps:
      - name: Check out code
        uses: actions/checkout@v1
      - uses: ruby/setup-ruby@v1
        with:
          ruby-version: 2.5.8
      - name: rubocop
        uses: reviewdog/action-rubocop@v1
        with:
          rubocop_version: gemfile
          rubocop_extensions: rubocop-rails:gemfile rubocop-rspec:gemfile
          github_token: ${{ secrets.github_token }}
          reporter: github-pr-review

Can't really make it work with ESLint

First of all, thanks for the massive efforts around reviewdog. It's in plain sight the amount of work you poured in for everybody to enjoy.

I have been trying to set reviewdog in my CI on Github Actions and I only managed to get reports in the PR like this:
image

But never to get code comments/suggestions.

This is my current action file:

name: reviewdog
on: [pull_request]
jobs:
  eslint:
    runs-on: ubuntu-latest

    name: runner / eslint

    steps:
      - uses: actions/checkout@v2
        with:
          submodules: recursive
          token: ${{ secrets.CI_ACCESS_TOKEN }}

      - uses: reviewdog/action-setup@v1
        with:
          reviewdog_version: latest

      - uses: reviewdog/action-eslint@v1
        env:
          REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          reporter: github-pr-review
          level: error
          filter_mode: added
      
      - uses: reviewdog/action-suggester@v1
        with:
          tool_name: eslint

Is there anything I'm missing?

In my understanding the reviewdog/action-eslint@v1 action will output the result and the reviewdog/action-suggester@v1 will print it as comments/suggestions. But really can't manage to make this work ๐Ÿคท๐Ÿปโ€โ™‚๏ธ

Thank you so much for any help.

Cleanup never runs if reviewdog fails making cleanup behaviour appear incorrect compared to intention

The action script contains set -e which tells bash to exit if any command fails:

Further down however it expects to be able to capture the exit code of executing the reviewdog binary:

EXIT_CODE=$?

But any non zero code would cause a termination before reaching that line.

Essentially the following might give the impression that some cleanup is done if the reviewdog command fails, but it's not, if the exit code is anything other than 0, the following block never gets run:

EXIT_CODE=$?

if [ "${INPUT_CLEANUP}" = "true" ]; then
  git stash drop || true
else
  git stash pop || true
fi

exit "${EXIT_CODE}"

Previously there was an || EXIT_CODE=$? that was removed as part of https://github.com/reviewdog/action-suggester/pull/31/files but this doesn't see correct if errexit is set

Instead it would appear that the command should use an && as well as an || to capture the exit code on the same line and ensure the line exit code is 0:

reviewdog \
  -name="${INPUT_TOOL_NAME:-reviewdog-suggester}" \
  -f=diff \
  -f.diff.strip=1 \
  -reporter="github-pr-review" \
  -filter-mode="${INPUT_FILTER_MODE}" \
  -fail-on-error="${INPUT_FAIL_ON_ERROR}" \
  -level="${INPUT_LEVEL}" \
  ${INPUT_REVIEWDOG_FLAGS} <"${TMPFILE}" && EXIT_CODE=$? || EXIT_CODE=$?

`/run/github-runner/runner1/_actions/reviewdog/action-setup/v1/install.sh: cannot execute: required file not found`

Hello,

I got an issue while working on input-output-hk/haskell.nix#1983, you can see the logs here:

Run reviewdog/action-suggester@v1
  with:
    tool_name: deadnix
    github_token: ***
    level: warning
    filter_mode: diff_context
    fail_on_error: false
    cleanup: true
  env:
    NIX_PATH: nixpkgs=channel:nixos-unstable
Run reviewdog/action-setup@v1
  with:
    reviewdog_version: v0.14.2
  env:
    NIX_PATH: nixpkgs=channel:nixos-unstable
Run $GITHUB_ACTION_PATH/install.sh
  $GITHUB_ACTION_PATH/install.sh
  shell: /nix/store/8fv91097mbh5049i9rglc73dx6kjg3qk-bash-5.2-p15/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    NIX_PATH: nixpkgs=channel:nixos-unstable
    REVIEWDOG_VERSION: v0.14.2
    REVIEWDOG_TEMPDIR: /run/github-runner/runner1/_temp
/run/github-runner/runner1/_temp/4afc4738-e60d-4450-b422-c30a1edec6b7.sh: line 1: /run/github-runner/runner1/_actions/reviewdog/action-setup/v1/install.sh: cannot execute: required file not found
Error: Process completed with exit code 127.

โ€ฆ which is surprising since my workflow code is pretty straightforward, where the issue could potentially come from?

  deadnix:
    runs-on: [self-hosted, linux]
    steps:
      - uses: actions/checkout@v3
      - run: nix run github:astro/deadnix -- --edit --no-lambda-pattern-names
      - uses: reviewdog/action-suggester@v1
        with:
          tool_name: deadnix

Ability to add text to include when comment posted with checks fallback

I am currently trying to workout best way to deal with JuliaDiff/ChainRulesCore.jl#489
where the suggester action doesn't have the permissions needed to make a suggestion to a PR from a fork.

One thing that might help is if I could define a string so that every comment make using the check fallback (that doesn't allow the "apply suggestion") includes that string, which would be something like:

To automatically format the whole repo (and thus fix this and other issues) run ...

need to update Go

see https://github.com/reviewdog/action-suggester/actions/runs/5253534837/jobs/9490984742?pr=29

#29

 go: downloading mvdan.cc/sh v1.3.1
go: downloading mvdan.cc/sh/v3 v3.6.0
go: downloading mvdan.cc/sh v2.6.4+incompatible
go: downloading github.com/google/renameio/v2 v2.0.0
go: downloading github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e
go: downloading golang.org/x/term v0.3.0
go: downloading mvdan.cc/editorconfig v0.2.0
go: downloading golang.org/x/sys v0.3.0
# golang.org/x/sys/unix
Error: ../../../go/pkg/mod/golang.org/x/[email protected]/unix/syscall.go:83:16: undefined: unsafe.Slice
Error: ../../../go/pkg/mod/golang.org/x/[email protected]/unix/syscall_linux.go:2256:9: undefined: unsafe.Slice
Error: ../../../go/pkg/mod/golang.org/x/[email protected]/unix/syscall_unix.go:118:7: undefined: unsafe.Slice
Error: ../../../go/pkg/mod/golang.org/x/[email protected]/unix/sysvshm_unix.go:33:7: undefined: unsafe.Slice
note: module requires Go 1.17
# mvdan.cc/sh/v3/fileutil
Error: ../../../go/pkg/mod/mvdan.cc/sh/[email protected]/fileutil/file.go:65:24: undefined: fs.FileInfoToDirEntry
note: module requires Go 1.18
Error: Process completed with exit code 2.

We use Go 1.16 now, whether it doesn't support unsafe.Slice.
unsafe.Slice requires Go 1.17: https://pkg.go.dev/unsafe#Slice

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
  • reviewdog/action-depup v1
  • actions/checkout v4
  • shogo82148/actions-commit-and-create-pr v1
.github/workflows/release.yml
  • actions/checkout v4
  • haya14busa/action-bumpr v1
  • haya14busa/action-update-semver v1
  • haya14busa/action-cond v1
  • actions/checkout v4
  • haya14busa/action-bumpr v1
.github/workflows/reviewdog.yml
  • actions/checkout v4
  • haya14busa/action-cond v1
  • reviewdog/action-shellcheck v1
  • actions/checkout v4
  • reviewdog/action-shfmt v1
  • actions/checkout v4
  • reviewdog/action-actionlint v1
  • actions/checkout v4
  • reviewdog/action-misspell v1
  • actions/checkout v4
  • reviewdog/action-alex v1
.github/workflows/test.yml
  • actions/checkout v4
  • actions/checkout v4
  • actions/setup-go v5

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

Action only works on workflows triggered by PR

I would like to use reviewdog in a workflow that is not directly triggered by a Pull Request but only indirectly, by another workflow which is triggered by a PR. I'm trying to copy langchain4j/langchain4j#673 but with reviewdog instead of the google code suggester. Security concerns are the reason to split formatting and suggesting into different workflows. But for all I've tried I couldn't make reviewdog work when the request wasn't triggered by a Pull Request.
Is this by design? Then please consider this a feature request: The action should also work when triggered by workflow_run.
If it is not by design and is actually supposed to work could you please have a look at https://github.com/timo-a/jackson-core/actions/runs/8638440591/job/23682897275?
The logs say reviewdog: this is not PullRequest build.
The workflow is: https://github.com/timo-a/jackson-core/blob/a847f5e655643e98242f40fad57ec6c23dd490c6/.github/workflows/comment-pr.yml and depends on https://github.com/timo-a/jackson-core/blob/a847f5e655643e98242f40fad57ec6c23dd490c6/.github/workflows/receive-pr.yml.
Other Workflows do make a suggestion on timo-a/jackson-core#2 however they are all triggered by a pull_request

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.