347 lines
16 KiB
YAML
347 lines
16 KiB
YAML
name: Validators (Pushes and Pull Requests)
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [ main ]
|
|
push:
|
|
branches: [ main ]
|
|
workflow_dispatch:
|
|
|
|
# Validator pipeline. Independent validation jobs run in parallel.
|
|
|
|
concurrency:
|
|
group: quantengine-ci-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
validate-core:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
QE_WBS_PG_DSN: "host=postgres port=5432 dbname=quantenginedb user=quantengine_ci password=quantengine_ci options='-c search_path=quantengine'"
|
|
PGPASSWORD: quantengine_ci
|
|
PGHOST: postgres
|
|
PGPORT: 5432
|
|
PYTHONPATH: "$HOME/python_deps/core:."
|
|
services:
|
|
postgres:
|
|
image: postgres:16
|
|
env:
|
|
POSTGRES_USER: quantengine_ci
|
|
POSTGRES_PASSWORD: quantengine_ci
|
|
POSTGRES_DB: quantenginedb
|
|
options: >-
|
|
--health-cmd pg_isready
|
|
--health-interval 5s
|
|
--health-timeout 5s
|
|
--health-retries 10
|
|
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Configure Runtime Paths
|
|
run: |
|
|
# Node.js 18: /usr/local/bin (appstore symlink)
|
|
export PATH=/usr/local/bin:$PATH
|
|
echo "/usr/local/bin" >> $GITHUB_PATH
|
|
echo "=== 런타임 확인 ==="
|
|
/usr/bin/python3 --version
|
|
node --version
|
|
npm --version
|
|
|
|
- name: Setup Python Environment
|
|
run: |
|
|
# 순수 Python 패키지만 설치 (numpy/pandas 제외 — ARMv7l 휠 없음)
|
|
PYTHON_DEPS="$HOME/python_deps/core"
|
|
mkdir -p "$PYTHON_DEPS"
|
|
/usr/bin/python3 --version
|
|
/usr/bin/python3 -m pip --version
|
|
/usr/bin/python3 -m pip install --disable-pip-version-check --quiet \
|
|
--target "$PYTHON_DEPS" requests pyyaml openpyxl pytest "psycopg[binary]"
|
|
/usr/bin/python3 -c 'import requests, yaml, openpyxl, pytest, psycopg; print("Python dependencies: PASS")'
|
|
|
|
- name: Apply Database Migrations (CI Postgres service)
|
|
env:
|
|
PGPASSWORD: quantengine_ci
|
|
PGHOST: postgres
|
|
PGPORT: 5432
|
|
run: |
|
|
# QE-M2-01 등 스키마 존재만 확인하는 게이트는 실제 Postgres에 대해 재검증한다
|
|
# (2026-07-12: WBS 게이트가 마이그레이션 SQL만으로 스키마를 주장하지 않도록,
|
|
# ci.yml 전용 postgres 서비스 컨테이너에 실제 DbUp 마이그레이션을 순서대로 적용).
|
|
which psql || (sudo apt-get update -qq && sudo apt-get install -y -qq postgresql-client)
|
|
for f in $(ls src/dotnet/QuantEngine.Infrastructure/Migrations/V*.sql | sort -V); do
|
|
echo "=== Applying $f ==="
|
|
psql -U quantengine_ci -d quantenginedb -v ON_ERROR_STOP=1 -f "$f"
|
|
done
|
|
echo "QE_WBS_PG_DSN=host=postgres port=5432 dbname=quantenginedb user=quantengine_ci password=quantengine_ci options='-c search_path=quantengine'" >> "$GITHUB_ENV"
|
|
|
|
- name: Setup .NET SDK
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: 10.0.x
|
|
|
|
- name: "[CRITICAL] Run .NET Unit Tests (Warnings as Errors)"
|
|
run: dotnet test src/dotnet/QuantEngine.Core.Tests/QuantEngine.Core.Tests.csproj -c Release --nologo -p:TreatWarningsAsErrors=true
|
|
|
|
- name: Install Node Dependencies
|
|
run: |
|
|
# package-lock.json 해시로 캐시 유효성 판단
|
|
CACHE_BASE="$HOME/gitea_node_cache"
|
|
LOCK_HASH=$(md5sum package-lock.json 2>/dev/null | cut -d' ' -f1 || echo "no-lock")
|
|
[ -z "$LOCK_HASH" ] && LOCK_HASH="no-lock"
|
|
CACHE_DIR="$CACHE_BASE/$LOCK_HASH"
|
|
|
|
if [ -d "$CACHE_DIR/node_modules" ]; then
|
|
echo "=== node_modules 캐시 히트: $LOCK_HASH ==="
|
|
# 이미 같은 캐시를 가리키고 있으면 재연결하지 않음
|
|
if [ -L node_modules ] && [ "$(readlink node_modules)" = "$CACHE_DIR/node_modules" ]; then
|
|
echo "=== node_modules already linked to cache ==="
|
|
else
|
|
if [ -e node_modules ] || [ -L node_modules ]; then
|
|
rm -rf node_modules
|
|
fi
|
|
ln -s "$CACHE_DIR/node_modules" node_modules
|
|
fi
|
|
else
|
|
echo "=== npm install (최초 or lock 변경) ==="
|
|
npm ci --quiet
|
|
# 캐시 저장
|
|
mkdir -p "$CACHE_DIR"
|
|
cp -r node_modules "$CACHE_DIR/node_modules"
|
|
echo "캐시 저장 완료: $CACHE_DIR"
|
|
# 오래된 캐시 정리 (최근 3개만 유지)
|
|
ls -dt "$CACHE_BASE"/*/ 2>/dev/null | tail -n +4 | xargs rm -rf 2>/dev/null || true
|
|
fi
|
|
node --version && npm --version
|
|
|
|
- name: "[CRITICAL] No Direct API Trading Gate"
|
|
run: python3 tools/validate_no_direct_api_trading_v1.py
|
|
|
|
- name: "[CRITICAL] Validate KIS API Credentials (mock)"
|
|
env:
|
|
KIS_APP_Key_TEST: ${{ vars.KIS_APP_KEY_TEST }}
|
|
KIS_APP_Secret_TEST: ${{ vars.KIS_APP_SECRET_TEST }}
|
|
run: python3 tools/validate_kis_api_credentials_v1.py --account mock --ticker 005930 --dry-run
|
|
|
|
- name: Validate Specs
|
|
run: python3 tools/validate_specs.py
|
|
|
|
- name: Validate Formula Registry
|
|
run: python3 tools/validate_formula_registry.py
|
|
|
|
- name: Validate Golden Case Coverage
|
|
run: python3 tools/validate_golden_coverage_100.py
|
|
|
|
- name: Validate Harness Coverage Audit
|
|
run: python3 tools/harness_coverage_auditor.py
|
|
|
|
- name: Validate Platform Transition WBS
|
|
run: python3 tools/validate_platform_transition_wbs_v1.py
|
|
|
|
- name: Validate Market Time Series Schema
|
|
run: python3 tools/validate_market_time_series_schema_v1.py
|
|
|
|
- name: Generate DONE WBS Verdicts
|
|
run: |
|
|
# DONE 작업 중 CI(ubuntu-latest, 위 postgres 서비스 컨테이너)에서 온디맨드로 재검증
|
|
# 가능한 것만 나열한다. 실제 KIS API/라이브 앱이 전제인 나머지 DONE 작업은
|
|
# spec/60의 execution.mode: not_ci_reproducible 로 별도 표시되어
|
|
# validate_quant_engine_wbs_v1.py 가 verdict 부재를 FAIL로 취급하지 않는다.
|
|
python3 - <<'PY'
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
import yaml
|
|
|
|
root = Path.cwd()
|
|
spec = yaml.safe_load((root / "spec" / "60_quant_engine_wbs.yaml").read_text(encoding="utf-8"))
|
|
tasks = spec.get("tasks") or {}
|
|
for task_id, task in tasks.items():
|
|
if task.get("status") != "DONE":
|
|
continue
|
|
mode = ((task.get("execution") or {}).get("mode"))
|
|
if mode in {"not_ci_reproducible", "manual_user_action"}:
|
|
continue
|
|
result = subprocess.run(["python3", "tools/verify_wbs_task_v1.py", "--task", task_id], cwd=root)
|
|
if result.returncode != 0:
|
|
print(f"WARNING: verdict generation skipped for {task_id} (exit={result.returncode})")
|
|
PY
|
|
|
|
- name: Validate Quant Engine WBS
|
|
run: python3 tools/validate_quant_engine_wbs_v1.py
|
|
|
|
- name: Validate Dotnet Migration Roadmap
|
|
run: python3 tools/validate_dotnet_migration_roadmap_v1.py
|
|
|
|
- name: Validate Dotnet Migration Execution Plan
|
|
run: python3 tools/validate_dotnet_migration_execution_plan_v1.py
|
|
|
|
- name: Validate Dotnet Parity Contract
|
|
run: python3 tools/validate_dotnet_parity_contract_v1.py
|
|
|
|
- name: Validate Dotnet Provenance Contract
|
|
run: python3 tools/validate_dotnet_provenance_contract_v1.py
|
|
|
|
- name: Validate Dotnet Scheduler Contract
|
|
run: python3 tools/validate_dotnet_scheduler_contract_v1.py
|
|
|
|
- name: Validate Dotnet Normalization Contract
|
|
run: python3 tools/validate_dotnet_normalization_contract_v1.py
|
|
|
|
- name: Validate Dotnet Idempotency Contract
|
|
run: python3 tools/validate_dotnet_idempotency_contract_v1.py
|
|
|
|
- name: Validate Dotnet CICD Chain Contract
|
|
run: python3 tools/validate_dotnet_cicd_chain_contract_v1.py
|
|
|
|
- name: Validate Dotnet Domain Parity Backlog
|
|
run: python3 tools/validate_dotnet_domain_parity_backlog_v1.py
|
|
|
|
- name: Validate Dotnet Read Model Contract
|
|
run: python3 tools/validate_dotnet_read_model_contract_v1.py
|
|
|
|
- name: Validate Dotnet Domain Parity Artifact
|
|
run: python3 tools/validate_dotnet_domain_parity_artifact_v1.py
|
|
|
|
|
|
|
|
- name: Build Calibration Priority Backlog
|
|
run: python3 tools/build_calibration_priority_v1.py
|
|
|
|
- name: Build Calibration Change Ledger
|
|
run: python3 tools/build_calibration_change_ledger_v4.py
|
|
|
|
- name: Validate Calibration Change Ledger
|
|
run: python3 tools/validate_calibration_change_ledger_v1.py
|
|
|
|
- name: Validate Qualitative Sell Strategy Pipeline
|
|
run: python3 tools/validate_qualitative_sell_strategy_pipeline_v1.py
|
|
|
|
- name: Validate Gitea Secrets Contract
|
|
run: python3 tools/validate_gitea_secrets_contract_v1.py
|
|
|
|
- name: Validate Snapshot Admin Workflow
|
|
run: python3 tools/validate_snapshot_admin_workflow_v1.py
|
|
|
|
- name: Validate DB First Pipeline
|
|
run: python3 tools/validate_db_first_pipeline_v1.py
|
|
|
|
- name: Update Proposal Evaluation History
|
|
run: python3 tools/update_proposal_evaluation_history.py --json GatherTradingData.json --history Temp/proposal_evaluation_history.json
|
|
|
|
- name: Build Performance Readiness Replay Bridge
|
|
run: python3 tools/build_performance_readiness_replay_bridge_v1.py --hist Temp/proposal_evaluation_history.json --out Temp/performance_readiness_replay_bridge_v1.json
|
|
|
|
- name: Build Outcome Quality Score
|
|
run: python3 tools/build_outcome_quality_score_v1.py --json GatherTradingData.json --out Temp/outcome_quality_score_v1.json --policy spec/strategy_execution_lock_policy.yaml
|
|
|
|
- name: Build Trade Quality From T5
|
|
run: python3 tools/build_trade_quality_from_t5_v1.py --hist Temp/proposal_evaluation_history.json --out Temp/trade_quality_from_t5_v1.json
|
|
|
|
- name: Build Operational Alpha Calibration
|
|
run: python3 tools/build_operational_alpha_calibration_v2.py --out Temp/operational_alpha_calibration_v2.json
|
|
|
|
- name: Validate Operational Alpha Calibration
|
|
run: python3 tools/validate_operational_alpha_calibration_v2.py --input Temp/operational_alpha_calibration_v2.json --out Temp/validate_operational_alpha_calibration_v2.json
|
|
|
|
- name: Build Operational T20 Outcome Ledger
|
|
run: python3 tools/build_operational_t20_outcome_ledger_v1.py --json GatherTradingData.json --out Temp/operational_t20_outcome_ledger_v1.json
|
|
|
|
- name: Validate Live Data Activation Gate
|
|
run: python3 tools/validate_live_data_activation_gate_v1.py
|
|
|
|
- name: Ensure Temp Directory and Mock Packet
|
|
run: |
|
|
mkdir -p Temp
|
|
python3 -c 'import json; json.dump({"order_blueprint_json":{},"cash_recovery_plan_json":{},"per_ticker":[{"ticker":"DATA_MISSING","gate":"DATA_MISSING"}],"meta":{"formulas_run":[],"source_file":"GatherTradingData.json"}},open("Temp/computed_harness_v1.json","w"),ensure_ascii=False,indent=2)'
|
|
if [ ! -f Temp/final_decision_packet_active.json ]; then
|
|
python3 -c 'import json; json.dump({"formula_id":"FINAL_DECISION_PACKET_V2","meta":{"generated_at":"2026-06-29T00:00:00Z"},"canonical_metrics":{"total_asset_krw":None},"portfolio_snapshot":{},"order_table":[],"pass_100":{"gate":"DATA_MISSING","score_0_100":None},"execution_readiness":{"gate":"DATA_MISSING","min_axis_score":None},"prediction":{"match_rate_pct":None}},open("Temp/final_decision_packet_active.json","w"),ensure_ascii=False,indent=2)'
|
|
fi
|
|
|
|
- name: Validate Replay Live Separation
|
|
run: python3 tools/validate_replay_live_separation_v1.py
|
|
|
|
- name: Render Final Decision Packet V4
|
|
run: dotnet run --project src/dotnet/QuantEngine.Tools/QuantEngine.Tools.csproj -p:TreatWarningsAsErrors=true -- packet-v4 --packet=Temp/final_decision_packet_active.json --out=Temp/final_decision_packet_v4.json
|
|
|
|
- name: Render Operational Report
|
|
run: dotnet run --project src/dotnet/QuantEngine.Tools/QuantEngine.Tools.csproj -p:TreatWarningsAsErrors=true -- report --packet=Temp/final_decision_packet_active.json --out=Temp/operational_report.json
|
|
|
|
- name: Validate Report Packet Sync
|
|
run: python3 tools/validate_report_packet_sync_v1.py --packet Temp/final_decision_packet_active.json --report Temp/operational_report.json | tee Temp/validate_report_packet_sync_v1.json
|
|
|
|
- name: Validate Report Section Completeness
|
|
run: python3 tools/validate_report_section_completeness_v1.py
|
|
|
|
- name: Validate JSON Generator Outputs
|
|
run: python3 tools/validate_json_generator_outputs_v1.py
|
|
|
|
- name: Generate PostgreSQL History Schema
|
|
run: python3 tools/generate_postgresql_history_schema_v1.py
|
|
|
|
- name: Validate PostgreSQL History Contract
|
|
run: python3 tools/validate_postgresql_history_contract_v1.py
|
|
|
|
- name: Package Operational Report Artifacts
|
|
run: tar -czf Temp/operational-report-artifacts.tar.gz Temp/operational_report.json Temp/missing_data_inventory_v1.json Temp/report_section_completeness.json Temp/operational_alpha_calibration_v2.json Temp/validate_operational_alpha_calibration_v2.json Temp/operational_t20_outcome_ledger_v1.json Temp/live_data_activation_gate_v1.json Temp/replay_live_separation_v1.json Temp/validate_report_packet_sync_v1.json Temp/json_generator_outputs_v1.json Temp/proposal_evaluation_history.json Temp/performance_readiness_replay_bridge_v1.json Temp/postgresql_history_schema_v1.sql Temp/postgresql_history_schema_v1.json Temp/postgresql_history_contract_v1.json
|
|
|
|
- name: Upload Operational Report Artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: operational-report-artifacts
|
|
path: Temp/operational-report-artifacts.tar.gz
|
|
|
|
- name: Upload Operational Report JSON
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: operational-report-json
|
|
path: Temp/operational_report.json
|
|
|
|
validate-ui-and-storage:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
PYTHONPATH: "$HOME/python_deps/ui:."
|
|
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Python Environment
|
|
run: |
|
|
PYTHON_DEPS="$HOME/python_deps/ui"
|
|
mkdir -p "$PYTHON_DEPS"
|
|
/usr/bin/python3 --version
|
|
/usr/bin/python3 -m pip --version
|
|
/usr/bin/python3 -m pip install --disable-pip-version-check --quiet \
|
|
--target "$PYTHON_DEPS" requests pyyaml openpyxl pytest
|
|
/usr/bin/python3 -c 'import requests, yaml, openpyxl, pytest; print("Python dependencies: PASS")'
|
|
|
|
- name: Validate Snapshot Admin Web UI
|
|
run: python3 tools/validate_snapshot_admin_web_v1.py
|
|
|
|
- name: Validate Storage Backend Contracts
|
|
run: python3 -m pytest tests/unit/test_storage_backend_v1.py tests/unit/test_validate_kis_api_credentials_v1.py tests/unit/test_qualitative_sell_strategy_store_v1.py tests/unit/test_kis_api_client_v1.py tests/unit/test_snapshot_admin_store_v1.py tests/unit/test_snapshot_admin_web_v1.py -q
|
|
|
|
- name: Notify PR Result
|
|
if: always() && github.event_name == 'pull_request'
|
|
env:
|
|
STAGE_RESULT: ${{ job.status }}
|
|
run: |
|
|
STATUS="$STAGE_RESULT"
|
|
PR_NUM="${{ github.event.pull_request.number }}"
|
|
RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
|
|
if [ "$STATUS" = "success" ]; then
|
|
MSG="✅ **CI PASS** — spec/registry/coverage gate OK\n\n[워크플로우 로그](${RUN_URL})"
|
|
else
|
|
MSG="❌ **CI FAIL** — 로그 확인 필요\n\n[워크플로우 로그](${RUN_URL})"
|
|
fi
|
|
curl -s -X POST "${{ github.api_url }}/repos/${{ github.repository }}/issues/${PR_NUM}/comments" \
|
|
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"body\":\"${MSG}\"}"
|