Files
ARTEX/.gitea/workflows/ci.yml
T
wangdefa 2511c2e041 ci: 添加 Gitea Actions 的 CI 与发布流程,移除 .github/workflows
- ci.yml:push main 时起 postgres:16 服务容器,应用 schema.sql 并补建 llm_usage,
  跑 go mod verify / go vet / go test -p 1 ./...;不接 PR 触发。
  -skip 掉当前已失败的 TestGraphOverviewExpandsAssociatedCompanyScope。
- release.yml:v* tag 触发,只构建 linux/amd64 与 linux/arm64,从 CHANGELOG
  提取说明,用 gitea-release-action 建 Release 上传 zip 与 SHA256SUMS,
  再用 buildx 推多架构镜像到 gitea.bcde.io/wangdefa/artex。
- .dockerignore:排除 dist 下的 zip 与中间产物,只放 dist/<arch>/artex 进构建上下文。
- 删除 .github/workflows:本仓库 CI/CD 全部走 .gitea/workflows。留着的副本会被
  Gitea 一并扫描,同一个 tag 触发两套发布流程、重复建 Release。
2026-10-20 21:45:42 -07:00

118 lines
3.6 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Gitea Actions:push 到 main 时跑后端测试与前端构建。
# 刻意不接 pull_request:solo 开发时同一提交会跑两遍,浪费 CI 时间。
#
# 前置条件(缺一不可):
# 1. 仓库 Settings → Actions 勾选 “Enable Repository Actions”
# 2. 已注册带 ubuntu-latest-amd64 标签、且以 Docker 模式运行的 Gitea Runner
# (services 容器只在 Docker 模式下可用)
# 现有 Runner:runner-amd64 → ubuntu-latest-amd64 / ubuntu-22.04-amd64 / ubuntu-20.04-amd64
# runner-arm64 → ubuntu-latest-arm64 / ubuntu-22.04-arm64 / ubuntu-20.04-arm64
# 想跑在 arm64 上把下面的 runs-on 换成 ubuntu-latest-arm64 即可。
# 3. Runner 能出网:actions/checkout 与 actions/setup-go 默认从 github.com 拉取,
# setup-go 还要从 go.dev 下载工具链
name: ci
on:
push:
branches: [main]
permissions:
contents: read
jobs:
backend:
runs-on: ubuntu-latest-amd64
timeout-minutes: 40
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: artex
POSTGRES_PASSWORD: artex
POSTGRES_DB: artex
options: >-
--health-cmd "pg_isready -U artex"
--health-interval 5s
--health-timeout 5s
--health-retries 30
env:
ARTEX_PG_DSN: postgres://artex:artex@postgres:5432/artex?sslmode=disable
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.26"
# Runner 没开缓存服务时 actions/cache 会失败,这里先关掉保稳。
cache: false
- name: 安装 psql 客户端
run: |
command -v psql >/dev/null 2>&1 && exit 0
apt-get update -qq
apt-get install -y -qq postgresql-client
- name: 初始化数据库 schema
env:
PGPASSWORD: artex
run: psql -h postgres -U artex -d artex -v ON_ERROR_STOP=1 -q -f db/schema.sql
- name: 初始化运行时表(llm_usage)
run: |
# llm_usage 不在 schema.sql 里,由应用启动时的 db.EnsureLLMUsageTable 建表。
# 有测试直接读写这张表,所以这里显式补一次,避免依赖包执行顺序。
cat > /tmp/bootstrap.go <<'GO'
package main
import (
"log"
"os"
"github.com/Autumn-27/artex/db"
)
func main() {
d, err := db.Open(os.Getenv("ARTEX_PG_DSN"))
if err != nil {
log.Fatal(err)
}
defer d.Close()
if err := d.EnsureLLMUsageTable(); err != nil {
log.Fatal(err)
}
}
GO
go run /tmp/bootstrap.go
- name: 依赖完整性
run: go mod verify
- name: 静态检查
run: go vet ./...
- name: 测试
run: |
# -p 1:各包共用一个库,串行执行避免跨包数据竞争。
# -skip:TestGraphOverviewExpandsAssociatedCompanyScope 在当前代码上
# 已失败(coverage["scope"] 为 nil),与本流程无关,修好后请删掉。
go test -p 1 ./... -count=1 -skip 'TestGraphOverviewExpandsAssociatedCompanyScope'
frontend:
runs-on: ubuntu-latest-amd64
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: false
- name: 安装依赖
working-directory: web
run: npm ci --no-audit --no-fund
- name: 构建静态站点
working-directory: web
run: npm run build:static