- .golangci.yml:standard 集 - errcheck(存量 38 处裸忽略待专项),staticcheck 关纯风格/quickfix - 清理 3 个无引用死函数;SanitizedJSON 不可达分支收敛为接口分支 + nil 指针防护(原死分支中的 nil 检查从未执行) - CI backend job 增加 golangci-lint-action@v6
60 lines
1.6 KiB
YAML
60 lines
1.6 KiB
YAML
# Gitea Actions CI — 合并门禁(与 GitHub Actions 语法兼容)
|
|
# 后端: gofmt/vet/test;前端: lint/build/test。全部通过才允许合并。
|
|
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
|
|
jobs:
|
|
backend:
|
|
name: Backend (go vet + test)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: backend/go.mod
|
|
cache-dependency-path: backend/go.sum
|
|
- name: gofmt check
|
|
working-directory: backend
|
|
run: |
|
|
unformatted=$(gofmt -l .)
|
|
if [ -n "$unformatted" ]; then
|
|
echo "::error::以下文件未通过 gofmt:"; echo "$unformatted"; exit 1
|
|
fi
|
|
- name: go vet
|
|
working-directory: backend
|
|
run: go vet ./...
|
|
- name: golangci-lint
|
|
uses: golangci/golangci-lint-action@v6
|
|
with:
|
|
working-directory: backend
|
|
- name: go test
|
|
working-directory: backend
|
|
run: go test ./...
|
|
|
|
frontend:
|
|
name: Frontend (lint + build + test)
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
cache-dependency-path: frontend/package-lock.json
|
|
- name: npm ci
|
|
working-directory: frontend
|
|
run: npm ci
|
|
- name: lint
|
|
working-directory: frontend
|
|
run: npm run lint
|
|
- name: test
|
|
working-directory: frontend
|
|
run: npm test
|
|
- name: build
|
|
working-directory: frontend
|
|
run: npm run build
|