mirror of
https://github.com/Awuqing/BackupX.git
synced 2026-08-30 04:27:20 +08:00
refactor: simplify architecture and harden lifecycle
Remove obsolete implementations, centralize background task ownership and terminal-state recovery, consolidate frontend routing and log streaming, and enforce project-wide verification in CI.
This commit is contained in:
@@ -26,7 +26,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version: '1.25'
|
||||
go-version: "1.25"
|
||||
cache-dependency-path: server/go.sum
|
||||
|
||||
- name: Verify modules
|
||||
@@ -54,6 +54,31 @@ jobs:
|
||||
working-directory: server
|
||||
run: go test ./... -v
|
||||
|
||||
backend-windows:
|
||||
name: Go Test (Windows)
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version: "1.25"
|
||||
cache-dependency-path: server/go.sum
|
||||
|
||||
- name: Verify modules
|
||||
working-directory: server
|
||||
run: go mod verify
|
||||
|
||||
- name: Build
|
||||
working-directory: server
|
||||
run: go build ./...
|
||||
|
||||
- name: Test
|
||||
working-directory: server
|
||||
run: go test ./...
|
||||
|
||||
frontend:
|
||||
name: React Build & Test
|
||||
runs-on: ubuntu-latest
|
||||
@@ -64,14 +89,22 @@ jobs:
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: '24'
|
||||
cache: 'npm'
|
||||
node-version: "24"
|
||||
cache: "npm"
|
||||
cache-dependency-path: web/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: web
|
||||
run: npm ci
|
||||
|
||||
- name: Audit production dependencies
|
||||
working-directory: web
|
||||
run: npm audit --omit=dev --audit-level=high
|
||||
|
||||
- name: Lint and formatting
|
||||
working-directory: web
|
||||
run: npm run lint && npm run format:check
|
||||
|
||||
- name: Test
|
||||
working-directory: web
|
||||
run: npm run test
|
||||
@@ -79,3 +112,48 @@ jobs:
|
||||
- name: Type Check & Build
|
||||
working-directory: web
|
||||
run: npm run build
|
||||
|
||||
docs:
|
||||
name: Documentation Build
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 20
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: "24"
|
||||
cache: "npm"
|
||||
cache-dependency-path: docs-site/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
working-directory: docs-site
|
||||
run: npm ci
|
||||
|
||||
- name: Type Check & Build
|
||||
working-directory: docs-site
|
||||
run: npm run typecheck && npm run build
|
||||
|
||||
container:
|
||||
name: Container Build
|
||||
needs: [backend, backend-windows, frontend, docs]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v7
|
||||
|
||||
- name: Validate Compose configuration
|
||||
run: docker compose config --quiet
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
|
||||
- name: Build image
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
tags: backupx:ci
|
||||
cache-from: type=gha,scope=backupx-ci
|
||||
cache-to: type=gha,mode=max,scope=backupx-ci
|
||||
|
||||
@@ -18,11 +18,11 @@ name: Release
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: '版本号(如 v1.2.3)'
|
||||
description: "版本号(如 v1.2.3)"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
@@ -65,7 +65,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version: '1.25'
|
||||
go-version: "1.25"
|
||||
cache-dependency-path: server/go.sum
|
||||
|
||||
- name: Verify backend
|
||||
@@ -83,14 +83,17 @@ jobs:
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: '24'
|
||||
cache: 'npm'
|
||||
node-version: "24"
|
||||
cache: "npm"
|
||||
cache-dependency-path: web/package-lock.json
|
||||
|
||||
- name: Verify frontend
|
||||
working-directory: web
|
||||
run: |
|
||||
npm ci
|
||||
npm audit --omit=dev --audit-level=high
|
||||
npm run lint
|
||||
npm run format:check
|
||||
npm run test
|
||||
|
||||
# ─── Job 1: 构建前端 ───
|
||||
@@ -105,8 +108,8 @@ jobs:
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v7
|
||||
with:
|
||||
node-version: '24'
|
||||
cache: 'npm'
|
||||
node-version: "24"
|
||||
cache: "npm"
|
||||
cache-dependency-path: web/package-lock.json
|
||||
|
||||
- name: Install & Build
|
||||
@@ -143,7 +146,7 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v7
|
||||
with:
|
||||
go-version: '1.25'
|
||||
go-version: "1.25"
|
||||
cache-dependency-path: server/go.sum
|
||||
|
||||
- name: Download frontend artifact
|
||||
@@ -157,7 +160,7 @@ jobs:
|
||||
env:
|
||||
GOOS: ${{ matrix.goos }}
|
||||
GOARCH: ${{ matrix.goarch }}
|
||||
CGO_ENABLED: '0'
|
||||
CGO_ENABLED: "0"
|
||||
run: |
|
||||
go build \
|
||||
-trimpath \
|
||||
@@ -172,13 +175,13 @@ jobs:
|
||||
cp backupx "${ARCHIVE_NAME}/"
|
||||
cp -r web/dist "${ARCHIVE_NAME}/web"
|
||||
cp server/config.example.yaml "${ARCHIVE_NAME}/"
|
||||
cp deploy/install.sh "${ARCHIVE_NAME}/" 2>/dev/null || true
|
||||
cp deploy/backupx.service "${ARCHIVE_NAME}/" 2>/dev/null || true
|
||||
cp deploy/install.sh "${ARCHIVE_NAME}/"
|
||||
cp deploy/backupx.service "${ARCHIVE_NAME}/"
|
||||
# v2.2+: 随发布包提供 Grafana dashboard 与 nginx.conf 模板
|
||||
if [ -d deploy/grafana ]; then
|
||||
cp -r deploy/grafana "${ARCHIVE_NAME}/grafana"
|
||||
fi
|
||||
cp deploy/nginx.conf "${ARCHIVE_NAME}/nginx.conf" 2>/dev/null || true
|
||||
cp deploy/nginx.conf "${ARCHIVE_NAME}/nginx.conf"
|
||||
tar czf "${ARCHIVE_NAME}.tar.gz" "${ARCHIVE_NAME}"
|
||||
cp "${ARCHIVE_NAME}.tar.gz" "backupx-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz"
|
||||
sha256sum "${ARCHIVE_NAME}.tar.gz" > "${ARCHIVE_NAME}.tar.gz.sha256"
|
||||
@@ -199,7 +202,7 @@ jobs:
|
||||
# ─── Job 3: Docker 多架构 → Docker Hub ───
|
||||
build-docker:
|
||||
name: Build & Push Docker
|
||||
needs: build-web
|
||||
needs: verify
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 45
|
||||
steps:
|
||||
@@ -226,7 +229,7 @@ jobs:
|
||||
build-args: |
|
||||
VERSION=${{ env.VERSION }}
|
||||
tags: |
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/backupx:latest
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/backupx:${{ env.VERSION }}
|
||||
${{ !contains(env.VERSION, '-') && format('{0}/backupx:latest', secrets.DOCKERHUB_USERNAME) || '' }}
|
||||
cache-from: type=gha
|
||||
cache-to: type=gha,mode=max
|
||||
|
||||
Reference in New Issue
Block a user