architecture recovery and sync cost controls #166
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build: | |
| name: Build and analyze | |
| runs-on: mayflower-k8s-runners | |
| services: | |
| postgres: | |
| image: ghcr.io/mayflower/pg4ai:latest | |
| env: | |
| POSTGRES_USER: contextmine | |
| POSTGRES_PASSWORD: contextmine | |
| POSTGRES_DB: contextmine | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
| # Python setup and coverage | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Install dependencies | |
| run: uv sync --all-packages | |
| - name: Run migrations | |
| working-directory: packages/core | |
| env: | |
| DATABASE_URL: postgresql+asyncpg://contextmine:contextmine@localhost:5432/contextmine | |
| run: uv run alembic upgrade head | |
| - name: Run Python tests with coverage | |
| env: | |
| DATABASE_URL: postgresql+asyncpg://contextmine:contextmine@localhost:5432/contextmine | |
| DEBUG: "true" | |
| run: | | |
| uv run pytest --cov=apps --cov=packages --cov-report=xml:coverage.xml --cov-report=term -v || true | |
| continue-on-error: true | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Run frontend tests with coverage | |
| working-directory: apps/web | |
| run: | | |
| npm ci | |
| npx vitest run --coverage || true | |
| continue-on-error: true | |
| # Optional ContextMine coverage ingest (CI push model). | |
| # Requires repository secrets: | |
| # - CONTEXTMINE_URL (e.g., https://contextmine.example.com) | |
| # - CONTEXTMINE_SOURCE_ID | |
| # - CONTEXTMINE_INGEST_TOKEN | |
| - name: Push coverage to ContextMine | |
| if: ${{ always() && github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
| env: | |
| CONTEXTMINE_URL: ${{ secrets.CONTEXTMINE_URL }} | |
| CONTEXTMINE_SOURCE_ID: ${{ secrets.CONTEXTMINE_SOURCE_ID }} | |
| CONTEXTMINE_INGEST_TOKEN: ${{ secrets.CONTEXTMINE_INGEST_TOKEN }} | |
| run: | | |
| set -euo pipefail | |
| if [ -z "${CONTEXTMINE_URL}" ] || [ -z "${CONTEXTMINE_SOURCE_ID}" ] || [ -z "${CONTEXTMINE_INGEST_TOKEN}" ]; then | |
| echo "ContextMine ingest secrets not set. Skipping ingest." | |
| exit 0 | |
| fi | |
| if [ ! -f coverage.xml ]; then | |
| echo "coverage.xml not found. Skipping ContextMine ingest." | |
| exit 0 | |
| fi | |
| response=$(curl --silent --show-error --fail-with-body \ | |
| -X POST "${CONTEXTMINE_URL}/api/sources/${CONTEXTMINE_SOURCE_ID}/metrics/coverage-ingest" \ | |
| -H "X-ContextMine-Ingest-Token: ${CONTEXTMINE_INGEST_TOKEN}" \ | |
| -F "commit_sha=${{ github.sha }}" \ | |
| -F "branch=${{ github.ref_name }}" \ | |
| -F "workflow_run_id=${{ github.run_id }}" \ | |
| -F "provider=github_actions" \ | |
| -F "reports=@coverage.xml") | |
| echo "ContextMine ingest response: ${response}" | |
| continue-on-error: true | |
| # SonarQube scan | |
| - uses: SonarSource/sonarqube-scan-action@v6 | |
| env: | |
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
| SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} | |
| # Uncomment to fail on Quality Gate red | |
| # - uses: SonarSource/sonarqube-quality-gate-action@v1 | |
| # timeout-minutes: 5 | |
| # env: | |
| # SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |