ci.yml 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. name: CI
  2. on:
  3. push:
  4. branches: [main]
  5. pull_request:
  6. branches: [main]
  7. jobs:
  8. # ──────────────────────────────────────────────
  9. # Secret leak scan — first line of defense
  10. # 在跑任何其他东西之前先扫秘钥,省 CI 分钟
  11. # ──────────────────────────────────────────────
  12. secret-scan:
  13. runs-on: ubuntu-latest
  14. steps:
  15. - uses: actions/checkout@v4
  16. with:
  17. fetch-depth: 0 # gitleaks 需要完整历史
  18. - name: Run gitleaks
  19. uses: gitleaks/gitleaks-action@v2
  20. env:
  21. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  22. # GITLEAKS_LICENSE only needed for org-level; OSS repo runs free
  23. GITLEAKS_CONFIG: .github/gitleaks.toml
  24. # ──────────────────────────────────────────────
  25. # Python tests on 3.10/3.11/3.12
  26. # ──────────────────────────────────────────────
  27. test:
  28. runs-on: ubuntu-latest
  29. needs: secret-scan
  30. strategy:
  31. fail-fast: false
  32. matrix:
  33. python-version: ["3.10", "3.11", "3.12"]
  34. steps:
  35. - uses: actions/checkout@v4
  36. - name: Set up Python
  37. uses: actions/setup-python@v5
  38. with:
  39. python-version: ${{ matrix.python-version }}
  40. cache: pip
  41. - name: Install lambdagent (src-layout) + agentpaas[dev]
  42. run: |
  43. pip install -e lambdagent/
  44. # [dev] pulls in httpx — required by fastapi.testclient.TestClient
  45. # used by tests/test_api_endpoints.py (audit critical #6 coverage).
  46. pip install -e "agentpaas/[dev]"
  47. pip install pytest pytest-asyncio
  48. - name: Run tests
  49. run: python -m pytest tests/ -v --tb=short
  50. - name: Lint module loads
  51. run: python -c "from lambdagent.fromconfig import lint_config; print('Lint module OK')"
  52. # ──────────────────────────────────────────────
  53. # Package import smoke test
  54. # ──────────────────────────────────────────────
  55. imports:
  56. runs-on: ubuntu-latest
  57. needs: secret-scan
  58. steps:
  59. - uses: actions/checkout@v4
  60. - uses: actions/setup-python@v5
  61. with:
  62. python-version: "3.12"
  63. cache: pip
  64. - name: Install both packages
  65. run: |
  66. pip install -e lambdagent/
  67. pip install -e agentpaas/ # agentpaas needs fastapi/uvicorn/pydantic
  68. - name: Verify package surface
  69. run: |
  70. python -c "import lambdagent; print(f'lambdagent OK: {len(lambdagent.__all__)} exports')"
  71. python -c "from agentpaas.api.app import app; print(f'AgentPaaS OK: {len([r for r in app.routes if hasattr(r, \"methods\")])} routes')"
  72. # ──────────────────────────────────────────────
  73. # Web UI build (catch broken frontend before merge)
  74. # ──────────────────────────────────────────────
  75. webui:
  76. runs-on: ubuntu-latest
  77. needs: secret-scan
  78. defaults:
  79. run:
  80. working-directory: webui
  81. steps:
  82. - uses: actions/checkout@v4
  83. - uses: actions/setup-node@v4
  84. with:
  85. node-version: "20"
  86. cache: npm
  87. cache-dependency-path: webui/package-lock.json
  88. - run: npm ci
  89. - run: npm run build