64 lines
1.7 KiB
YAML
64 lines
1.7 KiB
YAML
name: CI
|
||
|
||
on:
|
||
push:
|
||
branches: [develop, main, refactor/v2, feature/gitea-ci-verify-yeuimu]
|
||
pull_request:
|
||
|
||
jobs:
|
||
test:
|
||
runs-on: online # 使用你创建的 runner 标签
|
||
|
||
services:
|
||
postgres:
|
||
image: postgres:16-alpine
|
||
env:
|
||
POSTGRES_USER: test
|
||
POSTGRES_PASSWORD: test
|
||
POSTGRES_DB: inkreach_test
|
||
# 去掉 ports 映射,避免与宿主机冲突
|
||
options: >-
|
||
--health-cmd "pg_isready -U test"
|
||
--health-interval 5s
|
||
--health-timeout 3s
|
||
--health-retries 10
|
||
|
||
env:
|
||
DATABASE_URL: postgresql://test:test@postgres:5432/inkreach_test
|
||
|
||
steps:
|
||
- uses: https://gitea.com/actions/checkout@v4
|
||
|
||
- name: 安装依赖
|
||
run: |
|
||
npm install -g @pnpm/exe
|
||
pnpm install --frozen-lockfile --registry=https://registry.npmmirror.com
|
||
|
||
|
||
- name: Prisma generate
|
||
run: pnpm --filter @inkreach/api prisma:generate
|
||
|
||
- name: 建表(migrate deploy)
|
||
run: pnpm --filter @inkreach/api exec prisma migrate deploy
|
||
|
||
- name: API 测试(真实数据库集成测试)
|
||
run: pnpm --filter @inkreach/api test
|
||
|
||
- name: Admin 前端测试
|
||
run: pnpm --filter @inkreach/admin test
|
||
|
||
build-and-test:
|
||
runs-on: online
|
||
steps:
|
||
- uses: https://gitea.com/actions/checkout@v4
|
||
- name: 安装 Docker 客户端
|
||
run: |
|
||
apt-get update && apt-get install -y docker.io
|
||
- name: 构建镜像
|
||
run: docker build -t my-app:latest .
|
||
- name: 启动测试服务
|
||
run: |
|
||
docker run -d --name test-server -p 8080:80 my-app:latest
|
||
sleep 5
|
||
- name: 测试服务是否正常
|
||
run: curl -f http://localhost:8080 |