Files
eip4-platform/scripts/ci.sh
zhengwr 073e2a67f5 ci: 一键流水线脚本 + GitHub Actions 工作流(编译/单测/ArchUnit/对拍冒烟)
scripts/ci.sh:全模块 install → 重建冒烟库+自举 → 起服务 → 种子 21 实体全量对拍 + C2 权限样本;
端口/库名/账号环境变量化(本地默认 8090/eip4ci),--skip-parity 可只跑编译测试。
ci.yml:PG15 service 容器,步骤复用 ci.sh(换 Jenkins 同构迁移)。
完整本地实跑验证待并行代理收工后执行(避免并发 mvn 互踩)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-11 12:04:58 +08:00

55 lines
2.4 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
JDBC="jdbc:postgresql://${CI_PG_HOST}:${CI_PG_PORT}/${CI_DB}"
echo "==[3/4] 起服务(:${CI_PORT} → ${JDBC})=="
java -jar platform-app/target/platform-app-*.jar \
--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
java -cp "$CP" com.eip4.platform.parity.selfcheck.ParityCli \
--engine="http://localhost:${CI_PORT}" --jdbc="$JDBC" --user="$CI_PG_USER" --pass= --privilege
echo "== CI 全绿 =="