name: CI

on:
  push:
    branches: [main]
  pull_request:
  workflow_dispatch:

concurrency:
  group: ci-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

permissions:
  contents: read

jobs:
  validate:
    name: Compose / Helm validate
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - uses: actions/checkout@v4

      - name: Validate Compose files
        run: |
          docker compose -f docker-compose.yml config --quiet
          docker compose -f docker-compose.release.yml config --quiet

      - uses: azure/setup-helm@v4
        with:
          version: v3.16.4

      - name: Lint and render Helm chart
        run: |
          make helm-lint
          make helm-template >/dev/null

  quality:
    name: make ci
    runs-on: ubuntu-latest
    timeout-minutes: 90
    steps:
      - uses: actions/checkout@v4

      - name: Prepare lab env
        run: test -f .env || cp .env.example .env

      - name: Build runtime and development images
        run: make install

      - name: Ruff + mypy + offline pytest + API surface probe
        run: make ci

      - name: Upload coverage XML
        if: always()
        uses: actions/upload-artifact@v4
        with:
          name: coverage-xml
          path: coverage.xml
          if-no-files-found: ignore
