mirror of
https://github.com/tw93/Mole.git
synced 2026-02-12 00:39:02 +00:00
format automate
This commit is contained in:
59
.github/workflows/quality.yml
vendored
59
.github/workflows/quality.yml
vendored
@@ -9,13 +9,16 @@ permissions:
|
|||||||
contents: write
|
contents: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
shell-quality:
|
format:
|
||||||
name: Code Quality
|
name: Auto Format
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Cache Homebrew
|
- name: Cache Homebrew
|
||||||
uses: actions/cache@v4
|
uses: actions/cache@v4
|
||||||
@@ -31,16 +34,56 @@ jobs:
|
|||||||
- name: Install tools
|
- name: Install tools
|
||||||
run: brew install shfmt shellcheck
|
run: brew install shfmt shellcheck
|
||||||
|
|
||||||
- name: Format check
|
- name: Set up Go
|
||||||
|
uses: actions/setup-go@v5
|
||||||
|
with:
|
||||||
|
go-version: '1.24'
|
||||||
|
|
||||||
|
- name: Format all code
|
||||||
run: |
|
run: |
|
||||||
echo "Checking shell script formatting..."
|
echo "Formatting shell scripts..."
|
||||||
./scripts/format.sh
|
./scripts/format.sh
|
||||||
|
echo "Formatting Go code..."
|
||||||
|
gofmt -w ./cmd
|
||||||
|
echo "✓ All code formatted"
|
||||||
|
|
||||||
|
- name: Commit formatting changes
|
||||||
|
run: |
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
if [[ -n $(git status --porcelain) ]]; then
|
if [[ -n $(git status --porcelain) ]]; then
|
||||||
echo "Code formatting issues found:"
|
git add .
|
||||||
git diff
|
git commit -m "chore: auto format code"
|
||||||
exit 1
|
git push
|
||||||
|
echo "✓ Formatting changes committed"
|
||||||
|
else
|
||||||
|
echo "✓ No formatting changes needed"
|
||||||
fi
|
fi
|
||||||
echo "✓ All scripts properly formatted"
|
|
||||||
|
quality:
|
||||||
|
name: Code Quality
|
||||||
|
runs-on: macos-latest
|
||||||
|
needs: format
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: ${{ github.head_ref }}
|
||||||
|
|
||||||
|
- name: Cache Homebrew
|
||||||
|
uses: actions/cache@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
|
- name: ShellCheck
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
10
.github/workflows/tests.yml
vendored
10
.github/workflows/tests.yml
vendored
@@ -49,16 +49,6 @@ jobs:
|
|||||||
go vet ./cmd/...
|
go vet ./cmd/...
|
||||||
echo "✓ Vet passed"
|
echo "✓ Vet passed"
|
||||||
|
|
||||||
- name: Check formatting
|
|
||||||
run: |
|
|
||||||
echo "Checking Go formatting..."
|
|
||||||
if [ -n "$(gofmt -l ./cmd)" ]; then
|
|
||||||
echo "Go code is not formatted:"
|
|
||||||
gofmt -d ./cmd
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo "✓ Go code properly formatted"
|
|
||||||
|
|
||||||
integration-tests:
|
integration-tests:
|
||||||
name: Integration Tests
|
name: Integration Tests
|
||||||
runs-on: macos-latest
|
runs-on: macos-latest
|
||||||
|
|||||||
Reference in New Issue
Block a user