|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + |
| 8 | +# A force-push or a rapid second push should not leave two runs racing; the older |
| 9 | +# one is cancelled rather than burning a runner on a commit nobody will merge. |
| 10 | +concurrency: |
| 11 | + group: ci-${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +# Read-only by default. Nothing here writes to the repository, and a fork-based |
| 15 | +# pull request must never hold a writable token. |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +jobs: |
| 20 | + # ── Required checks ──────────────────────────────────────────────────────── |
| 21 | + # Everything in this group passes on main today. Only checks that are green |
| 22 | + # from the first run belong here: a required check that always fails is |
| 23 | + # indistinguishable from a broken merge queue and teaches people to ignore CI. |
| 24 | + |
| 25 | + frontend: |
| 26 | + name: frontend (build) |
| 27 | + runs-on: ubuntu-latest |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + - uses: actions/setup-node@v4 |
| 31 | + with: |
| 32 | + node-version: '22' |
| 33 | + cache: npm |
| 34 | + - run: npm ci |
| 35 | + - run: npm run build |
| 36 | + |
| 37 | + backend: |
| 38 | + name: backend (compile + package) |
| 39 | + runs-on: ubuntu-latest |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 |
| 42 | + - uses: actions/setup-java@v4 |
| 43 | + with: |
| 44 | + distribution: temurin |
| 45 | + java-version: '25' |
| 46 | + cache: maven |
| 47 | + # No database service here on purpose: with tests skipped nothing opens a |
| 48 | + # connection, so this job stays fast and has exactly one failure mode — |
| 49 | + # the code does not compile, or does not package. |
| 50 | + - run: ./mvnw -B -ntp -DskipTests verify |
| 51 | + working-directory: backend |
| 52 | + |
| 53 | + mcp: |
| 54 | + name: mcp (syntax) |
| 55 | + runs-on: ubuntu-latest |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@v4 |
| 58 | + - uses: actions/setup-node@v4 |
| 59 | + with: |
| 60 | + node-version: '22' |
| 61 | + # Every JS file in the package, not just the entrypoint: the server is a |
| 62 | + # thin shim over lib and command modules, and a syntax error in any of them |
| 63 | + # surfaces only when an agent loads that path at runtime. |
| 64 | + - name: Syntax-check MCP sources |
| 65 | + run: find mcp -name '*.js' -not -path '*/node_modules/*' -print0 | xargs -0 -n1 node --check |
| 66 | + |
| 67 | + compose-build: |
| 68 | + name: docker compose build |
| 69 | + runs-on: ubuntu-latest |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v4 |
| 72 | + # Catches the case where the code compiles but the image does not. Our |
| 73 | + # distribution path is "clone and build", so an unbuildable image is a |
| 74 | + # total outage for a new user even when every test passes. |
| 75 | + - name: Synthesize .env |
| 76 | + run: | |
| 77 | + cp .env.example .env |
| 78 | + printf 'SECURITY_JWT_SECRET=%s\n' "$(openssl rand -base64 64 | tr -d '\n')" >> .env |
| 79 | + printf 'ENCRYPTION_KEY=%s\n' "$(openssl rand -base64 32)" >> .env |
| 80 | + - run: docker compose build |
| 81 | + |
| 82 | + # ── Advisory checks ──────────────────────────────────────────────────────── |
| 83 | + # These run on every pull request and report, but do not block. They are staged |
| 84 | + # this way because both are red on main right now (backend: 77 of 1293 tests |
| 85 | + # failing; frontend: 41 eslint errors). Promote each to a required check in |
| 86 | + # branch protection the day its suite goes green — that promotion is the point |
| 87 | + # of running them, not an afterthought. |
| 88 | + |
| 89 | + backend-tests: |
| 90 | + name: backend tests (advisory) |
| 91 | + runs-on: ubuntu-latest |
| 92 | + continue-on-error: true |
| 93 | + services: |
| 94 | + postgres: |
| 95 | + # pgvector, not stock postgres: rag_documents.embedding is vector(3072) |
| 96 | + # and the schema will not create against an image without the extension. |
| 97 | + image: pgvector/pgvector:pg18 |
| 98 | + env: |
| 99 | + POSTGRES_USER: postgres |
| 100 | + POSTGRES_PASSWORD: postgres |
| 101 | + POSTGRES_DB: dba_agent |
| 102 | + ports: |
| 103 | + - 5432:5432 |
| 104 | + options: >- |
| 105 | + --health-cmd "pg_isready -U postgres" |
| 106 | + --health-interval 10s |
| 107 | + --health-timeout 5s |
| 108 | + --health-retries 10 |
| 109 | + steps: |
| 110 | + - uses: actions/checkout@v4 |
| 111 | + - uses: actions/setup-java@v4 |
| 112 | + with: |
| 113 | + distribution: temurin |
| 114 | + java-version: '25' |
| 115 | + cache: maven |
| 116 | + # Generated per run and discarded with the runner, rather than written into |
| 117 | + # this file or held as a repository secret. Nothing in the test suite needs |
| 118 | + # a key that outlives the job, so nothing should own one. The id must be |
| 119 | + # local-2025-01: application-test.properties pins ENCRYPTION_KEY_ID to it. |
| 120 | + - name: Generate ephemeral encryption key |
| 121 | + run: echo "ENCRYPTION_KEYS=local-2025-01:$(openssl rand -base64 32)" >> "$GITHUB_ENV" |
| 122 | + - run: ./mvnw -B -ntp test |
| 123 | + working-directory: backend |
| 124 | + env: |
| 125 | + TEST_DB_URL: jdbc:postgresql://localhost:5432/dba_agent?sslmode=disable |
| 126 | + TEST_DB_USERNAME: postgres |
| 127 | + TEST_DB_PASSWORD: postgres |
| 128 | + AZURE_SEARCH_API_KEY: dummy-test-key |
| 129 | + - name: Publish test summary |
| 130 | + if: always() |
| 131 | + run: | |
| 132 | + echo '### Backend test results' >> "$GITHUB_STEP_SUMMARY" |
| 133 | + echo '```' >> "$GITHUB_STEP_SUMMARY" |
| 134 | + grep -ho 'Tests run:.*' backend/target/surefire-reports/*.txt 2>/dev/null \ |
| 135 | + | tail -5 >> "$GITHUB_STEP_SUMMARY" \ |
| 136 | + || echo 'no surefire reports produced' >> "$GITHUB_STEP_SUMMARY" |
| 137 | + echo '```' >> "$GITHUB_STEP_SUMMARY" |
| 138 | +
|
| 139 | + lint: |
| 140 | + name: frontend lint (advisory) |
| 141 | + runs-on: ubuntu-latest |
| 142 | + continue-on-error: true |
| 143 | + steps: |
| 144 | + - uses: actions/checkout@v4 |
| 145 | + - uses: actions/setup-node@v4 |
| 146 | + with: |
| 147 | + node-version: '22' |
| 148 | + cache: npm |
| 149 | + - run: npm ci |
| 150 | + - run: npm run lint |
0 commit comments