1
0
Fork 0
mirror of https://github.com/ludeeus/action-shellcheck.git synced 2024-08-16 10:09:53 +02:00
Find a file
Arkadiusz Bokowy 10434c2598
Fix warnings reported by shellcheck (#61)
Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>
2022-09-03 10:31:50 +02:00
.github Fix warnings reported by shellcheck (#61) 2022-09-03 10:31:50 +02:00
testfiles Fix warnings reported by shellcheck (#61) 2022-09-03 10:31:50 +02:00
.gitattributes Add exclude and testfiles 2020-05-30 11:44:01 +02:00
action.yaml Fix warnings reported by shellcheck (#61) 2022-09-03 10:31:50 +02:00
LICENSE Move action to composite (#31) 2020-10-25 21:00:46 +01:00
README.md Exact path matching ignore path (#59) 2022-09-03 10:29:32 +02:00

ShellCheck

GitHub action for ShellCheck.

Example

on:
  push:
    branches:
      - master

name: "Trigger: Push action"

jobs:
  shellcheck:
    name: Shellcheck
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Run ShellCheck
        uses: ludeeus/action-shellcheck@master

ShellCheck options

You can pass any supported ShellCheck option or flag with the SHELLCHECK_OPTS env key in the job definition.

Some examples include:

  • To disable specific checks (eg: -e SC2059 -e SC2034 -e SC1090)
  • To test against different shells (eg: -s dash or -s ksh)

example:

    ...
    - name: Run ShellCheck
      uses: ludeeus/action-shellcheck@master
      env:
        SHELLCHECK_OPTS: -e SC2059 -e SC2034 -e SC1090

Ignore paths and names

You can use the ignore_paths and ignore_names input to disable specific directories and files.

sample structure:
sample/directory/with/files/ignoreme/test.sh
sample/directory/with/files/ignoremetoo/test.sh
sample/directory/with/files/test.sh
sample/directory/with/files/ignorable.sh

example:

    ...
    - name: Run ShellCheck
      uses: ludeeus/action-shellcheck@master
      with:
        ignore_paths: ignoreme ignoremetoo
        ignore_names: ignorable.sh

This will skip sample/directory/with/files/ignoreme/test.sh, sample/directory/with/files/ignoremetoo/test.sh and sample/directory/with/files/ignorable.sh.

You can also ignore specific files using full paths or glob patterns with ignore_paths.

example:

    ...
    - name: Run ShellCheck
      uses: ludeeus/action-shellcheck@master
      with:
        ignore_paths: ./sample/directory/with/files/ignorable.sh **/ignoreme/test.sh

This will skip sample/directory/with/files/ignorable.sh and sample/directory/with/files/ignoreme/test.sh.

Minimum severity of errors to consider (error, warning, info, style)

You can use the severity input to not fail until specified severity is met, for example fail only if there are errors in scripts but ignore styling, info and warnings.

example:

    ...
    - name: Run ShellCheck
      uses: ludeeus/action-shellcheck@master
      with:
        severity: error

Run shellcheck with all paths in a single invocation

If you run into SC1090/SC1091 errors you may need to tell shellcheck to check all files at once:

    ...
    - name: Run ShellCheck
      uses: ludeeus/action-shellcheck@master
      with:
        check_together: 'yes'

This can turn into a problem if you have enough script files to overwhelm the maximum argv length on your system.

Run shellcheck only in a single directory

If you have multiple directories with scripts, but only want to scan one of them, you can use the following configuration:

   ...
   - name: Run ShellCheck
     uses: ludeeus/action-shellcheck@master
     with:
       scandir: './scripts'

Scan for additional files

If you need to scan for unusual files, you can use the additional_files key.

   ...
   - name: Run ShellCheck
     uses: ludeeus/action-shellcheck@master
     with:
       additional_files: 'run finish'

Disable problem matcher

If you do not want to have the problem-matcher annotate files, you can disable it by setting disable_matcher to true.

   ...
   - name: Run ShellCheck
     uses: ludeeus/action-shellcheck@master
     with:
       disable_matcher: true

Change output format

Shellcheck can print output in these formats: checkstyle, diff, gcc, json, json1, quiet, tty. See some examples here. Only tty and gcc produce file annotations via problem matcher, default is gcc.

  • tty has multi-line log messages, but all annotations are reported as errors
  • gcc has single-line log messages, so it's easier to parse with a problem matcher (including correct severity annotation)
   ...
   - name: Run ShellCheck
     uses: ludeeus/action-shellcheck@master
     with:
       format: tty

Run a specific version of Shellcheck

If running the latest stable version of Shellcheck is not to your liking, you can specify a concrete version of Shellcheck to be used. When specifying a custom version, please use any of the released versions listed in the Shellcheck repository.

   ...
   - name: Run ShellCheck
     uses: ludeeus/action-shellcheck@master
     with:
       version: v0.7.0