feat(lab): 数值可解释性 — testcase 构成、指标定义、评测分类 #51
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test Build | |
| on: | |
| push: | |
| branches: [main-go] | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }} | |
| jobs: | |
| # ── Backend tests: go test ./... (fail fast, before Docker build) ── | |
| # 注意:go test ./... 已在干净 checkout 验证可行 —— | |
| # · validation 测试用内联 fixture,不依赖生成的 runtime/core-schema/models.js | |
| # · S3 集成测试带 `//go:build integration`,正常 go test 自动跳过(无需 MinIO) | |
| # · vault/pb_migrations 新增迁移冒烟 + JSVM 审计钩子测试(真 gate,失败即拦) | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version: stable | |
| cache-dependency-path: vault/go.sum | |
| - name: go test ./... | |
| working-directory: vault | |
| env: | |
| GOPROXY: direct | |
| GONOSUMDB: "*" | |
| run: go test ./... | |
| # ── Docs quality gate: duplicate-content check (doc-standard §6) ── | |
| # 要求 S0=0、S1=0、单文件重复率 < 阈值。失败即拦截(doc-dup-check 退出码 1/2)。 | |
| docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: doc-dup-check | |
| run: node scripts/doc-dup-check.mjs | |
| # ── Build Docker images (tagged with commit SHA) ── | |
| docker: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| matrix: | |
| target: [prod, dev] | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: Log in to GHCR | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v6 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=sha,prefix=${{ matrix.target }}- | |
| type=raw,value=${{ matrix.target }}-edge | |
| - name: Build & push | |
| uses: docker/build-push-action@v7 | |
| with: | |
| context: . | |
| target: ${{ matrix.target }} | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| platforms: linux/amd64 | |
| # ── Build migrate binaries ── | |
| migrate: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| goos: [linux, darwin] | |
| goarch: [amd64, arm64] | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version: stable | |
| cache-dependency-path: vault/go.sum | |
| - name: Build | |
| working-directory: vault | |
| env: | |
| GOPROXY: direct | |
| GONOSUMDB: "*" | |
| run: | | |
| GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=0 \ | |
| go build -ldflags="-s -w" -o bin/migrate-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/migrate | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: migrate-${{ matrix.goos }}-${{ matrix.goarch }} | |
| path: vault/bin/migrate-* | |
| retention-days: 7 | |
| # ── Lint Go backend (go vet -all + golangci-lint gate) ── | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - uses: actions/setup-go@v6 | |
| with: | |
| go-version: stable | |
| cache-dependency-path: vault/go.sum | |
| - name: go vet -all | |
| working-directory: vault | |
| run: go vet -all ./... | |
| - name: golangci-lint | |
| uses: golangci/golangci-lint-action@v6 | |
| with: | |
| version: v1.64.8 | |
| working-directory: vault | |
| args: run ./... |