W1 引入 db/migration/V1-V3 后,平台表 DDL 在迁移与各模块 bootstrap-*.sql 重复
(评审揪出的"易漂移")。本次收敛,db/migration 成唯一真相:
- 删 3 份重复 bootstrap:bootstrap-page-schema(=V1)/bootstrap-datastatus(=V2)/
bootstrap-ai-agent(=V3)。三者无运行态 classpath 消费者(已全仓核实)。
- AiAgentDdlTest(platform-ai,原读 bootstrap-ai-agent.sql)删除,等价覆盖迁入
platform-app 新增 PlatformMigrationDdlGuardTest:① 守 V3 声明全部 AI 平台表/索引;
② 守 SchemaImportCli.CREATE_DDL ≡ V1(独立 CLI 兜底 DDL 防漂移)。
- SchemaImportCli.CREATE_DDL 由包私有改 public 供上述 guard 比对;两处过时注释改指 V1。
- ci.sh 平台表预灌改指 db/migration/V1(注:app 启动 Flyway 已幂等建表,此预灌仅冗余兜底)。
- docs 对齐:AI_AGENT_AUTO_DEVELOPMENT(spring.sql.init→Flyway)、docs/sql/SYS_PAGE_SCHEMA
/SYS_AI_AGENT 头注释(待办→已落地)、A10 design 残留收敛标完成、deploy/README 残留项标完成。
边界:platform-parity 的 bootstrap-{sys,privilege,auth,xservice,multidim,flow}.sql 是
eip3 schema 对拍测试 fixture,非平台表副本,原样保留。
验证:全 reactor mvn clean install 绿;PlatformMigrationDdlGuardTest 2/2;独立 code-reviewer
评审 GO(零 CRITICAL/HIGH/MEDIUM,含 guard substring 逻辑对真实 V1 仿真核实)。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
67 lines
3.5 KiB
Bash
Executable File
67 lines
3.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# eip4-platform CI:编译 + 单测(含 ArchUnit)+ 对拍冒烟(决策会治理条款:移植代码门禁=对拍,新代码门禁=单测)
|
|
# 用法:scripts/ci.sh [--skip-parity]
|
|
# 环境变量:CI_PORT(默认 8090) CI_PG_HOST(默认 localhost) CI_PG_PORT(默认 5433) CI_DB(默认 eip4ci) CI_PG_USER(默认 zhengwr)
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")/.."
|
|
|
|
CI_PORT="${CI_PORT:-8090}"
|
|
CI_PG_HOST="${CI_PG_HOST:-localhost}"
|
|
CI_PG_PORT="${CI_PG_PORT:-5433}"
|
|
CI_DB="${CI_DB:-eip4ci}"
|
|
CI_PG_USER="${CI_PG_USER:-zhengwr}"
|
|
SKIP_PARITY="${1:-}"
|
|
|
|
echo "==[1/4] 编译 + 单测(全模块,含 ArchUnit 边界纪律)=="
|
|
mvn -q -T1C clean install
|
|
|
|
if [ "$SKIP_PARITY" = "--skip-parity" ]; then
|
|
echo "==[跳过对拍冒烟]=="; exit 0
|
|
fi
|
|
|
|
echo "==[2/4] 准备冒烟库 ${CI_DB}(重建 + 自举)=="
|
|
psql -h "$CI_PG_HOST" -p "$CI_PG_PORT" -U "$CI_PG_USER" -d postgres -q \
|
|
-c "DROP DATABASE IF EXISTS ${CI_DB}" -c "CREATE DATABASE ${CI_DB}"
|
|
psql -h "$CI_PG_HOST" -p "$CI_PG_PORT" -U "$CI_PG_USER" -d "$CI_DB" -q \
|
|
-f platform-parity/src/main/resources/bootstrap/bootstrap-sys.sql
|
|
psql -h "$CI_PG_HOST" -p "$CI_PG_PORT" -U "$CI_PG_USER" -d "$CI_DB" -q \
|
|
-f platform-parity/src/main/resources/bootstrap/bootstrap-privilege.sql
|
|
# 平台表 SYS_PAGE_SCHEMA:单一真相 db/migration/V1(A10 W1 收敛,散落 bootstrap 已删)。
|
|
# 注:app 启动时 Flyway 已会幂等建全部平台表(V1-V3);此处预灌仅保证起服务前表已在(幂等无害)。
|
|
psql -h "$CI_PG_HOST" -p "$CI_PG_PORT" -U "$CI_PG_USER" -d "$CI_DB" -q \
|
|
-f platform-app/src/main/resources/db/migration/V1__sys_page_schema.sql
|
|
|
|
JDBC="jdbc:postgresql://${CI_PG_HOST}:${CI_PG_PORT}/${CI_DB}"
|
|
echo "==[3/4] 起服务(:${CI_PORT} → ${JDBC})=="
|
|
# profile=ci:对拍冒烟依赖免令牌 permitAll + asUser/roles 旁路(见 SecurityProfiles)。
|
|
# P0 fail-safe 修复后默认严格链(无 profile=强制认证),故 CI 必须显式声明 ci profile,
|
|
# 否则健康检查 /api/entity/... 被拒 401、ParityCli 免令牌重放失效。
|
|
java -jar platform-app/target/platform-app-*.jar \
|
|
--spring.profiles.active=ci \
|
|
--server.port="$CI_PORT" \
|
|
--spring.datasource.url="$JDBC" \
|
|
--spring.datasource.username="$CI_PG_USER" \
|
|
--spring.datasource.password= \
|
|
--logging.level.com.dsasp=WARN > /tmp/eip4-ci-app.log 2>&1 &
|
|
APP_PID=$!
|
|
trap 'kill $APP_PID 2>/dev/null || true' EXIT
|
|
for i in $(seq 1 60); do
|
|
curl -s -m 2 "http://localhost:${CI_PORT}/api/entity/SYS_USERGROUP/list?page=1&perPage=1" >/dev/null 2>&1 && break
|
|
[ "$i" = 60 ] && { echo "服务启动超时"; tail -30 /tmp/eip4-ci-app.log; exit 1; }
|
|
sleep 2
|
|
done
|
|
|
|
echo "==[4/4] 对拍冒烟(种子 21 实体全量 + C2 权限样本)=="
|
|
CP="platform-parity/target/classes:$(mvn -q org.apache.maven.plugins:maven-dependency-plugin:build-classpath \
|
|
-pl platform-parity -Dmdep.outputFile=/dev/stdout -o | tail -1)"
|
|
java -cp "$CP" com.eip4.platform.parity.selfcheck.ParityCli \
|
|
--engine="http://localhost:${CI_PORT}" --jdbc="$JDBC" --user="$CI_PG_USER" --pass= --seed --all
|
|
# 权限规则按表名动态绑定实体 ID,必须在种子实体创建后重放(脚本幂等);
|
|
# 否则 INSERT...SELECT 在空 sys_entity 上静默插 0 条规则 → 负例不拒、正例 0 行
|
|
psql -h "$CI_PG_HOST" -p "$CI_PG_PORT" -U "$CI_PG_USER" -d "$CI_DB" -q \
|
|
-f platform-parity/src/main/resources/bootstrap/bootstrap-privilege.sql
|
|
java -cp "$CP" com.eip4.platform.parity.selfcheck.ParityCli \
|
|
--engine="http://localhost:${CI_PORT}" --jdbc="$JDBC" --user="$CI_PG_USER" --pass= --privilege
|
|
|
|
echo "== CI 全绿 =="
|