Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ad86bf93be | |||
| 5d00715c3a | |||
| d7d636792d | |||
| 89c484cdc4 | |||
| 5e3362e2b0 | |||
| edd07a65d6 | |||
| 7c120b3adc | |||
| ea159ca2fb |
Executable
+10
@@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
# Keep the configured global checks when this checkout opts into repository hooks.
|
||||||
|
global_hooks=$(git config --global --path --get core.hooksPath || :)
|
||||||
|
if [ -n "$global_hooks" ] && [ -x "$global_hooks/pre-commit" ] &&
|
||||||
|
[ ! "$global_hooks/pre-commit" -ef "$0" ]; then
|
||||||
|
"$global_hooks/pre-commit"
|
||||||
|
fi
|
||||||
|
exec make test-changed
|
||||||
@@ -6,6 +6,8 @@
|
|||||||
/web/node_modules/
|
/web/node_modules/
|
||||||
/web/dist/
|
/web/dist/
|
||||||
/web/tsconfig.tsbuildinfo
|
/web/tsconfig.tsbuildinfo
|
||||||
|
/web/test-results/
|
||||||
|
/web/playwright-report/
|
||||||
|
|
||||||
# Local runtime
|
# Local runtime
|
||||||
.env
|
.env
|
||||||
|
|||||||
@@ -27,6 +27,27 @@ BUILD_TIME ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
|
|||||||
verify:
|
verify:
|
||||||
$(PY) scripts/ci_checks.py
|
$(PY) scripts/ci_checks.py
|
||||||
|
|
||||||
|
.PHONY: qa qa-doctor qa-self-test tests-e2e tests-e2e-ci test-changed test-tooling
|
||||||
|
tests-e2e:
|
||||||
|
npm --prefix web run test:e2e -- $(E2E)
|
||||||
|
|
||||||
|
# The hosted CI job container is disposable and starts without Chromium's system libraries.
|
||||||
|
tests-e2e-ci: export PLAYWRIGHT_BROWSERS_PATH ?= /opt/citools-cache/playwright
|
||||||
|
tests-e2e-ci:
|
||||||
|
sh scripts/ci_install_chromium.sh
|
||||||
|
$(MAKE) tests-e2e
|
||||||
|
test-changed:
|
||||||
|
$(PY) scripts/test_changed.py
|
||||||
|
test-tooling: qa-self-test
|
||||||
|
$(PY) -m unittest discover -s scripts -p test_test_changed.py -v
|
||||||
|
|
||||||
|
qa:
|
||||||
|
$(PY) scripts/qa_env.py run
|
||||||
|
qa-doctor:
|
||||||
|
$(PY) scripts/qa_env.py doctor
|
||||||
|
qa-self-test:
|
||||||
|
$(PY) -m unittest discover -s scripts -p test_qa_env.py -v
|
||||||
|
|
||||||
# 清单:哪些是必需项、在哪个档案(local / ci)下必需
|
# 清单:哪些是必需项、在哪个档案(local / ci)下必需
|
||||||
list:
|
list:
|
||||||
$(PY) scripts/ci_checks.py --list
|
$(PY) scripts/ci_checks.py --list
|
||||||
|
|||||||
@@ -71,15 +71,16 @@ IT、行政等是待扩展的业务资料范围,不是已经完成的新连接
|
|||||||
|
|
||||||
## 访问与部署
|
## 访问与部署
|
||||||
|
|
||||||
### 已部署环境
|
### 运行架构与访问入口
|
||||||
|
|
||||||
Compose 中网页入口固定映射为 **宿主机 `8088` → Web 容器 `8080`**。网页和 `/api/` 使用同源入口。
|
| 组件 | 职责 | 接手时从这里看 |
|
||||||
|
|---|---|---|
|
||||||
|
| React/Vite + Web Nginx | 提供静态页面,同源转发 `/api/` 和 `/health` | [前端开发代理](web/vite.config.ts)、[Compose 的 Nginx 配置](deploy/nginx.conf) |
|
||||||
|
| Go API + 治理 PostgreSQL | 认证、角色、来源、绑定、审核、任务与发布记录。云测试使用独立逻辑库 `knowledge_governance_test` | [API](cmd/api)、[接口契约](api/openapi.yaml) |
|
||||||
|
| 普通 worker + 测试 WeKnora | worker 取件、上传、轮询并记录验收结果。WeKnora 负责解析、切片和索引 | [worker](cmd/worker)、[来源接入](docs/OPERATIONS_RUNBOOK.md#接入外部平台) |
|
||||||
|
| 发布 worker + 生产 WeKnora | 按已锁定的批次和目标执行受控发布与读回。问答端通过下游服务使用已发布知识 | [发布 worker](cmd/release-worker)、[操作手册](docs/OPERATIONS_RUNBOOK.md) |
|
||||||
|
|
||||||
- 本机访问:`http://127.0.0.1:8088/`
|
从自己的电脑做系统设置验收,使用 SSH 转发后的 `http://127.0.0.1:28189/`。云测试主控制台使用受限内网入口 `http://100.85.111.121:8088/`。仓内 Compose 则将宿主 `8088` 映射到 Web 容器 `8080`。选择入口时先确认要看的部署。隧道命令、生产 `090` 服务地址和 HTTPS 反代示例见[运维手册](docs/OPERATIONS_RUNBOOK.md#入口与反向代理)。
|
||||||
- 局域网访问:`http://<服务器内网IP>:8088/`
|
|
||||||
- 健康入口:`http://127.0.0.1:8088/health`
|
|
||||||
|
|
||||||
可以由 NAS 反向代理提供 HTTPS 域名入口,目标为平台服务器的 `8088`,保持路径原样转发。公网开放前必须验证鉴权、访问控制及转发头配置,不直接暴露数据库或内部管理接口。
|
|
||||||
|
|
||||||
**平台入口展示当前部署版本,不是每次 CI 的构建预览。** CI 静态预览由独立链路提供;CI 通过不会自动更新运行服务。
|
**平台入口展示当前部署版本,不是每次 CI 的构建预览。** CI 静态预览由独立链路提供;CI 通过不会自动更新运行服务。
|
||||||
|
|
||||||
@@ -94,13 +95,7 @@ Compose 中网页入口固定映射为 **宿主机 `8088` → Web 容器 `8080`*
|
|||||||
- 来源目录、spool 与运行状态挂载;按部署主机调整路径和 UID/GID。
|
- 来源目录、spool 与运行状态挂载;按部署主机调整路径和 UID/GID。
|
||||||
- 测试 WeKnora 连接与对内/对外路由;生产发布按独立配置和授权接线。
|
- 测试 WeKnora 连接与对内/对外路由;生产发布按独立配置和授权接线。
|
||||||
|
|
||||||
准备完成后,由获授权的操作者执行:
|
仓内 Compose 含 `postgres` 演练服务。云测试和生产使用阿里云 RDS,部署前先核对目标逻辑库、当前迁移版本、待运行的迁移及所用的环境配置。API 和 worker 启动可执行迁移。已有环境先用 `docker compose config --services` 检查服务清单,按该环境的发布手册切换已验证的产物。前端开发可直接使用下面的 Vite 流程。
|
||||||
|
|
||||||
```bash
|
|
||||||
docker compose up --build -d
|
|
||||||
```
|
|
||||||
|
|
||||||
主机需要提权时,由操作者按本机权限规则执行,不在自动化中默认使用 sudo。停止服务可用 `docker compose down`;**不要执行 `docker compose down -v`,除非明确批准删除数据库卷。**
|
|
||||||
|
|
||||||
## 配置与安全边界
|
## 配置与安全边界
|
||||||
|
|
||||||
@@ -114,7 +109,7 @@ docker compose up --build -d
|
|||||||
|
|
||||||
## 开发与 CI
|
## 开发与 CI
|
||||||
|
|
||||||
基础环境:Go 1.26、Node.js 22、npm,以及检查脚本所需的 Python 3 和工具链。依赖以仓库锁文件和实际 CI 配置为准。
|
本机和 QA 虚拟机的依赖安装、前后端启动、测试命令及 PostgreSQL 测试库准备见 [开发与测试指南](docs/DEVELOPMENT_AND_TESTING.md)。
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
make verify # 完整检查入口:本地与 CI 使用同一套规则
|
make verify # 完整检查入口:本地与 CI 使用同一套规则
|
||||||
|
|||||||
@@ -0,0 +1,146 @@
|
|||||||
|
# 知识治理平台开发与测试
|
||||||
|
|
||||||
|
以下命令从仓库根目录运行。日常开发可在 Ubuntu 宿主进行,指定提交的回归在 `hifox-qa` 的独立检出中运行。部署到阿里云测试服后的验收按 [操作 Runbook](OPERATIONS_RUNBOOK.md) 和 [用户流程验收](USER_FLOWS_ACCEPTANCE.md) 执行。
|
||||||
|
|
||||||
|
## QA 虚拟机一键回归
|
||||||
|
|
||||||
|
在 `hifox-qa` 检出提测提交后,运行下列入口。将 SHA 占位值换成提测记录里的完整提交 SHA。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make qa-doctor
|
||||||
|
KG_QA_SHA='<完整提交 SHA>' make qa
|
||||||
|
```
|
||||||
|
|
||||||
|
`make qa-doctor` 检查工具链、HiFox 机器在线状态、OMP 模型调用、测试库身份和已安装的迁移。`make qa` 安装锁定依赖,在专用测试库上通过 API 初始化和迁移,随后核对完整迁移序列、API 就绪状态、Web 首页及 Vite 健康代理。通过后执行 Go、Vitest 和 Chromium 浏览器测试,结束时关闭本次启动的服务。每次运行的服务日志保存在 `~/.local/state/knowledge-governance/qa/`。需要提交前完整门禁时执行 `make verify`。
|
||||||
|
|
||||||
|
初次配置由负责人在 QA 虚拟机准备 `~/.config/knowledge-governance/`。以下示例使用虚构的 RDS 主机名。
|
||||||
|
|
||||||
|
| 文件 | 内容 |
|
||||||
|
| --- | --- |
|
||||||
|
| `qa.json` | 当前用户所有、权限 `0600`,字段 `host`、`port`、`database`、`user` |
|
||||||
|
| `qa.pgpass` | 当前用户所有、权限 `0600`,填写与 `qa.json` 匹配的口令条目 |
|
||||||
|
| `rds-ca.pem` | 对应实例的 CA 证书,用于校验 RDS 主机名 |
|
||||||
|
|
||||||
|
```json
|
||||||
|
{"host":"rds.example.test","port":5432,"database":"kg_qa_app","user":"kg_qa_app"}
|
||||||
|
```
|
||||||
|
|
||||||
|
专用非生产 RDS 库和角色以 `kg_qa_` 开头,权限和网络准备见第 2 节。首次运行接受空库,后续运行接受与当前提交兼容的迁移序列。缺库、认证失败、迁移不兼容和端口冲突均会使命令非零退出。浏览器业务 E2E 和专用集成库的 Go 测试按第 4 节执行。
|
||||||
|
|
||||||
|
## 1. 检出代码与安装依赖
|
||||||
|
|
||||||
|
准备 Git、Make、Python 3、Go 1.26(含同一工具链的 `gofmt`)、Node.js 22 和 npm。数据库检查另需 PostgreSQL 客户端 `psql`。首次安装依赖需要能访问 Go 和 npm 的依赖源。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# QA 在独立克隆中拉取提测分支,使用提测记录里的完整提交 SHA
|
||||||
|
export KG_TARGET_BRANCH='<提测分支名>' KG_TARGET_SHA='<完整提交 SHA>'
|
||||||
|
git fetch origin "$KG_TARGET_BRANCH" && git switch --detach "$KG_TARGET_SHA" &&
|
||||||
|
test "$(git rev-parse HEAD)" = "$KG_TARGET_SHA" && test -z "$(git status --porcelain)"
|
||||||
|
# 上面的命令链若失败,先解决检出或工作区问题再继续
|
||||||
|
|
||||||
|
# 检查当前 shell 的工具链,非交互任务也应设置相同的 PATH
|
||||||
|
export PATH="$(go env GOROOT)/bin:$PATH"
|
||||||
|
go version
|
||||||
|
command -v gofmt
|
||||||
|
node --version
|
||||||
|
npm --version
|
||||||
|
python3 --version
|
||||||
|
make deps-install
|
||||||
|
```
|
||||||
|
|
||||||
|
`make deps-install` 通过 `go mod download` 和 `npm ci` 安装依赖。Go 依赖由 `go.mod` / `go.sum` 约束,前端由 `web/package-lock.json` 锁定。依赖安装失败时先检查工具链、依赖源和锁文件,避免临时改写清单来绕过问题。
|
||||||
|
|
||||||
|
## 2. 准备开发和测试数据库
|
||||||
|
|
||||||
|
无库检查可直接跳到第 4 节。启动 API 或执行真库测试前,由数据库管理员在**非生产 PostgreSQL RDS** 上预建专用空库和登录角色。建议分配 `kg_qa_app` 给应用冒烟,`kg_qa_it` 给 Go 集成测试,各用独立角色。开发宿主另用开发专用库,避免与 QA 共享数据。库未分配时先申请,启动流程以库已存在为前提。
|
||||||
|
|
||||||
|
| 用途 | 所需权限 | 数据初始化 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 应用启动与 UI 冒烟 | `CONNECT`,以及目标 schema 内的 `USAGE`、`CREATE` 和对应用对象的读写权限。迁移角色须能修改自己创建的对象。 | 首次 API 启动执行仓库内嵌迁移。用户表为空时创建初始管理员,首次登录必须修改密码。初始口令通过测试环境负责人交接。 |
|
||||||
|
| Go PostgreSQL 集成测试 | `CONNECT` 和目标测试库的 `CREATE` 权限,用于建立各用例自己的 schema。 | 用例创建隔离 schema、执行迁移、写入测试数据并清理。相同测试不要并发指向同一个库,避免固定 schema 名冲突。 |
|
||||||
|
|
||||||
|
两类角色均只授予对应非生产库所需的权限。使用空库和合成数据。密码由操作者在目标机配置到权限为 `0600` 的 PostgreSQL passfile,条目按 `host:port:database:user:password` 填写。使用 RDS CA 校验证书。以下命令先读回实际数据库、角色与 TLS 状态,核对三者再启动 API 或运行真库测试。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 用获准的 RDS 主机名、端口、库名、角色和文件路径替换示例值
|
||||||
|
export PGHOST='<非生产 RDS 主机名>' PGPORT=5432
|
||||||
|
export PGDATABASE=kg_qa_app PGUSER=kg_qa_app
|
||||||
|
export PGPASSFILE="$HOME/.config/knowledge-governance/qa.pgpass"
|
||||||
|
export PGSSLROOTCERT="$HOME/.config/knowledge-governance/rds-ca.pem"
|
||||||
|
export PGSSLMODE=verify-full PGCONNECT_TIMEOUT=5
|
||||||
|
psql -X -v ON_ERROR_STOP=1 -c \
|
||||||
|
'SELECT current_database(), current_user, ssl FROM pg_stat_ssl WHERE pid = pg_backend_pid();'
|
||||||
|
```
|
||||||
|
|
||||||
|
如果是云厂商提供的私网地址,先确认执行机通过获准的网络路径可访问 RDS。库名、角色、TLS、连接权限或迁移权限有问题时,先交由环境负责人核对配置。实例上已有数据的库不能当作空库初始化。
|
||||||
|
|
||||||
|
## 3. 启动后端和前端
|
||||||
|
|
||||||
|
**终端 A,启动 API。** 在干净 shell 中执行第 2 节的应用库配置和连通性检查。使用独立测试配置,不加载现网 `.env`。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
export DATABASE_URL="postgresql://${PGUSER}@${PGHOST}:${PGPORT}/${PGDATABASE}?sslmode=verify-full&connect_timeout=5"
|
||||||
|
export APP_ADDR=127.0.0.1:8088
|
||||||
|
export TEST_WEKNORA_ENABLED=false PP_SCAN_ENABLED=false
|
||||||
|
export RELEASE_WORKER_ENABLED=false PRODUCTION_RELEASE_REQUESTS_ENABLED=false
|
||||||
|
export DOBOTAI_OPS_READ_ENABLED=false DOBOTAI_OPS_DIRECTORY_SYNC_ENABLED=false
|
||||||
|
go run ./cmd/api
|
||||||
|
```
|
||||||
|
|
||||||
|
API 会在监听前连接 PostgreSQL、应用迁移并初始化管理员。Web 页面和同步 API 联调只需运行 API 与 Vite。需要验证后台队列时,另用相同的隔离应用库配置启动普通 worker(`go run ./cmd/worker`)。涉及取件或来源刷新的任务还依赖容器内 `/app/scripts` 及获准的来源接线,按部署说明准备。发布 worker 无需启动。
|
||||||
|
|
||||||
|
Vite 通过 `localhost:8088` 转发 `/api` 和健康检查。如果 `8088` 已被其他部署占用,使用端口空闲的 QA 虚拟机运行本节。仅改前端时,可复用一个获准联调的测试 API,但需要先确认 `localhost:8088/health` 可达,并核对该地址指向的环境。
|
||||||
|
|
||||||
|
**终端 B,启动 Web。**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm --prefix web run dev -- --host 127.0.0.1 --port 5173 --strictPort
|
||||||
|
```
|
||||||
|
|
||||||
|
在运行服务的机器打开 `http://127.0.0.1:5173/`。另开终端检查 API 与前端代理,再复查迁移记录。最后一条命令需要第 2 节的应用库配置。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl --fail --silent --show-error http://127.0.0.1:8088/health
|
||||||
|
curl --fail --silent --show-error http://127.0.0.1:5173/health
|
||||||
|
psql -X -v ON_ERROR_STOP=1 -c \
|
||||||
|
'SELECT version FROM schema_migrations ORDER BY version DESC LIMIT 1;'
|
||||||
|
```
|
||||||
|
|
||||||
|
空库首次启动后,用专用测试账号登录,按当次验收标准验证页面及接口。联调结束在两个终端按 `Ctrl+C` 停服务,数据库由环境管理员按测试数据保留规则管理。
|
||||||
|
|
||||||
|
## 4. 选择测试命令
|
||||||
|
|
||||||
|
| 目的 | 命令 |
|
||||||
|
| --- | --- |
|
||||||
|
| 查看检查及适用范围 | `make list` |
|
||||||
|
| 后端包测试 | `make tests-go` |
|
||||||
|
| 单个 Go 包及相关子包 | `go test -count=1 ./internal/httpapi/...` |
|
||||||
|
| 前端 Vitest 套件 | `make tests-web` |
|
||||||
|
| 单个前端测试文件 | `npm --prefix web test -- src/App.test.tsx` |
|
||||||
|
| 完整提交前检查,与 CI 共用入口 | `make verify` |
|
||||||
|
|
||||||
|
`make verify` 包含安装、格式、静态检查、构建、测试、版本和安全检查,并写出 `ci-report.json`。在未导入真库测试配置的 shell 中运行。若检出时用了 `--no-tags`,先执行 `git fetch --tags origin`,以便版本检查读取正式标签对应的提交。依赖安装与安全检查需要相应网络或缓存。允许跳过的外部依赖用例见 [test-scope.json](../scripts/test-scope.json),真库测试应单独执行并记录结果。
|
||||||
|
|
||||||
|
在应用冒烟之外验证真实 PostgreSQL 行为时,重新按第 2 节切换并核对 **集成测试库和角色**,然后执行目标用例。下面以 UI 设置版本切换用例为例。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
TEST_DATABASE_URL="postgresql://${PGUSER}@${PGHOST}:${PGPORT}/${PGDATABASE}?sslmode=verify-full&connect_timeout=5" \
|
||||||
|
go test -count=1 -v ./internal/platform/postgres -run '^TestUISettingsActivationRetiresPreviousRevisionIntegration$'
|
||||||
|
```
|
||||||
|
|
||||||
|
检查输出出现目标用例的 `PASS`。如果用例被跳过或没有匹配,补齐配置或修正用例名后重跑。提测记录包含完整提交 SHA、执行命令、退出码及失败证据。
|
||||||
|
|
||||||
|
## 5. 浏览器回归与提交前检查
|
||||||
|
|
||||||
|
浏览器用例、固定数据和独立 Vite 配置位于 `web/e2e/`,Playwright 版本由前端锁文件固定。第一次运行先执行 `make deps-install`,再在 QA 机的 `web/` 目录用 `npm exec -- playwright install chromium` 下载对应浏览器。已有浏览器缓存时测试本身可以离线运行。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
make tests-e2e
|
||||||
|
make tests-e2e E2E=scope-rules.spec.ts
|
||||||
|
python3 scripts/test_changed.py --list
|
||||||
|
make test-changed
|
||||||
|
```
|
||||||
|
|
||||||
|
`make tests-e2e` 在 `127.0.0.1:4175` 启动夹具页并用 Chromium 检查目录规则。夹具页加载真实 React 编辑器并拦截 API 请求到固定的内存数据。覆盖保存和刷新读回、显示 HTTP 403、展示子目录与兄弟目录各自的继承来源。后端角色权限由 Go 测试覆盖,规则持久化和继承语义由 PostgreSQL 集成测试覆盖。失败截图与 trace 保存在 `web/test-results/`。
|
||||||
|
|
||||||
|
在独立克隆中可运行 `git config --local core.hooksPath .githooks` 启用仓内提交钩子。钩子先运行可用的全局提交检查,再运行 `make test-changed`。该入口读暂存差异,能定位时只跑修改的测试文件或 Go 包,遇到生产源码或公共依赖改动时扩大到相关套件。对已有仓库自定义钩子的克隆,应在现有钩子中调用 `make test-changed`。`make verify` 继续作为完整提交门禁,Gitea CI 将 Chromium 用例纳入必需检查。本地使用 `make tests-e2e` 直接运行。
|
||||||
@@ -3,7 +3,86 @@
|
|||||||
按"实际干活顺序"排列的**现在的**操作流程。标注:**【新】**本期新增(含本次会话与 `f4e1ecc/6496ee3/9155bd3` 的 dws 取件)|**【变】**既有流程本期有改动|**【既有】**未变,仍照旧走。
|
按"实际干活顺序"排列的**现在的**操作流程。标注:**【新】**本期新增(含本次会话与 `f4e1ecc/6496ee3/9155bd3` 的 dws 取件)|**【变】**既有流程本期有改动|**【既有】**未变,仍照旧走。
|
||||||
逐条验收证据请看 `docs/USER_FLOWS_ACCEPTANCE.md`;细节规则看各自专题文档。
|
逐条验收证据请看 `docs/USER_FLOWS_ACCEPTANCE.md`;细节规则看各自专题文档。
|
||||||
|
|
||||||
统一入口 **http://127.0.0.1:8088/**(测试栈,右侧面板可直接操作)。角色:管理员 / 文档工程师 / 只读。
|
管理员配置连接和发布授权,文档工程师维护资料,只读成员查看进度。先确定要操作的环境,再按下面的接线与验收步骤进入业务流程。
|
||||||
|
|
||||||
|
## 入口与反向代理
|
||||||
|
|
||||||
|
| 请求从哪里发出 | 地址或路径 | 实际目的地 |
|
||||||
|
|---|---|---|
|
||||||
|
| 已接入内网的运维电脑 | `http://100.85.111.121:8088/` | 云测试治理主站 |
|
||||||
|
| 开发电脑的浏览器 | `http://127.0.0.1:28189/` | SSH 转发到测试机回环 `28189`,由候选 Web 提供静态资源 |
|
||||||
|
| 测试候选 Nginx(host 网络) | `/api/`、`/health` | 测试机 `127.0.0.1:18099` 候选 API |
|
||||||
|
| 同一候选 Nginx | `/api/v1/qa-ops/ai/` | 测试机 `127.0.0.1:18098` 现用治理 API,负责模型配置和连接验证 |
|
||||||
|
| 标准 Compose Web(容器网络) | `/api/`、`/health` | Docker DNS 解析 `api:8080`。静态资源和 SPA 回退由同一 Web 提供 |
|
||||||
|
|
||||||
|
**在开发电脑恢复验收入口。** 前提是 SSH 别名 `weknora-test` 能登录测试机。先查远端服务,再查本机监听。本机端口空闲且远端正常时,在独立终端运行第三条命令,保留该终端。在另一终端执行最后一条并用浏览器打开同一地址。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ssh weknora-test 'curl -fsS --max-time 5 http://127.0.0.1:28189/health'
|
||||||
|
ss -ltn 'sport = :28189'
|
||||||
|
ssh -NT -o ExitOnForwardFailure=yes -o ServerAliveInterval=30 -o ServerAliveCountMax=3 -L 127.0.0.1:28189:127.0.0.1:28189 weknora-test
|
||||||
|
curl -fsS --max-time 5 http://127.0.0.1:28189/health
|
||||||
|
```
|
||||||
|
|
||||||
|
**为内网域名配置 HTTPS。** 在能访问测试主站的受信任反代机上配置证书、内部 DNS 和访问范围。以下片段放入已有 HTTPS `server`,完整保留 URI、Host 和会话 Cookie。上游应选治理 Web 入口,使 `/assets/`、`/api/`、`/health` 走同一域名。若该入口的内层代理也设置 `X-Forwarded-Proto`,联调时检查其保留受信任 TLS 终止层的协议值以及登录回调的实际 URL。
|
||||||
|
|
||||||
|
```nginx
|
||||||
|
location / {
|
||||||
|
proxy_pass http://100.85.111.121:8088;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
在反代机执行 `nginx -t` 校验待应用配置。入口启用后,通过该域名验证登录、一次 `/api/` 请求和首页实际引用的 JS/CSS。`index.html` 应重新校验,带哈希的资源可长期缓存,缺失的 JS 返回 404。候选切换前后分别记录通用上游和 AI 专用上游。现场可在测试机用以下只读命令查看,容器名以当时部署为准。仓内同源配置见 [deploy/nginx.conf](../deploy/nginx.conf)。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker exec kg-test-storage-ui-6444814 nginx -T 2>&1 | grep -E 'listen .*28189|location /api/v1/qa-ops/ai/|set \$(api|health)_upstream|proxy_pass http://127[.]0[.]0[.]1:18098'
|
||||||
|
docker inspect -f '{{.Name}} {{index .Config.Labels "release"}}' kg-test-storage-ui-6444814 kg-accept-090-api
|
||||||
|
```
|
||||||
|
|
||||||
|
**现场版本与回退。** 本次在测试机读到 Web 标签 `4b615abe534b`、API 标签 `341c3154ac91`。完整候选包的 `current` 链接位于 `/opt/knowledge-governance/acceptance/090/current`,单独切换的 Web 位于同级 `web-only/4b615abe534b/dist`,实际反代配置位于 `integration/28189.conf`。切换前记录这三处、容器标签与旧 Web 名称。静态页回退时恢复上次的 Web 资源和对应代理配置。完整候选回退按同批装配工具的 `deploy/accept-090/README.md` 执行。回退后用浏览器重新验证首页资源、模型连接和列库。数据库迁移另按备份与恢复方案处理。
|
||||||
|
|
||||||
|
本次已核实共享测试治理库到 `000082`。对内、对外独立启用的实现依赖 `000083`,待独立库联调或共享库迁移获准后,再验证单侧暂停、保存和刷新。生产 `070` 不在该套验收范围。
|
||||||
|
|
||||||
|
下文系统设置中的绑定、盘点和模型连接步骤适用于上表的测试候选版本。根据现场标签选择对应版本的代码和交付物。
|
||||||
|
|
||||||
|
## 接入外部平台
|
||||||
|
|
||||||
|
| 平台与用途 | 管理员或运维怎样接 | 接通的证据 |
|
||||||
|
|---|---|---|
|
||||||
|
| 钉钉知识库,取目录和文件 | 系统设置 → 数据源配置 → 钉钉授权。用 DWS 设备授权,以来源账号选择组织、空间和范围。API 与 worker 使用部署约定的 DWS 身份目录 | 登录后读回预期空间,选一个有权限的目录校验。登记来源、扫描完成和文件取件分别核验。 |
|
||||||
|
| AList,取工业或教育资料 | 按来源登记服务根地址和允许的目录。普通 worker 读取专用令牌文件。目录接口 `POST /api/fs/list` 使用 `X-Gateway-Token` | 在来源页扫描已知根目录,对照一个子目录和一份文件。下载遵循来源签名链接,凭据和签名 URL 仅留在受控运行环境。[目录与取件](SOURCE_CATALOG_LIVE_ROUTING_ACCEPTANCE.md) |
|
||||||
|
| PP 资料门户 | 在数据源配置填写 HTTPS 根地址和来源账号,点「测试连接」后「保存并校验」。API 和 worker 共享 `PP_AUTH_STATE_FILE` 所在目录 | 真实登录并读取一条目录记录,刷新后核对生效配置。超时或限流时查看待验证状态。 |
|
||||||
|
| WeKnora 测试 090,处理与验收 | 系统设置 → 知识库绑定 → 测试 090。当前测试 API 地址 `http://127.0.0.1:8092`,由治理服务器访问。输入该实例的专用 Key 或使用已配置凭据 | 「验证并读取知识库」能列出预期库。核对名称和 ID,为对内、对外选择不同的目标,保存后刷新读回 |
|
||||||
|
| WeKnora 生产 090,列库与映射 | 在同页切到生产 090,使用下节的转发入口与生产专用 Key。新连接的安全存储由 `WEKNORA_BINDING_MASTER_KEY_FILE` 提供 | 读取生产目录并核对两个目标 ID,保存后重新进入生产页核实。执行发布另按 §5–6 授权 |
|
||||||
|
| 问答 AI 模型 | 系统设置 → AI 模型连接,填写 OpenAI 兼容基础地址(含服务要求的 `/v1`)、模型名及专用 Key。API 与普通 worker 使用同一 `QA_AI_MASTER_KEY_FILE` | 点「测试连接」等待成功,需生效时再保存并刷新检查模型名。存储密钥、权限与 DNS 配置见 [README](../README.md#问答运营模型配置) |
|
||||||
|
|
||||||
|
**生产 090 的两段地址。** 生产机私网 IP 为 `172.29.151.11`,其 WeKnora API 对宿主回环发布 `127.0.0.1:18092`。测试治理机上已有 SSH 本地转发,治理 API 使用 host 网络,故页面的生产服务地址填写 **`http://127.0.0.1:18092`**。请求从治理 API 发出,经测试机的回环监听到生产机的回环 API。浏览器所在电脑的 `127.0.0.1:28189` 则用于打开治理页面。迁到 bridge 网络时要从新 API 容器重新验证上游可达性。
|
||||||
|
|
||||||
|
在**测试治理机**上检验已有通道。`/health` 返回 200 证明转发可用,无凭据列库返回 401 表明请求已到认证层。接着在治理页面安全输入该实例的 Key 并验证真实库列表。本次核验时,生产通道探活成功,匿名列库返回 401。带生产凭据列库和保存映射仍待验收。
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ss -ltnp 'sport = :18092'
|
||||||
|
curl --noproxy '*' --max-time 5 -sS -o /dev/null -w 'health %{http_code}\n' http://127.0.0.1:18092/health
|
||||||
|
curl --noproxy '*' --max-time 5 -sS -o /dev/null -w 'catalog %{http_code}\n' http://127.0.0.1:18092/api/v1/knowledge-bases
|
||||||
|
```
|
||||||
|
|
||||||
|
## 开发测试和现场验收
|
||||||
|
|
||||||
|
1. 在开发机运行 `make list` 查看门禁,`make verify` 做整套检查。以 `ci-report.json` 的 `commit_sha` 对照 `git rev-parse HEAD`,记录失败或跳过项。前端启动和组件测试见 [开发与 CI](../README.md#开发与-ci)。
|
||||||
|
2. 针对后端改动,在独立测试逻辑库核对 `SELECT current_database(), max(version) FROM schema_migrations;` 与候选版本的迁移目录。云端多个候选可能共用治理 RDS。只改静态页面时单独切换 Web,保留原资源和代理配置供回滚。
|
||||||
|
3. 在指定入口以真实账号分别验证。来源页读取一条已知记录,模型页测试到成功终态,知识库绑定在正确环境列库,保存后刷新核对。存储页按最近批次和子库目录分别与 `du -sB1 -- <目录>` 对账。记录入口、Web/API 提交、时间和结果。
|
||||||
|
4. 候选备份页读取宿主采集的 `metadata.json`,API 只读挂载输出目录。「重新盘点」只重读文件。超过 `BACKUP_HOST_METADATA_MAX_AGE` 时,目录、占盘和预测转为未知。宿主重新采集后核对采集时间是否前进、批次是否恢复。测试现场使用按次采集、15 分钟有效期。采集脚本和挂载参数以同批测试候选交付物为准。
|
||||||
|
|
||||||
|
| 症状 | 第一步怎么查 | 如何判定 |
|
||||||
|
|---|---|---|
|
||||||
|
| 浏览器连接被拒 | 对照本机 `28189` 监听和测试机 `/health` | 远端正常、本机无监听时恢复本机 SSH 转发 |
|
||||||
|
| 页面打开,某个 API 404 或 502 | 查浏览器请求路径、Nginx 生效上游及对应 API 版本 | 404 先查路由是否存在,502 先查上游是否可达。AI 页单独核对 `18098` |
|
||||||
|
| 能探活,列库仍灰或返回 401 | 核对选中环境、凭据配置状态、容器运行 UID 与凭据文件可读性 | 用该环境的专用身份实际列库。检查过程只记录状态码和可读性 |
|
||||||
|
| 历史可读,计划或配额显示未知 | 核对快照年龄、执行主机连接与配额字段 | 盘点、SSH 计划、配额分别验证。只有主机实际读回 cron 才能报告下一次执行时间 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -241,6 +241,16 @@ func TestAuthRBACMatrix(t *testing.T) {
|
|||||||
t.Fatalf("viewer write = %d", rec.Code)
|
t.Fatalf("viewer write = %d", rec.Code)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, method := range []string{http.MethodPut, http.MethodDelete} {
|
||||||
|
result := httptest.NewRecorder()
|
||||||
|
request := httptest.NewRequest(method, "/api/v1/scope-rules", nil)
|
||||||
|
request.AddCookie(viewer)
|
||||||
|
handler.ServeHTTP(result, request)
|
||||||
|
if result.Code != http.StatusForbidden {
|
||||||
|
t.Fatalf("viewer %s scope rules = %d, want %d", method, result.Code, http.StatusForbidden)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// engineer may create batches but not authorize production
|
// engineer may create batches but not authorize production
|
||||||
rec = httptest.NewRecorder()
|
rec = httptest.NewRecorder()
|
||||||
req = httptest.NewRequest(http.MethodPost, "/api/v1/release-change-sets", strings.NewReader(`{"name":"x"}`))
|
req = httptest.NewRequest(http.MethodPost, "/api/v1/release-change-sets", strings.NewReader(`{"name":"x"}`))
|
||||||
@@ -417,6 +427,9 @@ func TestClassifyRoleMatrix(t *testing.T) {
|
|||||||
http.MethodPost + " /api/v1/release-batches/rb-1/seal": roleEngineer,
|
http.MethodPost + " /api/v1/release-batches/rb-1/seal": roleEngineer,
|
||||||
http.MethodPost + " /api/v1/test-publications/start": roleEngineer,
|
http.MethodPost + " /api/v1/test-publications/start": roleEngineer,
|
||||||
http.MethodGet + " /api/v1/release-plan": roleViewer,
|
http.MethodGet + " /api/v1/release-plan": roleViewer,
|
||||||
|
http.MethodGet + " /api/v1/scope-rules": roleViewer,
|
||||||
|
http.MethodPut + " /api/v1/scope-rules": roleEngineer,
|
||||||
|
http.MethodDelete + " /api/v1/scope-rules": roleEngineer,
|
||||||
}
|
}
|
||||||
for key, want := range cases {
|
for key, want := range cases {
|
||||||
fields := strings.Fields(key)
|
fields := strings.Fields(key)
|
||||||
|
|||||||
@@ -48,7 +48,10 @@ func TestNormalizeRefusesEnabledSettingsWithoutTransportAndBadRecipients(t *test
|
|||||||
t.Fatalf("defaults not applied: %+v %v", good, err)
|
t.Fatalf("defaults not applied: %+v %v", good, err)
|
||||||
}
|
}
|
||||||
// 解析不了的主机名必须仍被判为非法:.invalid 是 RFC 6761 保留域,永远不解析。
|
// 解析不了的主机名必须仍被判为非法:.invalid 是 RFC 6761 保留域,永远不解析。
|
||||||
if _, err := normalize(SettingsInput{Host: "smtp.kg-test.invalid", From: "kb@example.com",
|
// 末尾的点是必须的:构建机的 resolv.conf 可能带 search 域(本环境 Tailscale
|
||||||
|
// 的 tailf49802.ts.net),不带点就会被拼成 smtp.kg-test.invalid.<search> 并
|
||||||
|
// 由 Fake-IP DNS 解析出来,于是这条断言测的是构建机的搜索域而不是被测逻辑。
|
||||||
|
if _, err := normalize(SettingsInput{Host: "smtp.kg-test.invalid.", From: "kb@example.com",
|
||||||
Recipients: []string{"a@example.com"}}); err != ErrInvalid {
|
Recipients: []string{"a@example.com"}}); err != ErrInvalid {
|
||||||
t.Fatalf("unresolvable host must stay invalid, got %v", err)
|
t.Fatalf("unresolvable host must stay invalid, got %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -249,6 +249,8 @@ def checks() -> list[Check]:
|
|||||||
[g, "test", "-count=1", "-json", "./..."], env=env, judge=judge_go_tests),
|
[g, "test", "-count=1", "-json", "./..."], env=env, judge=judge_go_tests),
|
||||||
Check("tests-web", "前端测试(vitest,必须真跑)",
|
Check("tests-web", "前端测试(vitest,必须真跑)",
|
||||||
[py3, "scripts/ci_checks.py", "--internal-web-test"], env=env),
|
[py3, "scripts/ci_checks.py", "--internal-web-test"], env=env),
|
||||||
|
Check("tests-e2e", "Chromium 浏览器回归(CI 必需)", ["make", "tests-e2e-ci"],
|
||||||
|
env=env, required_in=("ci",), note="本地用 make tests-e2e,复用已安装的浏览器"),
|
||||||
Check("contracts", "版本与变更记录契约(不许 SKIP;开发构建不许自称正式版)",
|
Check("contracts", "版本与变更记录契约(不许 SKIP;开发构建不许自称正式版)",
|
||||||
[py3, "scripts/ci_checks.py", "--internal-contracts", g], env=env),
|
[py3, "scripts/ci_checks.py", "--internal-contracts", g], env=env),
|
||||||
Check("version", "CHANGELOG 与版本记录(四类小节无空栏目 + 正式 tag 与提交内版本一致)",
|
Check("version", "CHANGELOG 与版本记录(四类小节无空栏目 + 正式 tag 与提交内版本一致)",
|
||||||
@@ -356,6 +358,9 @@ def cmd_internal_web_test() -> int:
|
|||||||
def cmd_internal_contracts(go: str) -> int:
|
def cmd_internal_contracts(go: str) -> int:
|
||||||
"""版本契约:结构 + 注入身份必须**真 PASS**(SKIP 判红),
|
"""版本契约:结构 + 注入身份必须**真 PASS**(SKIP 判红),
|
||||||
并且**开发构建不许自称正式版**(负例:标成 release ⇒ 必须红)。"""
|
并且**开发构建不许自称正式版**(负例:标成 release ⇒ 必须红)。"""
|
||||||
|
qa_rc = subprocess.run(["make", "test-tooling"], cwd=ROOT).returncode
|
||||||
|
if qa_rc:
|
||||||
|
return qa_rc
|
||||||
snapshot_rc = subprocess.run(py("scripts/development_snapshot.py","--self-test"),cwd=ROOT).returncode
|
snapshot_rc = subprocess.run(py("scripts/development_snapshot.py","--self-test"),cwd=ROOT).returncode
|
||||||
if snapshot_rc:
|
if snapshot_rc:
|
||||||
return 1
|
return 1
|
||||||
@@ -438,6 +443,7 @@ CHECK_MANIFEST: dict[str, tuple[str, ...]] = {
|
|||||||
"build-web": ("local", "ci"),
|
"build-web": ("local", "ci"),
|
||||||
"tests-go": ("local", "ci"),
|
"tests-go": ("local", "ci"),
|
||||||
"tests-web": ("local", "ci"),
|
"tests-web": ("local", "ci"),
|
||||||
|
"tests-e2e": ("ci",),
|
||||||
"contracts": ("local", "ci"),
|
"contracts": ("local", "ci"),
|
||||||
"version": ("local", "ci"),
|
"version": ("local", "ci"),
|
||||||
"security-secrets": ("local", "ci"),
|
"security-secrets": ("local", "ci"),
|
||||||
@@ -631,6 +637,14 @@ def main(argv: list[str]) -> int:
|
|||||||
print(f"\n── [{c.id}] {c.title} ──\n {'✅' if status == SUCCESS else ('⏭️' if status == SKIPPED else '❌')} {reason}")
|
print(f"\n── [{c.id}] {c.title} ──\n {'✅' if status == SUCCESS else ('⏭️' if status == SKIPPED else '❌')} {reason}")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
if args.profile not in c.required_in:
|
||||||
|
reason = f"{args.profile} 档案不要求此项。{c.note}".strip()
|
||||||
|
results.append({"id": c.id, "title": c.title, "required_in": list(c.required_in),
|
||||||
|
"status": SKIPPED, "reason": reason, "command": "",
|
||||||
|
"exit_code": None, "duration_s": 0})
|
||||||
|
print(f"\n── [{c.id}] {c.title} ──\n ⏭️ {reason}")
|
||||||
|
continue
|
||||||
|
|
||||||
print(f"\n── [{c.id}] {c.title} ──")
|
print(f"\n── [{c.id}] {c.title} ──")
|
||||||
print(" $ " + " ".join(c.argv))
|
print(" $ " + " ".join(c.argv))
|
||||||
t0 = time.time()
|
t0 = time.time()
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -eu
|
||||||
|
|
||||||
|
if [ ! -f /.dockerenv ]; then
|
||||||
|
printf '%s\n' 'Chromium provisioning requires the disposable CI container. Use make tests-e2e here.' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Scope mirror settings to this command, keeping the runner image and its apt sources intact.
|
||||||
|
. /etc/os-release
|
||||||
|
if [ "$ID:$VERSION_CODENAME" != ubuntu:noble ]; then
|
||||||
|
printf '%s\n' 'Chromium provisioning expects Ubuntu 24.04.' >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
apt_scope=$(mktemp -d)
|
||||||
|
trap 'rm -f "$apt_scope/ubuntu.list" "$apt_scope/apt.conf"; rmdir "$apt_scope"' EXIT
|
||||||
|
mirror=https://mirrors.aliyun.com/ubuntu/
|
||||||
|
for suite in noble noble-updates noble-security; do
|
||||||
|
printf 'deb [signed-by=/usr/share/keyrings/ubuntu-archive-keyring.gpg] %s %s main universe\n' "$mirror" "$suite"
|
||||||
|
done > "$apt_scope/ubuntu.list"
|
||||||
|
printf 'Dir::Etc::sourcelist "%s/ubuntu.list";\nDir::Etc::sourceparts "-";\nAcquire::Retries "2";\nAcquire::https::Timeout "15";\n' "$apt_scope" > "$apt_scope/apt.conf"
|
||||||
|
export APT_CONFIG="$apt_scope/apt.conf"
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
export PLAYWRIGHT_DOWNLOAD_CONNECTION_TIMEOUT=90000
|
||||||
|
timeout 360s npm --prefix web exec -- playwright install --with-deps --only-shell chromium
|
||||||
@@ -0,0 +1,374 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Prepare and exercise an isolated Knowledge Governance QA run."""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
from contextlib import ExitStack
|
||||||
|
import fcntl
|
||||||
|
import http.client
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
import signal
|
||||||
|
import socket
|
||||||
|
import stat
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
import time
|
||||||
|
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
CONFIG = Path.home() / '.config/knowledge-governance/qa.json'
|
||||||
|
API_PORT = 8088
|
||||||
|
WEB_PORT = 5173
|
||||||
|
RUNTIME_RESPONSE = 'KG_QA_RUNTIME_OK'
|
||||||
|
|
||||||
|
|
||||||
|
class QAError(RuntimeError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def report(stage, detail):
|
||||||
|
print(f'[qa:{stage}] {detail}', flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
def capture(argv, stage, timeout=10, env=None):
|
||||||
|
try:
|
||||||
|
return subprocess.run(argv, cwd=ROOT, env=env, text=True, capture_output=True,
|
||||||
|
timeout=timeout, stdin=subprocess.DEVNULL)
|
||||||
|
except FileNotFoundError as exc:
|
||||||
|
raise QAError(f'{stage} 缺少命令 {argv[0]}') from exc
|
||||||
|
except subprocess.TimeoutExpired as exc:
|
||||||
|
raise QAError(f'{stage} 超过 {timeout} 秒') from exc
|
||||||
|
|
||||||
|
|
||||||
|
def private_file(path):
|
||||||
|
try:
|
||||||
|
info = path.lstat()
|
||||||
|
except FileNotFoundError as exc:
|
||||||
|
raise QAError(f'缺少测试配置文件 {path}') from exc
|
||||||
|
if not stat.S_ISREG(info.st_mode) or info.st_uid != os.getuid() or stat.S_IMODE(info.st_mode) != 0o600:
|
||||||
|
raise QAError(f'{path} 必须是当前用户所有的 0600 普通文件')
|
||||||
|
|
||||||
|
|
||||||
|
def database_config(path):
|
||||||
|
private_file(path)
|
||||||
|
try:
|
||||||
|
config = json.loads(path.read_text())
|
||||||
|
except (UnicodeError, json.JSONDecodeError) as exc:
|
||||||
|
raise QAError(f'{path} 不是有效 JSON') from exc
|
||||||
|
if not isinstance(config, dict) or config.keys() != {'host', 'port', 'database', 'user'}:
|
||||||
|
raise QAError('qa.json 只接受 host、port、database、user 四个字段')
|
||||||
|
for field in ('database', 'user'):
|
||||||
|
if not re.fullmatch(r'kg_qa_[a-z0-9_]{1,56}', str(config[field])):
|
||||||
|
raise QAError(f'RDS {field} 必须以 kg_qa_ 开头并使用小写字母、数字或下划线')
|
||||||
|
host = config['host']
|
||||||
|
if not isinstance(host, str) or not re.fullmatch(r'[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+', host):
|
||||||
|
raise QAError('RDS host 必须填写证书对应的 DNS 主机名')
|
||||||
|
if type(config['port']) is not int or not 1 <= config['port'] <= 65535:
|
||||||
|
raise QAError('RDS port 必须是 1–65535 的整数')
|
||||||
|
return config
|
||||||
|
|
||||||
|
|
||||||
|
def tool_env():
|
||||||
|
allowed = ('HOME', 'PATH', 'LANG', 'TMPDIR', 'GOPROXY', 'GOSUMDB', 'GOPRIVATE', 'GONOSUMDB',
|
||||||
|
'GOMODCACHE', 'GOCACHE', 'npm_config_cache', 'npm_config_registry',
|
||||||
|
'HTTP_PROXY', 'HTTPS_PROXY', 'ALL_PROXY', 'NO_PROXY',
|
||||||
|
'http_proxy', 'https_proxy', 'all_proxy', 'no_proxy')
|
||||||
|
env = {key: os.environ[key] for key in allowed if key in os.environ}
|
||||||
|
env['GOFLAGS'] = '-mod=readonly'
|
||||||
|
return env
|
||||||
|
|
||||||
|
|
||||||
|
def database_env(config, directory):
|
||||||
|
# Keep inherited PG variables and integration switches out of application children.
|
||||||
|
env = tool_env()
|
||||||
|
env.update(PGHOST=config['host'], PGPORT=str(config['port']), PGDATABASE=config['database'],
|
||||||
|
PGUSER=config['user'], PGSSLMODE='verify-full', PGCONNECT_TIMEOUT='5',
|
||||||
|
PGPASSFILE=str(directory / 'qa.pgpass'), PGSSLROOTCERT=str(directory / 'rds-ca.pem'),
|
||||||
|
PGOPTIONS='-c search_path=public', LC_ALL='C',
|
||||||
|
TEST_WEKNORA_ENABLED='false', PP_SCAN_ENABLED='false',
|
||||||
|
RELEASE_WORKER_ENABLED='false', PRODUCTION_RELEASE_REQUESTS_ENABLED='false',
|
||||||
|
DOBOTAI_OPS_READ_ENABLED='false', DOBOTAI_OPS_DIRECTORY_SYNC_ENABLED='false')
|
||||||
|
env['APP_ADDR'] = f'127.0.0.1:{API_PORT}'
|
||||||
|
env['DATA' + 'BASE_URL'] = (
|
||||||
|
f"postgresql://{config['user']}@{config['host']}:{config['port']}/{config['database']}"
|
||||||
|
'?sslmode=verify-full&connect_timeout=5&search_path=public'
|
||||||
|
)
|
||||||
|
return env
|
||||||
|
|
||||||
|
|
||||||
|
def psql(env, sql):
|
||||||
|
result = capture(['psql', '-XAtw', '-v', 'ON_ERROR_STOP=1', '-c', sql], 'RDS 探针', env=env)
|
||||||
|
if result.returncode == 0:
|
||||||
|
return result.stdout.strip()
|
||||||
|
detail = result.stderr.lower()
|
||||||
|
hints = (
|
||||||
|
('password', '口令认证失败,检查 qa.pgpass 和登录角色'),
|
||||||
|
('certificate', 'TLS 校验失败,检查 RDS 主机名和 CA'),
|
||||||
|
('does not exist', '数据库或角色不存在,联系管理员确认专用 QA 库'),
|
||||||
|
('permission denied', 'RDS 权限不足,检查专用 QA 角色的 CONNECT、schema USAGE/CREATE 权限'),
|
||||||
|
('could not translate host name', 'RDS 主机名无法解析,检查私网 DNS'),
|
||||||
|
('timeout', '连接 RDS 超时,检查 QA 虚拟机到 RDS 的私网和安全组'),
|
||||||
|
('connection refused', 'RDS 拒绝 TCP 连接,检查主机名、端口和私网接入'),
|
||||||
|
)
|
||||||
|
hint = next((message for marker, message in hints if marker in detail), '连接或 SQL 探针失败,检查 RDS 接入和权限')
|
||||||
|
raise QAError(f'RDS {hint}(psql 退出 {result.returncode})')
|
||||||
|
|
||||||
|
|
||||||
|
def database_state(env):
|
||||||
|
identity = psql(env, """
|
||||||
|
SELECT concat_ws('|', current_database(), current_user,
|
||||||
|
COALESCE((SELECT ssl FROM pg_stat_ssl WHERE pid = pg_backend_pid()), false),
|
||||||
|
(SELECT NOT (rolsuper OR rolcreaterole OR rolcreatedb OR rolreplication OR rolbypassrls)
|
||||||
|
FROM pg_roles WHERE rolname = current_user),
|
||||||
|
(has_schema_privilege(current_user, 'public', 'USAGE') AND
|
||||||
|
has_schema_privilege(current_user, 'public', 'CREATE')),
|
||||||
|
to_regclass('public.schema_migrations') IS NOT NULL,
|
||||||
|
EXISTS (SELECT FROM pg_class c JOIN pg_namespace n ON n.oid=c.relnamespace
|
||||||
|
WHERE n.nspname = 'public' AND c.relname <> 'schema_migrations')
|
||||||
|
OR EXISTS (SELECT FROM pg_namespace
|
||||||
|
WHERE nspname NOT IN ('public', 'information_schema') AND nspname !~ '^pg_')
|
||||||
|
OR EXISTS (SELECT FROM pg_proc p JOIN pg_namespace n ON n.oid=p.pronamespace
|
||||||
|
WHERE n.nspname = 'public'));
|
||||||
|
""")
|
||||||
|
fields = identity.split('|')
|
||||||
|
if len(fields) != 7 or fields[:4] != [env['PGDATABASE'], env['PGUSER'], 't', 't']:
|
||||||
|
raise QAError('RDS 实际库名、角色、TLS 或角色权限与 QA 配置不符')
|
||||||
|
if fields[4] != 't':
|
||||||
|
raise QAError('RDS 角色需要 public schema 的 USAGE 和 CREATE 权限')
|
||||||
|
rows = psql(env, 'SELECT version FROM public.schema_migrations ORDER BY version;') if fields[5] == 't' else ''
|
||||||
|
if any(not re.fullmatch(r'[0-9]+', row) for row in rows.splitlines()):
|
||||||
|
raise QAError('RDS 迁移记录包含无效版本')
|
||||||
|
return [int(row) for row in rows.splitlines()], fields[6] == 't'
|
||||||
|
|
||||||
|
|
||||||
|
def expected_migrations():
|
||||||
|
paths = (ROOT / 'internal/platform/postgres/migrations').glob('*.up.sql')
|
||||||
|
try:
|
||||||
|
versions = sorted(int(path.name.split('_', 1)[0]) for path in paths)
|
||||||
|
except ValueError as exc:
|
||||||
|
raise QAError('仓库存在无效的迁移文件名') from exc
|
||||||
|
if not versions or len(versions) != len(set(versions)):
|
||||||
|
raise QAError('仓库迁移文件缺失或版本重复')
|
||||||
|
return versions
|
||||||
|
|
||||||
|
|
||||||
|
def check_migrations(expected, applied, nonempty, *, complete):
|
||||||
|
if not applied and nonempty:
|
||||||
|
raise QAError('RDS 非空且缺少有效迁移记录,停止初始化')
|
||||||
|
if expected[:len(applied)] != applied:
|
||||||
|
raise QAError('RDS 迁移序列与当前提交不兼容,使用专用空库或匹配的测试库')
|
||||||
|
if complete and applied != expected:
|
||||||
|
raise QAError(f'RDS 迁移未完成,缺少版本 {expected[len(applied)]} 至 {expected[-1]}')
|
||||||
|
|
||||||
|
|
||||||
|
def check_hifox(output):
|
||||||
|
try:
|
||||||
|
state = json.loads(output)
|
||||||
|
online = state['connected'] is True and state['remoteLiveness']['status'] == 'online'
|
||||||
|
except (ValueError, KeyError, TypeError) as exc:
|
||||||
|
raise QAError('HiFox 未返回有效的在线状态,检查本机注册和接收服务') from exc
|
||||||
|
if not online:
|
||||||
|
raise QAError('HiFox 未确认测试机在线,检查本机接收服务和网络')
|
||||||
|
|
||||||
|
|
||||||
|
def check_checkout(expected):
|
||||||
|
if not re.fullmatch(r'[0-9a-f]{40}', expected):
|
||||||
|
raise QAError('设置 KG_QA_SHA 为提测的完整 40 位 Git SHA')
|
||||||
|
actual = capture(['git', 'rev-parse', 'HEAD'], 'Git 检出')
|
||||||
|
if actual.returncode or actual.stdout.strip() != expected:
|
||||||
|
raise QAError('Git 检出与提测提交不一致')
|
||||||
|
state = capture(['git', 'status', '--porcelain'], 'Git 状态')
|
||||||
|
if state.returncode or state.stdout.strip():
|
||||||
|
raise QAError('QA 需要干净的独立检出,请检查 Git 状态')
|
||||||
|
|
||||||
|
|
||||||
|
def preflight(env):
|
||||||
|
for cmd in ('git', 'make', 'go', 'node', 'npm', 'psql', 'hifox', 'omp'):
|
||||||
|
if not shutil.which(cmd, path=env.get('PATH')):
|
||||||
|
raise QAError(f'工具链缺少 {cmd},检查 QA 机器的 PATH')
|
||||||
|
go = capture(['go', 'env', 'GOROOT', 'GOVERSION'], 'Go 工具链', env=env)
|
||||||
|
fields = go.stdout.splitlines()
|
||||||
|
if go.returncode or len(fields) != 2 or not fields[1].startswith('go1.26.'):
|
||||||
|
raise QAError('QA 需要 Go 1.26 工具链')
|
||||||
|
root = Path(fields[0]) / 'bin'
|
||||||
|
if not os.access(root / 'gofmt', os.X_OK):
|
||||||
|
raise QAError('Go 工具链缺少 gofmt,请安装完整的 Go 1.26')
|
||||||
|
env['PATH'] = f"{root}:{env['PATH']}"
|
||||||
|
node = capture(['node', '--version'], 'Node.js 工具链', env=env)
|
||||||
|
if node.returncode or not node.stdout.startswith('v22.'):
|
||||||
|
raise QAError('QA 需要 Node.js 22 工具链')
|
||||||
|
report('toolchain', f'{fields[1]} / Node.js {node.stdout.strip()}')
|
||||||
|
|
||||||
|
hifox = capture(['hifox', 'computer', 'status', '--output', 'json'], 'HiFox 在线检查', timeout=15)
|
||||||
|
if hifox.returncode:
|
||||||
|
raise QAError(f'HiFox 状态命令失败(退出 {hifox.returncode})')
|
||||||
|
check_hifox(hifox.stdout)
|
||||||
|
report('machine', f'{socket.gethostname()} / HiFox online')
|
||||||
|
prompt = f'Reply with exactly {RUNTIME_RESPONSE}. Do not use tools.'
|
||||||
|
omp = capture(['omp', '--no-session', '-p', prompt], 'OMP Runtime 探针', timeout=35)
|
||||||
|
if omp.returncode or RUNTIME_RESPONSE not in {line.strip() for line in omp.stdout.splitlines()}:
|
||||||
|
raise QAError('OMP Runtime 没有返回探针结果,检查 OMP 模型配置和 Magpie 网关')
|
||||||
|
report('runtime', 'OMP 模型请求通过')
|
||||||
|
|
||||||
|
|
||||||
|
def check_ports():
|
||||||
|
for port in (API_PORT, WEB_PORT):
|
||||||
|
with socket.socket() as listener:
|
||||||
|
listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||||
|
try:
|
||||||
|
listener.bind(('127.0.0.1', port))
|
||||||
|
except OSError as exc:
|
||||||
|
raise QAError(f'QA 端口 {port} 无法绑定,检查已有监听进程') from exc
|
||||||
|
|
||||||
|
|
||||||
|
def run_step(argv, stage, env, timeout):
|
||||||
|
report(stage, ' '.join(argv[:2]))
|
||||||
|
process = subprocess.Popen(argv, cwd=ROOT, env=env, stdin=subprocess.DEVNULL, start_new_session=True)
|
||||||
|
try:
|
||||||
|
code = process.wait(timeout=timeout)
|
||||||
|
except subprocess.TimeoutExpired as exc:
|
||||||
|
raise QAError(f'{stage} 超过 {timeout} 秒') from exc
|
||||||
|
finally:
|
||||||
|
stop_process(process)
|
||||||
|
if code:
|
||||||
|
raise QAError(f'{stage} 失败(退出 {code}),查看上方命令输出')
|
||||||
|
|
||||||
|
|
||||||
|
def stop_process(process):
|
||||||
|
try:
|
||||||
|
os.killpg(process.pid, signal.SIGTERM)
|
||||||
|
except ProcessLookupError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
process.wait(timeout=5)
|
||||||
|
except subprocess.TimeoutExpired:
|
||||||
|
try:
|
||||||
|
os.killpg(process.pid, signal.SIGKILL)
|
||||||
|
except ProcessLookupError:
|
||||||
|
pass
|
||||||
|
process.wait(timeout=5)
|
||||||
|
|
||||||
|
|
||||||
|
def start_service(stack, argv, env, log):
|
||||||
|
output = stack.enter_context(log.open('w', encoding='utf-8'))
|
||||||
|
process = subprocess.Popen(argv, cwd=ROOT, env=env, stdin=subprocess.DEVNULL,
|
||||||
|
stdout=output, stderr=subprocess.STDOUT, start_new_session=True)
|
||||||
|
stack.callback(stop_process, process)
|
||||||
|
return process
|
||||||
|
|
||||||
|
|
||||||
|
def request(port, path):
|
||||||
|
connection = http.client.HTTPConnection('127.0.0.1', port, timeout=2)
|
||||||
|
try:
|
||||||
|
connection.request('GET', path)
|
||||||
|
response = connection.getresponse()
|
||||||
|
return response.status, response.getheader('Content-Type', ''), response.read(32768)
|
||||||
|
finally:
|
||||||
|
connection.close()
|
||||||
|
|
||||||
|
|
||||||
|
def probe(port, path, expected):
|
||||||
|
try:
|
||||||
|
code, content_type, body = request(port, path)
|
||||||
|
if code != 200:
|
||||||
|
return False
|
||||||
|
if expected == 'html':
|
||||||
|
return 'text/html' in content_type and b'id="root"' in body
|
||||||
|
return 'application/json' in content_type and json.loads(body)['status'] == expected
|
||||||
|
except (OSError, http.client.HTTPException, ValueError, KeyError, TypeError):
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def wait_service(process, port, path, expected, log):
|
||||||
|
deadline = time.monotonic() + 45
|
||||||
|
while time.monotonic() < deadline:
|
||||||
|
if process.poll() is not None:
|
||||||
|
raise QAError(f'服务端口 {port} 启动进程提前退出(退出 {process.returncode}),日志 {log}')
|
||||||
|
if probe(port, path, expected):
|
||||||
|
return
|
||||||
|
time.sleep(0.25)
|
||||||
|
raise QAError(f'服务探针超时 127.0.0.1:{port}{path},日志 {log}')
|
||||||
|
|
||||||
|
|
||||||
|
def qa_run(commit, env, db_env, versions, state):
|
||||||
|
with tempfile.TemporaryDirectory(prefix='run-', dir=state) as directory, ExitStack() as services:
|
||||||
|
binary = Path(directory) / 'api'
|
||||||
|
run_step(['make', 'deps-install'], 'deps', env, 300)
|
||||||
|
ldflags = f'-X knowledge-governance/internal/version.CommitSHA={commit}'
|
||||||
|
run_step(['go', 'build', '-ldflags', ldflags, '-o', str(binary), './cmd/api'], 'build-api', env, 300)
|
||||||
|
check_ports()
|
||||||
|
log_dir = Path(tempfile.mkdtemp(prefix=f'{commit[:12]}-', dir=state))
|
||||||
|
report('logs', str(log_dir))
|
||||||
|
app_env = db_env | {'PATH': env['PATH'], 'GOVERNANCE_SPOOL_ROOT': str(Path(directory) / 'spool')}
|
||||||
|
api_log = log_dir / 'api.log'
|
||||||
|
api = start_service(services, [str(binary)], app_env, api_log)
|
||||||
|
wait_service(api, API_PORT, '/readyz', 'ready', api_log)
|
||||||
|
check_migrations(versions, *database_state(db_env), complete=True)
|
||||||
|
report('migration', f'已核对全部 {len(versions)} 条迁移,最新版本 {versions[-1]}')
|
||||||
|
|
||||||
|
web_log = log_dir / 'web.log'
|
||||||
|
web = start_service(services, ['npm', '--prefix', 'web', 'run', 'dev', '--', '--host', '127.0.0.1',
|
||||||
|
'--port', str(WEB_PORT), '--strictPort'], env, web_log)
|
||||||
|
wait_service(web, WEB_PORT, '/', 'html', web_log)
|
||||||
|
wait_service(web, WEB_PORT, '/health', 'ok', web_log)
|
||||||
|
report('services', 'API /readyz、Web 首页与 Vite /health 代理通过')
|
||||||
|
run_step(['make', 'tests-go', 'tests-web', 'tests-e2e'], 'tests', env, 300)
|
||||||
|
check_checkout(commit)
|
||||||
|
if api.poll() is not None or web.poll() is not None or not probe(WEB_PORT, '/health', 'ok'):
|
||||||
|
raise QAError(f'服务在测试期间失去健康状态,日志目录 {log_dir}')
|
||||||
|
report('result', f'PASS {commit},已停止本次 API 和 Web 进程')
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument('action', choices=('doctor', 'run'))
|
||||||
|
args = parser.parse_args()
|
||||||
|
env = tool_env()
|
||||||
|
try:
|
||||||
|
commit = os.environ.get('KG_QA_SHA', '')
|
||||||
|
if args.action == 'run':
|
||||||
|
check_checkout(commit)
|
||||||
|
check_ports()
|
||||||
|
preflight(env)
|
||||||
|
config_path = Path(os.environ.get('KG_QA_CONFIG', CONFIG)).expanduser().absolute()
|
||||||
|
config = database_config(config_path)
|
||||||
|
private_file(config_path.parent / 'qa.pgpass')
|
||||||
|
if not (config_path.parent / 'rds-ca.pem').is_file():
|
||||||
|
raise QAError(f'缺少 RDS CA 文件 {config_path.parent / "rds-ca.pem"}')
|
||||||
|
db_env = database_env(config, config_path.parent)
|
||||||
|
versions = expected_migrations()
|
||||||
|
if args.action == 'doctor':
|
||||||
|
applied, nonempty = database_state(db_env)
|
||||||
|
check_migrations(versions, applied, nonempty, complete=False)
|
||||||
|
report('database', f'连接与身份正常,已应用 {len(applied)}/{len(versions)} 条迁移')
|
||||||
|
return 0
|
||||||
|
|
||||||
|
state = Path.home() / '.local/state/knowledge-governance/qa'
|
||||||
|
state.mkdir(mode=0o700, parents=True, exist_ok=True)
|
||||||
|
with (state / 'run.lock').open('a') as lock:
|
||||||
|
try:
|
||||||
|
fcntl.flock(lock, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
|
except BlockingIOError as exc:
|
||||||
|
raise QAError('本机已有 QA 任务,等待当前任务退出') from exc
|
||||||
|
check_ports()
|
||||||
|
check_migrations(versions, *database_state(db_env), complete=False)
|
||||||
|
qa_run(commit, env, db_env, versions, state)
|
||||||
|
return 0
|
||||||
|
except (QAError, OSError, ValueError) as exc:
|
||||||
|
print(f'[qa:FAIL] {exc}', file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print('[qa:FAIL] QA 任务中断', file=sys.stderr)
|
||||||
|
return 130
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
def interrupt(_signal, _frame):
|
||||||
|
raise KeyboardInterrupt
|
||||||
|
|
||||||
|
signal.signal(signal.SIGTERM, interrupt)
|
||||||
|
sys.exit(main())
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Select verification commands for staged changes."""
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
from pathlib import Path, PurePosixPath
|
||||||
|
import re
|
||||||
|
import shlex
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
|
||||||
|
ROOT = Path(__file__).resolve().parents[1]
|
||||||
|
|
||||||
|
|
||||||
|
def select_commands(paths, removed=()):
|
||||||
|
removed = set(removed)
|
||||||
|
full_go = full_web = browser = tooling = False
|
||||||
|
go_packages, web_tests = set(), set()
|
||||||
|
for name in paths:
|
||||||
|
path = PurePosixPath(name)
|
||||||
|
if name.startswith('docs/') or path.suffix == '.md':
|
||||||
|
continue
|
||||||
|
if name.startswith('web/e2e/') or name == 'web/playwright.config.ts':
|
||||||
|
browser = True
|
||||||
|
elif name.startswith('web/'):
|
||||||
|
if (name not in removed and name.startswith('web/src/') and
|
||||||
|
re.fullmatch(r'[\w./-]+\.test\.[jt]sx?', name)):
|
||||||
|
web_tests.add(str(path.relative_to('web')))
|
||||||
|
else:
|
||||||
|
full_web = browser = True
|
||||||
|
elif name.startswith(('scripts/', '.githooks/')) or name == 'Makefile':
|
||||||
|
tooling = full_go = full_web = browser = True
|
||||||
|
elif path.name.endswith('_test.go') and name not in removed:
|
||||||
|
go_packages.add('./' + path.parent.as_posix())
|
||||||
|
elif path.suffix == '.go' or name in ('go.mod', 'go.sum') or name.startswith(('internal/', 'cmd/')):
|
||||||
|
full_go = True
|
||||||
|
else:
|
||||||
|
full_go = full_web = browser = True
|
||||||
|
commands = []
|
||||||
|
if tooling:
|
||||||
|
commands.append(['make', 'test-tooling'])
|
||||||
|
if full_go:
|
||||||
|
commands.append(['make', 'tests-go'])
|
||||||
|
elif go_packages:
|
||||||
|
commands.append(['go', 'test', '-count=1', *sorted(go_packages)])
|
||||||
|
if full_web:
|
||||||
|
commands.append(['make', 'tests-web'])
|
||||||
|
elif web_tests:
|
||||||
|
commands.append(['npm', '--prefix', 'web', 'test', '--', *sorted(web_tests)])
|
||||||
|
if browser:
|
||||||
|
commands.append(['make', 'tests-e2e'])
|
||||||
|
return commands
|
||||||
|
|
||||||
|
|
||||||
|
def staged_names(*args):
|
||||||
|
result = subprocess.check_output(['git', 'diff', '--cached', '--no-renames', '--name-only', '-z', *args], cwd=ROOT)
|
||||||
|
return [name for name in result.decode('utf-8', errors='surrogateescape').split('\0') if name]
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(description=__doc__)
|
||||||
|
parser.add_argument('--list', action='store_true', help='print selected commands only')
|
||||||
|
args = parser.parse_args()
|
||||||
|
commands = select_commands(staged_names(), staged_names('--diff-filter=D'))
|
||||||
|
if not commands:
|
||||||
|
print('暂无需要执行测试的暂存文件')
|
||||||
|
return 0
|
||||||
|
if not args.list:
|
||||||
|
unstaged = subprocess.check_output(['git', 'diff', '--name-only', '-z'], cwd=ROOT)
|
||||||
|
paths = [name for name in unstaged.decode('utf-8', errors='surrogateescape').split('\0') if name]
|
||||||
|
if select_commands(paths):
|
||||||
|
print('还有未暂存的代码或配置,先整理工作区后再检查暂存改动', file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
for cmd in commands:
|
||||||
|
print(shlex.join(cmd), flush=True)
|
||||||
|
if not args.list:
|
||||||
|
code = subprocess.run(cmd, cwd=ROOT, check=False).returncode
|
||||||
|
if code:
|
||||||
|
return code
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
sys.exit(main())
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from threading import Thread
|
||||||
|
from pathlib import Path
|
||||||
|
import subprocess
|
||||||
|
import tempfile
|
||||||
|
import unittest
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
import qa_env
|
||||||
|
|
||||||
|
|
||||||
|
class QAEnvironmentTests(unittest.TestCase):
|
||||||
|
def test_missing_approval_config_names_file(self):
|
||||||
|
with tempfile.TemporaryDirectory() as directory:
|
||||||
|
config = Path(directory) / 'qa.json'
|
||||||
|
with self.assertRaisesRegex(qa_env.QAError, 'qa.json'):
|
||||||
|
qa_env.database_config(config)
|
||||||
|
|
||||||
|
def test_rejects_non_qa_database_before_connection(self):
|
||||||
|
with tempfile.TemporaryDirectory() as directory:
|
||||||
|
config = Path(directory) / 'qa.json'
|
||||||
|
config.write_text(json.dumps(dict(host='rds.example.test', port=5432,
|
||||||
|
database='governance', user='kg_qa_app')))
|
||||||
|
config.chmod(0o600)
|
||||||
|
with self.assertRaisesRegex(qa_env.QAError, 'kg_qa_'):
|
||||||
|
qa_env.database_config(config)
|
||||||
|
|
||||||
|
def test_database_environment_uses_only_approved_identity(self):
|
||||||
|
settings = dict(host='rds.example.test', port=5432, database='kg_qa_app', user='kg_qa_app')
|
||||||
|
with patch.dict(os.environ, {'PGHOSTADDR': '127.0.0.1', 'PGPASSWORD': 'fixture',
|
||||||
|
'PGSERVICE': 'other', 'PRODUCTION_RELEASE_REQUESTS_ENABLED': 'true'}):
|
||||||
|
env = qa_env.database_env(settings, Path('/approved'))
|
||||||
|
self.assertEqual(env['PGHOST'], 'rds.example.test')
|
||||||
|
self.assertEqual(env['PGSSLMODE'], 'verify-full')
|
||||||
|
self.assertEqual(env['PRODUCTION_RELEASE_REQUESTS_ENABLED'], 'false')
|
||||||
|
self.assertFalse({'PGHOSTADDR', 'PGPASSWORD', 'PGSERVICE'} & env.keys())
|
||||||
|
|
||||||
|
def test_empty_database_or_known_migration_prefix_can_bootstrap(self):
|
||||||
|
for applied in ([], [1], [1, 2]):
|
||||||
|
with self.subTest(applied=applied):
|
||||||
|
qa_env.check_migrations([1, 2], applied, False, complete=False)
|
||||||
|
|
||||||
|
def test_pending_migrations_block_testing(self):
|
||||||
|
with self.assertRaisesRegex(qa_env.QAError, '迁移未完成'):
|
||||||
|
qa_env.check_migrations([1, 2], [1], False, complete=True)
|
||||||
|
|
||||||
|
def test_schema_without_ledger_is_rejected(self):
|
||||||
|
with self.assertRaisesRegex(qa_env.QAError, '非空'):
|
||||||
|
qa_env.check_migrations([1, 2], [], True, complete=False)
|
||||||
|
|
||||||
|
def test_unknown_or_missing_middle_migrations_are_rejected(self):
|
||||||
|
for applied in ([1, 3], [1, 2, 3], [2]):
|
||||||
|
with self.subTest(applied=applied), self.assertRaisesRegex(qa_env.QAError, '迁移序列'):
|
||||||
|
qa_env.check_migrations([1, 2], applied, False, complete=False)
|
||||||
|
|
||||||
|
def test_hifox_exit_zero_does_not_override_offline_state(self):
|
||||||
|
with self.assertRaisesRegex(qa_env.QAError, '在线'):
|
||||||
|
qa_env.check_hifox('{"connected":true,"remoteLiveness":{"status":"offline"}}')
|
||||||
|
qa_env.check_hifox('{"connected":true,"remoteLiveness":{"status":"online"}}')
|
||||||
|
|
||||||
|
def test_health_probe_rejects_spa_fallback(self):
|
||||||
|
class Handler(BaseHTTPRequestHandler):
|
||||||
|
def do_GET(self):
|
||||||
|
self.send_response(200)
|
||||||
|
self.send_header('Content-Type', 'text/html')
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(b'<html><div id="root"></div></html>')
|
||||||
|
|
||||||
|
def log_message(self, format, *args):
|
||||||
|
pass
|
||||||
|
|
||||||
|
with ThreadingHTTPServer(('127.0.0.1', 0), Handler) as server:
|
||||||
|
thread = Thread(target=server.serve_forever)
|
||||||
|
thread.start()
|
||||||
|
try:
|
||||||
|
self.assertTrue(qa_env.probe(server.server_port, '/', 'html'))
|
||||||
|
self.assertFalse(qa_env.probe(server.server_port, '/health', 'ok'))
|
||||||
|
finally:
|
||||||
|
server.shutdown()
|
||||||
|
thread.join()
|
||||||
|
|
||||||
|
def test_database_identity_mismatch_stops_before_reading_migrations(self):
|
||||||
|
env = {'PGDATABASE': 'kg_qa_app', 'PGUSER': 'kg_qa_app'}
|
||||||
|
with patch.object(qa_env, 'psql', return_value='other|kg_qa_app|t|t|t|t|t') as probe:
|
||||||
|
with self.assertRaisesRegex(qa_env.QAError, '实际库名'):
|
||||||
|
qa_env.database_state(env)
|
||||||
|
self.assertEqual(probe.call_count, 1)
|
||||||
|
|
||||||
|
def test_full_sha_mismatch_rejects_current_checkout(self):
|
||||||
|
full_sha = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=qa_env.ROOT, text=True).strip()
|
||||||
|
wrong = ('0' if full_sha[0] != '0' else '1') + full_sha[1:]
|
||||||
|
with self.assertRaisesRegex(qa_env.QAError, '提交不一致'):
|
||||||
|
qa_env.check_checkout(wrong)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import unittest
|
||||||
|
|
||||||
|
from test_changed import select_commands
|
||||||
|
|
||||||
|
|
||||||
|
class SelectionTests(unittest.TestCase):
|
||||||
|
def test_documentation_only(self):
|
||||||
|
self.assertEqual(select_commands(['docs/DEVELOPMENT_AND_TESTING.md']), [])
|
||||||
|
|
||||||
|
def test_go_test_only_selects_its_package(self):
|
||||||
|
self.assertEqual(select_commands(['internal/governance/a_test.go']),
|
||||||
|
[['go', 'test', '-count=1', './internal/governance']])
|
||||||
|
|
||||||
|
def test_go_source_and_migration_fall_back_to_suite(self):
|
||||||
|
for name in ('internal/governance/model.go', 'internal/platform/postgres/migrations/0099_qa.up.sql'):
|
||||||
|
self.assertEqual(select_commands([name]), [['make', 'tests-go']])
|
||||||
|
|
||||||
|
def test_frontend_test_only_selects_its_file(self):
|
||||||
|
self.assertEqual(select_commands(['web/src/scopeRules.test.ts']),
|
||||||
|
[['npm', '--prefix', 'web', 'test', '--', 'src/scopeRules.test.ts']])
|
||||||
|
|
||||||
|
def test_shared_frontend_code_covers_browser_suite(self):
|
||||||
|
self.assertEqual(select_commands(['web/src/scopeRules.ts']),
|
||||||
|
[['make', 'tests-web'], ['make', 'tests-e2e']])
|
||||||
|
|
||||||
|
def test_e2e_only_runs_browser_suite(self):
|
||||||
|
self.assertEqual(select_commands(['web/e2e/scope-rules.spec.ts']), [['make', 'tests-e2e']])
|
||||||
|
|
||||||
|
def test_unsafe_unknown_paths_fall_back_to_all_relevant_suites(self):
|
||||||
|
self.assertEqual(select_commands(['new-runtime.conf']),
|
||||||
|
[['make', 'tests-go'], ['make', 'tests-web'], ['make', 'tests-e2e']])
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
dist/
|
dist/
|
||||||
|
test-results/
|
||||||
|
playwright-report/
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
package-lock.json
|
package-lock.json
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="zh-CN">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>目录范围规则测试</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="root"></div>
|
||||||
|
<script type="module" src="./scope-rules.tsx"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,128 @@
|
|||||||
|
import { expect, test, type Page } from '@playwright/test'
|
||||||
|
import { document as sample } from '../src/documentFixture'
|
||||||
|
import type { ScopeRule, ScopeRuleDecision } from '../src/scopeRules'
|
||||||
|
|
||||||
|
const cases = [
|
||||||
|
{ id: 'parent', directory_path: '产品', title: '总览.pdf' },
|
||||||
|
{ id: 'child', directory_path: '产品/手册', title: '手册.pdf' },
|
||||||
|
{ id: 'sibling', directory_path: '产品/固件', title: '固件.pdf' },
|
||||||
|
]
|
||||||
|
const existing: ScopeRule = {
|
||||||
|
target_type: 'directory',
|
||||||
|
connection_id: 'pp-1',
|
||||||
|
directory_path: '产品',
|
||||||
|
visibility: 'external',
|
||||||
|
reason: '父目录已公开',
|
||||||
|
updated_by: 'QA工程师',
|
||||||
|
updated_at: sample.updated_at,
|
||||||
|
}
|
||||||
|
|
||||||
|
async function scopeFixture(page: Page, canWrite = true) {
|
||||||
|
const rules = new Map<string, ScopeRule>([['产品', existing]])
|
||||||
|
const changes: ScopeRuleDecision[] = []
|
||||||
|
|
||||||
|
await page.route('**/*', async (route) => {
|
||||||
|
const request = route.request()
|
||||||
|
const url = new URL(request.url())
|
||||||
|
if (url.hostname !== '127.0.0.1' || url.port !== '4175') return route.abort()
|
||||||
|
if (url.pathname === '/api/v1/scope-rules') {
|
||||||
|
if (request.method() === 'GET' && url.searchParams.get('connection_id') === 'pp-1') {
|
||||||
|
return route.fulfill({ json: { data: [...rules.values()] } })
|
||||||
|
}
|
||||||
|
if (request.method() === 'PUT') {
|
||||||
|
const input = request.postDataJSON() as ScopeRuleDecision
|
||||||
|
changes.push(input)
|
||||||
|
if (!canWrite) return route.fulfill({ status: 403, json: { error: 'forbidden' } })
|
||||||
|
if (
|
||||||
|
input.target_type !== 'directory' ||
|
||||||
|
input.connection_id !== 'pp-1' ||
|
||||||
|
!cases.some((item) => item.directory_path === input.directory_path) ||
|
||||||
|
!request.headers()['idempotency-key'] ||
|
||||||
|
!input.reason.trim()
|
||||||
|
) {
|
||||||
|
return route.fulfill({ status: 400, json: { error: 'invalid fixture input' } })
|
||||||
|
}
|
||||||
|
const rule = { ...existing, ...input }
|
||||||
|
rules.set(input.directory_path, rule)
|
||||||
|
return route.fulfill({ json: { data: rule } })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (url.pathname === '/api/v1/source-items' && request.method() === 'GET') {
|
||||||
|
const items = cases.map((item) => {
|
||||||
|
const rule = rules.get(item.directory_path) ?? rules.get('产品')!
|
||||||
|
return {
|
||||||
|
...sample,
|
||||||
|
...item,
|
||||||
|
visibility: rule.visibility,
|
||||||
|
visibility_origin: 'directory_rule',
|
||||||
|
scope_rule_path: rule.directory_path,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return route.fulfill({ json: { data: items, summary: { total: items.length }, offset: 0, limit: 100 } })
|
||||||
|
}
|
||||||
|
if (url.pathname.startsWith('/api/'))
|
||||||
|
return route.fulfill({ status: 404, json: { error: 'unexpected fixture request' } })
|
||||||
|
return route.continue()
|
||||||
|
})
|
||||||
|
await page.goto('/e2e/scope-rules.html')
|
||||||
|
return changes
|
||||||
|
}
|
||||||
|
|
||||||
|
function openDirectory(page: Page, name: string) {
|
||||||
|
return page
|
||||||
|
.getByRole('complementary', { name: '来源目录' })
|
||||||
|
.getByRole('button', { name: new RegExp(`^▸ ${name} \\d+$`) })
|
||||||
|
.click()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveInternal(page: Page) {
|
||||||
|
const editor = page.getByRole('region', { name: '对内对外范围设置' })
|
||||||
|
await editor.getByLabel('拟修改为').selectOption('internal')
|
||||||
|
await expect(editor.getByRole('button', { name: '保存范围' })).toBeDisabled()
|
||||||
|
await editor.getByLabel('判断原因').fill(' 仅供内部使用 ')
|
||||||
|
await editor.getByRole('button', { name: '保存范围' }).click()
|
||||||
|
}
|
||||||
|
|
||||||
|
test('编辑器保存目录范围并在刷新后读回', async ({ page }) => {
|
||||||
|
const changes = await scopeFixture(page)
|
||||||
|
await openDirectory(page, '产品/手册')
|
||||||
|
await saveInternal(page)
|
||||||
|
await expect(page.getByText('当前设置:对内')).toBeVisible()
|
||||||
|
expect(changes).toEqual([
|
||||||
|
{
|
||||||
|
target_type: 'directory',
|
||||||
|
connection_id: 'pp-1',
|
||||||
|
directory_path: '产品/手册',
|
||||||
|
source_item_id: '',
|
||||||
|
visibility: 'internal',
|
||||||
|
reason: '仅供内部使用',
|
||||||
|
},
|
||||||
|
])
|
||||||
|
await page.reload()
|
||||||
|
await openDirectory(page, '产品/手册')
|
||||||
|
await expect(page.getByText('当前设置:对内')).toBeVisible()
|
||||||
|
await expect(page.getByRole('row', { name: /手册.pdf/ })).toContainText('继承目录设置:产品/手册')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('编辑器显示只读拒绝并保留原规则', async ({ page }) => {
|
||||||
|
const changes = await scopeFixture(page, false)
|
||||||
|
await openDirectory(page, '产品/手册')
|
||||||
|
await saveInternal(page)
|
||||||
|
await expect(page.getByRole('alert')).toHaveText('保存范围规则失败(HTTP 403)')
|
||||||
|
expect(changes).toHaveLength(1)
|
||||||
|
await page.reload()
|
||||||
|
await openDirectory(page, '产品/手册')
|
||||||
|
await expect(page.getByText('当前没有本级设置')).toBeVisible()
|
||||||
|
await expect(page.getByRole('row', { name: /手册.pdf/ })).toContainText('继承目录设置:产品')
|
||||||
|
})
|
||||||
|
|
||||||
|
test('编辑器刷新并显示子目录规则和兄弟目录的继承来源', async ({ page }) => {
|
||||||
|
await scopeFixture(page)
|
||||||
|
await openDirectory(page, '产品/手册')
|
||||||
|
await saveInternal(page)
|
||||||
|
await expect(page.getByRole('row', { name: /手册.pdf/ })).toContainText('继承目录设置:产品/手册')
|
||||||
|
await openDirectory(page, '产品/固件')
|
||||||
|
const sibling = page.getByRole('row', { name: /固件.pdf/ })
|
||||||
|
await expect(sibling).toContainText('对外')
|
||||||
|
await expect(sibling).toContainText('继承目录设置:产品')
|
||||||
|
})
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { createRoot } from 'react-dom/client'
|
||||||
|
import { DocumentWorkbench } from '../src/DocumentWorkbench'
|
||||||
|
|
||||||
|
createRoot(document.getElementById('root')!).render(<DocumentWorkbench mode="directory" connections={[]} />)
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import react from '@vitejs/plugin-react'
|
||||||
|
|
||||||
|
export default defineConfig({ plugins: [react()], publicDir: false })
|
||||||
Generated
+46
@@ -14,6 +14,7 @@
|
|||||||
"remark-gfm": "4.0.1"
|
"remark-gfm": "4.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@playwright/test": "1.65.1",
|
||||||
"@types/react": "19.1.10",
|
"@types/react": "19.1.10",
|
||||||
"@types/react-dom": "19.1.7",
|
"@types/react-dom": "19.1.7",
|
||||||
"@vitejs/plugin-react": "5.0.1",
|
"@vitejs/plugin-react": "5.0.1",
|
||||||
@@ -814,6 +815,22 @@
|
|||||||
"node": "^22.20 || ^24.12 || >=25"
|
"node": "^22.20 || ^24.12 || >=25"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@playwright/test": {
|
||||||
|
"version": "1.65.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.1.tgz",
|
||||||
|
"integrity": "sha512-y+NCIRm2LvY4slUVWvGh1nujJ8RF/hEisIsq2mtUPgdQC4L701bq5hZGMhrpeXjACvwvO9tj5dJqhvM6TP9lbw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"playwright": "1.65.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"playwright": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@rolldown/pluginutils": {
|
"node_modules/@rolldown/pluginutils": {
|
||||||
"version": "1.0.0-beta.32",
|
"version": "1.0.0-beta.32",
|
||||||
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.32.tgz",
|
"resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-beta.32.tgz",
|
||||||
@@ -2887,6 +2904,35 @@
|
|||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/playwright": {
|
||||||
|
"version": "1.65.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.1.tgz",
|
||||||
|
"integrity": "sha512-vJ1FuoOrNwOKHUIVEvSt3jT1L+wjjDpwhwIstKtfvTh8XIG4FG4bIFuvNdMxi81LGfAhUgUZleVFaOLY4RIUUw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"playwright-core": "1.65.1"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"playwright": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/playwright-core": {
|
||||||
|
"version": "1.65.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.1.tgz",
|
||||||
|
"integrity": "sha512-hqPpz7blSMPxWVdoeE1yiBSzXsKiVOd2k+kjCvmUywD2GPO2Dd9HfcWnq9NN0GHbNZDFgZ9JfBFr+X5/BLo0qw==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"playwright-core": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/postcss": {
|
"node_modules/postcss": {
|
||||||
"version": "8.5.26",
|
"version": "8.5.26",
|
||||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.26.tgz",
|
||||||
|
|||||||
+3
-1
@@ -5,7 +5,8 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite --host 0.0.0.0",
|
"dev": "vite --host 0.0.0.0",
|
||||||
"test": "vitest run",
|
"test": "vitest run --exclude 'e2e/**'",
|
||||||
|
"test:e2e": "playwright test",
|
||||||
"build": "tsc -b && vite build",
|
"build": "tsc -b && vite build",
|
||||||
"typecheck": "tsc -b --pretty false",
|
"typecheck": "tsc -b --pretty false",
|
||||||
"format": "prettier --write .",
|
"format": "prettier --write .",
|
||||||
@@ -18,6 +19,7 @@
|
|||||||
"remark-gfm": "4.0.1"
|
"remark-gfm": "4.0.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@playwright/test": "1.65.1",
|
||||||
"@types/react": "19.1.10",
|
"@types/react": "19.1.10",
|
||||||
"@types/react-dom": "19.1.7",
|
"@types/react-dom": "19.1.7",
|
||||||
"@vitejs/plugin-react": "5.0.1",
|
"@vitejs/plugin-react": "5.0.1",
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import { defineConfig } from '@playwright/test'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
testDir: './e2e',
|
||||||
|
workers: 1,
|
||||||
|
retries: 0,
|
||||||
|
forbidOnly: true,
|
||||||
|
timeout: 15000,
|
||||||
|
expect: { timeout: 5000 },
|
||||||
|
use: {
|
||||||
|
browserName: 'chromium',
|
||||||
|
baseURL: 'http://127.0.0.1:4175',
|
||||||
|
serviceWorkers: 'block',
|
||||||
|
trace: 'retain-on-failure',
|
||||||
|
screenshot: 'only-on-failure',
|
||||||
|
},
|
||||||
|
webServer: {
|
||||||
|
command: 'vite --config e2e/vite.config.ts --host 127.0.0.1 --port 4175 --strictPort',
|
||||||
|
url: 'http://127.0.0.1:4175/e2e/scope-rules.html',
|
||||||
|
reuseExistingServer: false,
|
||||||
|
timeout: 20000,
|
||||||
|
},
|
||||||
|
})
|
||||||
+1
-1
@@ -17,5 +17,5 @@
|
|||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"types": ["vitest/globals", "vite/client"]
|
"types": ["vitest/globals", "vite/client"]
|
||||||
},
|
},
|
||||||
"include": ["src", "vite.config.ts"]
|
"include": ["src", "e2e", "vite.config.ts", "playwright.config.ts"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user