mirror of
https://github.com/tw93/Mole.git
synced 2026-02-06 13:07:57 +00:00
feat: overhaul quality checks and expand test suite for clean and optimize features
This commit is contained in:
86
.github/workflows/check.yml
vendored
Normal file
86
.github/workflows/check.yml
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
name: Check
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
format:
|
||||
name: Format
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 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@9255dc7a253b0ccc959486e2bca901246202afeb # 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.6'
|
||||
|
||||
- name: Format all code
|
||||
run: |
|
||||
./scripts/check.sh --format
|
||||
|
||||
- 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: Check
|
||||
runs-on: macos-latest
|
||||
needs: format
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # 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@9255dc7a253b0ccc959486e2bca901246202afeb # 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: Run check script
|
||||
run: ./scripts/check.sh --no-format
|
||||
Reference in New Issue
Block a user