Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add shellcheck step to PR process. #1507

Open
trackleft opened this issue Apr 25, 2022 · 3 comments
Open

Add shellcheck step to PR process. #1507

trackleft opened this issue Apr 25, 2022 · 3 comments

Comments

@trackleft
Copy link
Member

Motivation

It would be good to find errors in our bash script files before updating the main branch.

Is your feature request related to a problem? Please describe.

This is more of a prevention step to make it easier for non bash experts to contribute bash scripts to the project.

Proposed Resolution

Use something similar to this.

name: Pull request checks
on: pull_request

jobs:
  lint-bash:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v1
      - name: Run ShellCheck
        uses: azohra/[email protected]
        with:
          exclude-paths: Dockerfile, .github/CODEOWNERS, .github/ISSUE_TEMPLATE

@mmunro-ltrr
Copy link
Member

mmunro-ltrr commented Apr 25, 2022

One extra comment (going here, but applies to the analogous issues in other repositories): we might want to promote a more generic shell than Bash! Particularly now that it isn't the default shell on MacOS, but there are minor efficiencies in going with some other shells in particular cases (this made a difference to runtimes for git under Linux). The Debian Linux distribution actually deprecated the use of Bash in favor of a generic POSIX shell (with support for local variables the only non-standard feature). The only thing that's been more difficult to work around after avoiding bash has been the failure status of chains of piped commands.

See
az-digital/az-digital-devops#3
az-digital/az-icons#28
az-digital/arizona-bootstrap#465
az-digital/az-quickstart-pantheon#85
az-digital/az-quickstart-scaffolding#63

@trackleft
Copy link
Member Author

trackleft commented Apr 25, 2022

Should we add the following from the docs?
https://github.com/marketplace/actions/shellcheck#shellcheck-options

      env:
        SHELLCHECK_OPTS: --shell sh
[-s](https://www.mankier.com/1/shellcheck#-s) shell, --shell=shell
Specify Bourne shell dialect. Valid values are sh, bash, dash and ksh. The default is to deduce the shell from the file's shell directive, shebang, or .bash/.bats/.dash/.ksh extension, in that order. sh refers to POSIX sh (not the system's), and will warn of portability issues.

@mmunro-ltrr
Copy link
Member

@trackleft : the option to deduce it from the files is nicer (particularly when it can follow the shebang line, which makes it easy to change the shell actually used by script files). That way it can check Bash-specific details for scripts that still need it, but still complain about Bashisims in generic shell scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants