mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 16:49:41 +00:00
Complete automated testing
This commit is contained in:
45
.github/workflows/shell-format.yml
vendored
Normal file
45
.github/workflows/shell-format.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
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
|
||||
mapfile -d '' files < <(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
|
||||
mapfile -d '' files < <(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[@]}"
|
||||
Reference in New Issue
Block a user