update shellcheck stuff #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ------------------------------------------------------------------------------ | |
| # OraDBA - Oracle Database Infrastructure and Security, 5630 Muri, Switzerland | |
| # ------------------------------------------------------------------------------ | |
| # Name.......: lint.yml | |
| # Author.....: Stefan Oehrli (oes) stefan.oehrli@oradba.ch | |
| # Editor.....: Stefan Oehrli | |
| # Date.......: 2025.12.12 | |
| # Version....: v4.0.0 | |
| # Purpose....: Lint and format checks for fast feedback on PRs | |
| # Notes......: Triggered on pull_request and push to master/dev | |
| # Reference..: https://github.com/oehrlis/oudbase | |
| # License....: Apache License Version 2.0, January 2004 as shown | |
| # at http://www.apache.org/licenses/ | |
| # ------------------------------------------------------------------------------ | |
| # Modified...: | |
| # see git revision history with git log for more information on changes | |
| # ------------------------------------------------------------------------------ | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - master | |
| - dev | |
| jobs: | |
| shfmt-check: | |
| name: shfmt --check | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Guard .gitmodules/submodules | |
| shell: bash | |
| run: | | |
| if [ -f .gitmodules ]; then | |
| git submodule sync --recursive || true | |
| fi | |
| - name: Install shfmt | |
| run: | | |
| mkdir -p "$HOME/bin" | |
| SHFMT_VERSION=3.7.0 | |
| curl -sSLf "https://github.com/mvdan/sh/releases/download/v${SHFMT_VERSION}/shfmt_v${SHFMT_VERSION}_linux_amd64" -o "$HOME/bin/shfmt" | |
| chmod +x "$HOME/bin/shfmt" | |
| echo "$HOME/bin" >> $GITHUB_PATH | |
| - name: Run shfmt (check) | |
| run: | | |
| export PATH="$PATH:$HOME/go/bin" | |
| # adjust globs to match your scripts | |
| set -o pipefail | |
| files=$(git ls-files '*.sh' 'src/bin/*' 'scripts/*.sh' 'test/bats/*.bash' || true) | |
| if [ -z "$files" ]; then | |
| echo "No shell files found" | |
| exit 0 | |
| fi | |
| echo "$files" | xargs shfmt -d || (echo "Run 'make fmt' to fix" && exit 1) | |
| shellcheck: | |
| name: shellcheck | |
| runs-on: ubuntu-latest | |
| needs: shfmt-check | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install shellcheck | |
| run: | | |
| sudo apt-get update -y | |
| sudo apt-get install -y shellcheck | |
| shellcheck --version | |
| - name: Run shellcheck | |
| run: | | |
| files=$(git ls-files '*.sh' 'src/bin/*' 'scripts/*.sh' 'test/bats/*.bash' || true) | |
| if [ -z "$files" ]; then | |
| echo "No shell files found" | |
| exit 0 | |
| fi | |
| # run shellcheck in parallel-ish | |
| echo "$files" | xargs -n1 shellcheck -x || (echo "shellcheck issues found" && exit 1) |