Giter Club home page Giter Club logo

action-shellcheck's Introduction

GitHub Action: Run shellcheck with reviewdog

Docker Image CI depup release GitHub release (latest SemVer) action-bumpr supported

This action runs shellcheck with reviewdog on pull requests to improve code review experience.

github-pr-check sample github-pr-review sample

Inputs

github_token

Optional. ${{ github.token }} is used by default.

level

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

reporter

Reporter of reviewdog command [github-pr-check,github-pr-review,github-check]. Default is github-pr-check. github-pr-review can use Markdown and add a link to rule page in reviewdog reports.

filter_mode

Optional. Filtering mode for the reviewdog command [added,diff_context,file,nofilter]. Default is file.

fail_on_error

Optional. Exit code for reviewdog when errors are found [true,false] Default is false.

reviewdog_flags

Optional. Additional reviewdog flags

path

Optional. Base directory to run shellcheck. Same as [path] of find command. Default: .

Directories are separated by lines. e.g.:

path: |
  tools
  src

pattern

Optional. File patterns of target files. Same as -name [pattern] of find command. Default: *.sh

Patterns are separated by lines. e.g.:

pattern: |
  *.bash
  *.sh

exclude

Optional. Exclude patterns of target files. Same as -not -path [exclude] of find command. Default: */.git/*

Patterns are separated by lines. e.g.:

exclude: |
  */.git/*
  ./.cache/*

check_all_files_with_shebangs

Optional. Checks all files with shebangs in the repository even if they do not match pattern. Default is false.

shellcheck_flags

Optional. Flags of shellcheck command. Default: --external-sources

Example usage

name: reviewdog
on: [pull_request]
jobs:
  shellcheck:
    name: runner / shellcheck
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: shellcheck
        uses: reviewdog/action-shellcheck@v1
        with:
          github_token: ${{ secrets.github_token }}
          reporter: github-pr-review # Change reporter.
          path: "." # Optional.
          pattern: "*.sh" # Optional.
          exclude: "./.git/*" # Optional.
          check_all_files_with_shebangs: "false" # Optional.

Known issue

Running shellcheck.exe on Windows might fail with the following error:

SC1017: Literal carriage return. Run script through tr -d '\r'

This is due to the presence of a carriage return character (\r) in the script.

To fix this, you can simply create or edit the .gitattributes file in the root of your repository with the following contents:

*.sh text eol=lf

This would ensure that the scripts are checked out with the correct line ending.

action-shellcheck's People

Contributors

github-actions[bot] avatar grische avatar haya14busa avatar jackton1 avatar lucianposton avatar mgrachev avatar renovate-bot avatar renovate[bot] avatar review-dog avatar shogo82148 avatar sksat avatar slamdunk 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

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

action-shellcheck's Issues

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
  • reviewdog/action-depup 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
.github/workflows/update_semver.yml
  • actions/checkout v4
  • haya14busa/action-update-semver v1
action.yml
  • reviewdog/action-setup v1

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

Error installing koalaman/shellcheck wget command not found

Error occurs when using windows/macOS GitHub runners

Related Logs

Installing shellcheck ... https://github.com/koalaman/shellcheck
  D:\a\_actions\reviewdog\action-shellcheck\v1/script.sh: line 8: wget: command not found
  xz: (stdin): File format not recognized
  tar: Child returned status 1
  tar: Error is not recoverable: exiting now
  cp: cannot stat 'shellcheck-v0.9.0/shellcheck': No such file or directory
 Running shellcheck ...
  D:\a\_actions\reviewdog\action-shellcheck\v1/script.sh: line 72: shellcheck: command not found
  reviewdog: EOF
 Running shellcheck (suggestion) ...
  D:\a\_actions\reviewdog\action-shellcheck\v1/script.sh: line 88: shellcheck: command not found
Error: Process completed with exit code 1.

Exclude multiple folders

How do I exclude multiple folders? I have tried :
exclude: './.git/* , ./vendor/*'
exclude: './.git/* ./vendor/*'

pattern / exclude is too granular

Many shell scripts have no '.sh' suffix and but if we omit the pattern, this action checks all files in the repo except those excluded. This isn't terribly useful.

It would be nice if the files could be filtered by their shebang somehow.

fatal: ls-files -i must be used with either -o or -c

I'm actively exploring what's going on here - in Magma's GH Action execution of hadolint. This has started failing very recently with the below.

Error message.

 Running hadolint with reviewdog ๐Ÿถ ...
  reviewdog: This is Pull-Request from forked repository.
  GitHub token doesn't have write permission of Review API, so reviewdog will
  report results via logging command [1] and create annotations similar to
  github-pr-check reporter as a fallback.
  fatal: ls-files -i must be used with either -o or -c
  [1]: https://help.github.com/en/actions/automating-your-workflow-with-github-actions/development-tools-for-github-actions#logging-commands
  parse error: Invalid numeric literal at line 1, column 7
  reviewdog: parse error: failed to unmarshal rdjson (DiagnosticResult): proto: syntax error (line 1:1): unexpected token 
Error: Process completed with exit code 1.

Our GH Action.

name: reviewdog
on: [pull_request]
jobs:
  shellcheck:
    name: runner / shellcheck
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - name: shellcheck
        uses: reviewdog/action-shellcheck@v1
        with:
          github_token: ${{ secrets.github_token }}
          filter_mode: added # Any added or changed content.
          reporter: github-pr-review # Post code review comments. Falls back to Annotations.
          pattern: "*.sh" # Optional.
          # Other options omitted here but possible.
          # - fail_on_error
          # - path
          # - exclude
          # - shellcheck_flags

Duplicate comments when suggestions exist

Hi there-

We're using this action with reporter: github-pr-review, and when an issue can be fixed by suggestion, we get two comments:

Is it possible to avoid this and only get the [shellcheck (suggestion)] comment when something is auto-fixable and only get the [shellcheck] comment when it's not?

Or, ideally, they should be combined:

[shellcheck] reported by reviewdog

Double quote to prevent globbing and word-splitting. SC2086

- echo $example
+ echo "$example"

Level seems to have no effect

I've configured level: style and while that produces quite a few errors locally, reviewdog/action-shellcheck does not fail the build. None of the errors I see locally are printed anywhere by reviewdog/action-shellcheck. Have I configured it wrong, somehow?

- name: Shellcheck
  uses: reviewdog/action-shellcheck@v1
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}
    reporter: github-pr-review
    level: style

Help needed: some errors message, problems with the filter and spaghetti code

Hi, I am having a couple of issues with using this action and I would like to receive help.

1) The first thing is that a warning message is being displayed when I use it. I would like to know if this is completely normal or is it a bug?

2020-07-15-183658_956x234_scrot

2) The second thing is, I'd like to know how I can run shellcheck over my entire file, rather than just the diff.
I have tried using the filter_mode: nofilter and filter_mode: file parameters but they were not successful (it may be due to the previous error)

The same message for both was:
2020-07-15-183708_636x39_scrot

3) And finally, I have spaghetti code in my action because I want to run shellcheck against a lot of different files that don't have any similitude in the name, is there any solution for it?

Here is my action:

name: Linter [develop]

on:
  pull_request:
    branches:
      - develop

jobs:
  linter:
    name: Linter
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Code
        uses: actions/checkout@v2

      - name: Super-Linter
        uses: github/[email protected]
        env:
          VALIDATE_ALL_CODEBASE: false

      # Spaghetti code

      - name: shellcheck for ~/.zshrc
        uses: reviewdog/[email protected]
        with:
          pattern: ".zshrc"
          github_token: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }}
          filter_mode: file
          shellcheck_flags: '-s sh -e 1090,2004,2039'

      - name: shellcheck for ~/.local/bin/change-background
        uses: reviewdog/[email protected]
        with:
          pattern: "change-background"
          github_token: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }}
          filter_mode: file
          shellcheck_flags: '-s sh -e 1090,2004,2039'

      - name: shellcheck for ~/.local/bin/start-script
        uses: reviewdog/[email protected]
        with:
          pattern: "start-script"
          github_token: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }}
          filter_mode: file
          shellcheck_flags: '-s sh -e 1090,2004,2039'

Thanks for your time โญ

License missing

Hi,

I am considering opening a pull request against this repository (see #2), but currently this repository is missing a license file.

Scope clarification

Hi! this may be a stupid question so I'm sorry in advance if this is not the place for it.

When reviewdog reviews a PR with shellcheck, does it look only at the changes made in the PR or does it look at everything in the repo?

I have a bash repo in which I want to use this action, but shellcheck has a lot of problems with it so checking the codebase with shellcheck right now is pretty much useless since every file will be flagged with something.
I wanted to avoid introducing even more problems in the repo while I fix all shellcheck complaints, so I wanted to run shellcheck only on the things changed in the PR. Is this something possible to do with this action? Will this action only spot the new problems introduced in the PR or will it complain about everything that was already wrong even before the PR?

Thank you for your time and the amazing tool!

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.