1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 19:44:44 +00:00
Files
Mole/.github/workflows/quality.yml
dependabot[bot] db220746dc chore(deps): bump actions/setup-go from 5.6.0 to 6.1.0 (#194)
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 5.6.0 to 6.1.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](40f1582b24...4dc6199c7b)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-version: 6.1.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-29 16:55:51 +08:00

108 lines
3.2 KiB
YAML

name: Quality
on:
push:
branches: [main]
pull_request:
permissions:
contents: write
jobs:
format:
name: Auto Format
runs-on: macos-latest
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.head_ref) || github.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Homebrew
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: |
~/Library/Caches/Homebrew
/usr/local/Cellar/shfmt
/usr/local/Cellar/shellcheck
key: ${{ runner.os }}-brew-quality-${{ hashFiles('**/Brewfile') }}
restore-keys: |
${{ runner.os }}-brew-quality-
- name: Install tools
run: brew install shfmt shellcheck
- name: Set up Go
uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v5
with:
go-version: '1.24'
- name: Format all code
run: |
echo "Formatting shell scripts..."
./scripts/format.sh
echo "Formatting Go code..."
gofmt -w ./cmd
echo "✓ All code formatted"
- name: Commit formatting changes
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
run: |
git config user.name "Tw93"
git config user.email "tw93@qq.com"
if [[ -n $(git status --porcelain) ]]; then
git add .
git commit -m "chore: auto format code"
git push
echo "✓ Formatting changes committed"
else
echo "✓ No formatting changes needed"
fi
quality:
name: Code Quality
runs-on: macos-latest
needs: format
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.head_ref) || github.ref }}
- name: Cache Homebrew
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: |
~/Library/Caches/Homebrew
/usr/local/Cellar/shfmt
/usr/local/Cellar/shellcheck
key: ${{ runner.os }}-brew-quality-${{ hashFiles('**/Brewfile') }}
restore-keys: |
${{ runner.os }}-brew-quality-
- name: Install tools
run: brew install shfmt shellcheck
- name: ShellCheck
run: |
echo "Running ShellCheck on all shell scripts..."
shellcheck mole
shellcheck bin/*.sh
find lib -name "*.sh" -exec shellcheck {} +
echo "✓ ShellCheck passed"
- name: Syntax check
run: |
echo "Checking Bash syntax..."
bash -n mole
for script in bin/*.sh; do
bash -n "$script"
done
find lib -name "*.sh" | while read -r script; do
bash -n "$script"
done
echo "✓ All scripts have valid syntax"