mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 16:14:44 +00:00
52 lines
1.4 KiB
YAML
52 lines
1.4 KiB
YAML
name: Shell Format & Lint
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- '**/*.sh'
|
|
- mole
|
|
pull_request:
|
|
paths:
|
|
- '**/*.sh'
|
|
- mole
|
|
|
|
jobs:
|
|
format-lint:
|
|
runs-on: macos-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install shfmt and shellcheck
|
|
run: brew install shfmt shellcheck
|
|
|
|
- name: Run shfmt in diff mode
|
|
run: |
|
|
set -euo pipefail
|
|
files=()
|
|
while IFS= read -r -d '' file; do
|
|
files+=("$file")
|
|
done < <(find . -type f \( -name '*.sh' -o -name 'mole' \) \
|
|
! -path './.git/*' ! -path './tests/tmp-*' -print0)
|
|
if (( ${#files[@]} == 0 )); then
|
|
echo "No shell files found; skipping shfmt"
|
|
exit 0
|
|
fi
|
|
shfmt -i 4 -ci -sr -d "${files[@]}"
|
|
|
|
- name: Run shellcheck
|
|
run: |
|
|
set -euo pipefail
|
|
files=()
|
|
while IFS= read -r -d '' file; do
|
|
files+=("$file")
|
|
done < <(find . -type f \( -name '*.sh' -o -name 'mole' \) \
|
|
! -path './.git/*' ! -path './tests/tmp-*' -print0)
|
|
if (( ${#files[@]} == 0 )); then
|
|
echo "No shell files found; skipping shellcheck"
|
|
exit 0
|
|
fi
|
|
shellcheck --rcfile .shellcheckrc "${files[@]}"
|