mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 16:14:44 +00:00
66 lines
1.7 KiB
YAML
66 lines
1.7 KiB
YAML
name: Shell Format & Lint (Minimal)
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
format-lint:
|
|
runs-on: macos-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install shfmt & shellcheck
|
|
run: |
|
|
set -euo pipefail
|
|
brew update
|
|
brew install shfmt shellcheck
|
|
shfmt -version || true
|
|
shellcheck --version || true
|
|
|
|
- name: List target files
|
|
id: list
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
FILES=$(git ls-files '*.sh' 'mole' || true)
|
|
echo "FILES<<EOF" >> "$GITHUB_OUTPUT"
|
|
echo "$FILES" >> "$GITHUB_OUTPUT"
|
|
echo "EOF" >> "$GITHUB_OUTPUT"
|
|
if [[ -z "$FILES" ]]; then
|
|
echo "found=0" >> "$GITHUB_OUTPUT"
|
|
echo "No shell files found."
|
|
else
|
|
echo "found=1" >> "$GITHUB_OUTPUT"
|
|
echo "Files:"
|
|
echo "$FILES"
|
|
fi
|
|
|
|
- name: Run shfmt (diff only)
|
|
if: steps.list.outputs.found == '1'
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
shfmt -i 4 -ci -sr -d ${FILES}
|
|
env:
|
|
FILES: ${{ steps.list.outputs.FILES }}
|
|
|
|
- name: Run shellcheck
|
|
if: steps.list.outputs.found == '1'
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
if [[ -f .shellcheckrc ]]; then
|
|
shellcheck --rcfile .shellcheckrc ${FILES}
|
|
else
|
|
shellcheck ${FILES}
|
|
fi
|
|
env:
|
|
FILES: ${{ steps.list.outputs.FILES }}
|
|
|
|
- name: Nothing to check
|
|
if: steps.list.outputs.found == '0'
|
|
run: echo "Skip: no shell files." |