mirror of
https://github.com/tw93/Mole.git
synced 2026-02-04 18:34:46 +00:00
102 lines
3.2 KiB
YAML
102 lines
3.2 KiB
YAML
name: Shell Script Quality Checks
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
shell-quality-checks:
|
|
runs-on: macos-latest
|
|
|
|
steps:
|
|
- name: Checkout source code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.24.6"
|
|
cache: true
|
|
|
|
- name: Cache Homebrew packages
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/Library/Caches/Homebrew
|
|
/usr/local/Cellar/bats-core
|
|
/usr/local/Cellar/shfmt
|
|
/usr/local/Cellar/shellcheck
|
|
key: ${{ runner.os }}-brew-${{ hashFiles('.github/workflows/shell-quality-checks.yml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-brew-
|
|
|
|
- name: Install shell linting and testing tools
|
|
run: brew install bats-core shfmt shellcheck
|
|
|
|
- name: Auto-format shell scripts with shfmt
|
|
run: ./scripts/format.sh
|
|
|
|
- name: Run shellcheck linter and bats tests
|
|
run: |
|
|
./scripts/check.sh
|
|
echo "✓ All quality checks passed"
|
|
|
|
- name: Run all bats tests with summary
|
|
run: |
|
|
echo "Running all test suites..."
|
|
bats tests/*.bats --formatter tap
|
|
echo ""
|
|
echo "Test summary:"
|
|
echo " Total test files: $(ls tests/*.bats | wc -l | tr -d ' ')"
|
|
echo " Total tests: $(grep -c "^@test" tests/*.bats | awk -F: '{sum+=$2} END {print sum}')"
|
|
|
|
- name: Build Universal Binary for disk analyzer
|
|
run: ./scripts/build-analyze.sh
|
|
|
|
- name: Build Universal Binary for system status
|
|
run: ./scripts/build-status.sh
|
|
|
|
- name: Verify binary is valid
|
|
run: |
|
|
if [[ ! -x bin/analyze-go ]]; then
|
|
echo "Error: bin/analyze-go is not executable"
|
|
exit 1
|
|
fi
|
|
if [[ ! -x bin/status-go ]]; then
|
|
echo "Error: bin/status-go is not executable"
|
|
exit 1
|
|
fi
|
|
echo "Binary info:"
|
|
file bin/analyze-go
|
|
ls -lh bin/analyze-go
|
|
file bin/status-go
|
|
ls -lh bin/status-go
|
|
echo ""
|
|
echo "✓ Universal binary built successfully"
|
|
|
|
- name: Commit analyzer binary if updated
|
|
if: github.event_name != 'pull_request'
|
|
run: |
|
|
if git diff --quiet -- bin/analyze-go; then
|
|
echo "bin/analyze-go unchanged; nothing to commit."
|
|
else
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add bin/analyze-go
|
|
git commit -m "chore: update analyzer binary"
|
|
git push origin HEAD:${GITHUB_REF#refs/heads/}
|
|
fi
|
|
if git diff --quiet -- bin/status-go; then
|
|
echo "bin/status-go unchanged; nothing to commit."
|
|
exit 0
|
|
fi
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git add bin/status-go
|
|
git commit -m "chore: update status binary"
|
|
git push origin HEAD:${GITHUB_REF#refs/heads/}
|