Files
QuantEngineByItz/tools/validate_gitea_secrets_contract_v1.py
T
kjh2064 e9512d5d4e
Validators (Pushes and Pull Requests) / UI & Storage Validation (push) Failing after 11s
Validators (Pushes and Pull Requests) / Core Validators & Database Setup (push) Failing after 14s
Validators (Pushes and Pull Requests) / WBS & Audit Validations (push) Has been skipped
Validators (Pushes and Pull Requests) / .NET Contracts (push) Has been skipped
Validators (Pushes and Pull Requests) / Calibration & Performance (push) Has been skipped
Validators (Pushes and Pull Requests) / Database & Schema Validation (push) Failing after 6s
Validators (Pushes and Pull Requests) / Operational Report & Decision Packet (push) Has been skipped
Validators (Pushes and Pull Requests) / Security & Secrets (push) Successful in 6s
Validators (Pushes and Pull Requests) / CI Workflow Lint (push) Failing after 7s
Validators (Pushes and Pull Requests) / Notify PR Results (push) Has been skipped
Workflow Lint & Validation / Validate Secrets Contract (push) Successful in 7s
Workflow Lint & Validation / Lint All Workflow Files (push) Failing after 11s
Workflow Lint & Validation / Notify Lint Results (push) Failing after 1s
fix(ci): create Temp directory if missing in secrets validation
When validate_gitea_secrets_contract_v1.py runs in CI environment,
Temp directory may not exist. Add directory creation before writing
output JSON.

This fixes: FileNotFoundError in Validate Security Configuration job

Phase 0 Week 1: CI Baseline (Attempt 4)

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2026-07-24 14:27:08 +09:00

73 lines
2.1 KiB
Python

#!/usr/bin/env python3
from __future__ import annotations
import json
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
REQUIRED_PATTERNS = {
".gitea/workflows/kis_data_collection.yml": [
"vars.KIS_APP_KEY_TEST",
"vars.KIS_APP_SECRET_TEST",
"vars.KIS_APP_KEY",
"vars.KIS_APP_SECRET",
],
".gitea/workflows/qualitative_sell_strategy.yml": [
"vars.KIS_APP_KEY_TEST",
"vars.KIS_APP_SECRET_TEST",
"vars.KIS_APP_KEY",
"vars.KIS_APP_SECRET",
],
".gitea/workflows/ci.yml": [
"vars.KIS_APP_KEY_TEST",
"vars.KIS_APP_SECRET_TEST",
],
"docs/GITEA_SECRETS_SETUP.md": [
"Temp/kis_tokens.db",
"TOKEN_REFRESH_SKEW_MINUTES=10",
"python tools/inspect_kis_token_cache_v1.py --json",
],
"docs/GATHERTRADINGDATA_XLSX_OPERATING_RUNBOOK.md": [
"Temp/kis_tokens.db",
"TOKEN_REFRESH_SKEW_MINUTES",
],
}
def main() -> int:
errors: list[str] = []
evidence: dict[str, dict[str, bool]] = {}
for rel, patterns in REQUIRED_PATTERNS.items():
path = ROOT / rel
text = path.read_text(encoding="utf-8") if path.exists() else ""
file_evidence: dict[str, bool] = {}
if not path.exists():
errors.append(f"missing:{rel}")
evidence[rel] = file_evidence
continue
for pattern in patterns:
found = pattern in text
file_evidence[pattern] = found
if not found:
errors.append(f"{rel}:{pattern}")
evidence[rel] = file_evidence
result = {
"formula_id": "GITEA_SECRETS_CONTRACT_V1",
"gate": "PASS" if not errors else "FAIL",
"evidence": evidence,
"errors": errors,
}
out = ROOT / "Temp" / "gitea_secrets_contract_v1.json"
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(json.dumps(result, ensure_ascii=False, indent=2), encoding="utf-8")
print(json.dumps(result, ensure_ascii=False, indent=2))
return 0 if not errors else 1
if __name__ == "__main__":
raise SystemExit(main())