chore(ci): add go checks in husky

This commit is contained in:
Acbox
2026-03-21 19:18:30 +08:00
parent a7a36df705
commit e6ef0c9ad6
5 changed files with 91 additions and 2 deletions
+60
View File
@@ -0,0 +1,60 @@
name: ESLint
on:
push:
branches: ["main"]
paths:
- "**/*.js"
- "**/*.cjs"
- "**/*.mjs"
- "**/*.ts"
- "**/*.tsx"
- "**/*.vue"
- "**/package.json"
- "pnpm-lock.yaml"
- "pnpm-workspace.yaml"
- "eslint.config.mjs"
- "**/tsconfig*.json"
- ".github/workflows/eslint.yml"
pull_request:
branches: ["main"]
paths:
- "**/*.js"
- "**/*.cjs"
- "**/*.mjs"
- "**/*.ts"
- "**/*.tsx"
- "**/*.vue"
- "**/package.json"
- "pnpm-lock.yaml"
- "pnpm-workspace.yaml"
- "eslint.config.mjs"
- "**/tsconfig*.json"
- ".github/workflows/eslint.yml"
workflow_dispatch:
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: lts/*
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Run ESLint
run: pnpm lint
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
export PATH="$HOME/.local/share/mise/shims:$HOME/.local/bin:$HOME/.npm-global/bin:/opt/homebrew/bin:/usr/local/bin:$PATH"
echo "Check Go lint..."
golangci-lint run ./...
+6
View File
@@ -0,0 +1,6 @@
#!/usr/bin/env sh
export PATH="$HOME/.local/share/mise/shims:$HOME/.local/bin:$HOME/.npm-global/bin:/opt/homebrew/bin:/usr/local/bin:$PATH"
echo "Check Go test..."
go test ./...
+1 -1
View File
@@ -3,4 +3,4 @@
export PATH="$HOME/.local/share/mise/shims:$HOME/.local/bin:$HOME/.npm-global/bin:/opt/homebrew/bin:/usr/local/bin:$PATH"
echo "Check lint..."
pnpm lint:fix || true
pnpm lint:fix
+18 -1
View File
@@ -7,4 +7,21 @@ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
sh "$SCRIPT_DIR/check-large-files" || exit 1
echo ""
sh "$SCRIPT_DIR/check-pnpm" || exit 1
echo "Running checks..."
sh "$SCRIPT_DIR/check-go" &
PID_GO=$!
sh "$SCRIPT_DIR/check-go-test" &
PID_GO_TEST=$!
sh "$SCRIPT_DIR/check-pnpm" &
PID_PNPM=$!
FAIL=0
wait "$PID_GO" || FAIL=1
wait "$PID_GO_TEST" || FAIL=1
wait "$PID_PNPM" || FAIL=1
[ "$FAIL" -eq 0 ] || exit 1