mirror of
https://github.com/Awuqing/BackupX.git
synced 2026-08-11 23:53:25 +08:00
82 lines
1.7 KiB
YAML
82 lines
1.7 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
workflow_dispatch:
|
|
|
|
# 最小权限:构建/测试仅需读取仓库内容,显式声明以收敛默认的可写令牌。
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: ci-${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
backend:
|
|
name: Go Build & Test
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.25'
|
|
cache-dependency-path: server/go.sum
|
|
|
|
- name: Verify modules
|
|
working-directory: server
|
|
run: go mod verify
|
|
|
|
- name: Check formatting
|
|
working-directory: server
|
|
run: |
|
|
unformatted="$(gofmt -l .)"
|
|
if [ -n "$unformatted" ]; then
|
|
printf '%s\n' "$unformatted"
|
|
exit 1
|
|
fi
|
|
|
|
- name: Vet
|
|
working-directory: server
|
|
run: go vet ./...
|
|
|
|
- name: Build
|
|
working-directory: server
|
|
run: go build ./...
|
|
|
|
- name: Test
|
|
working-directory: server
|
|
run: go test ./... -v
|
|
|
|
frontend:
|
|
name: React Build & Test
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 20
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24'
|
|
cache: 'npm'
|
|
cache-dependency-path: web/package-lock.json
|
|
|
|
- name: Install dependencies
|
|
working-directory: web
|
|
run: npm ci
|
|
|
|
- name: Test
|
|
working-directory: web
|
|
run: npm run test
|
|
|
|
- name: Type Check & Build
|
|
working-directory: web
|
|
run: npm run build
|