From 073e2a67f58221e5d6ca31e860f6a38e66aa1a12 Mon Sep 17 00:00:00 2001 From: zhengwr Date: Thu, 11 Jun 2026 12:04:58 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E4=B8=80=E9=94=AE=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BF=E8=84=9A=E6=9C=AC=20+=20GitHub=20Actions=20=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81(=E7=BC=96=E8=AF=91/=E5=8D=95=E6=B5=8B/ArchUn?= =?UTF-8?q?it/=E5=AF=B9=E6=8B=8D=E5=86=92=E7=83=9F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scripts/ci.sh:全模块 install → 重建冒烟库+自举 → 起服务 → 种子 21 实体全量对拍 + C2 权限样本; 端口/库名/账号环境变量化(本地默认 8090/eip4ci),--skip-parity 可只跑编译测试。 ci.yml:PG15 service 容器,步骤复用 ci.sh(换 Jenkins 同构迁移)。 完整本地实跑验证待并行代理收工后执行(避免并发 mvn 互踩) Co-Authored-By: Claude Fable 5 --- .github/workflows/ci.yml | 35 ++++++++++++++++++++++++++ scripts/ci.sh | 54 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100755 scripts/ci.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..91d8939 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +# eip4-platform CI:编译+单测+ArchUnit+对拍冒烟(公司自建 Git 服务可换 Jenkins,步骤同 scripts/ci.sh) +name: ci +on: + push: + branches: [main] + pull_request: + +jobs: + build-test-parity: + runs-on: ubuntu-latest + services: + postgres: + image: postgres:15 + env: + POSTGRES_USER: ci + POSTGRES_HOST_AUTH_METHOD: trust + ports: ["5433:5432"] + options: >- + --health-cmd "pg_isready -U ci" --health-interval 5s + --health-timeout 5s --health-retries 20 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: "17" + cache: maven + - name: 编译+单测+对拍冒烟 + env: + CI_PG_HOST: localhost + CI_PG_PORT: "5433" + CI_PG_USER: ci + CI_DB: eip4ci + CI_PORT: "8090" + run: bash scripts/ci.sh diff --git a/scripts/ci.sh b/scripts/ci.sh new file mode 100755 index 0000000..abcce82 --- /dev/null +++ b/scripts/ci.sh @@ -0,0 +1,54 @@ +#!/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 全绿 =="