|
| 1 | +name: Python AI Vision Service for face recognition |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + - assisted-vision |
| 8 | + paths: |
| 9 | + - 'ai-vision-service/face-recognition/**' |
| 10 | + pull_request: |
| 11 | + paths: |
| 12 | + - 'ai-vision-service/face-recognition/**' |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +# Declare default permissions as read only. |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +concurrency: |
| 20 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 21 | + cancel-in-progress: ${{ !contains(github.ref, 'master') && !startsWith(github.ref, 'refs/tags/') }} |
| 22 | + |
| 23 | +defaults: |
| 24 | + run: |
| 25 | + working-directory: ai-vision-service/face-recognition |
| 26 | + |
| 27 | +jobs: |
| 28 | + # --------------------------------------------------------------------------- |
| 29 | + # Lint – formatting and style |
| 30 | + # --------------------------------------------------------------------------- |
| 31 | + lint: |
| 32 | + name: Lint (ruff) |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - name: Harden Runner |
| 36 | + uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 |
| 37 | + with: |
| 38 | + egress-policy: audit |
| 39 | + |
| 40 | + - name: Checkout code |
| 41 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 42 | + |
| 43 | + - name: Set up uv |
| 44 | + uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0 |
| 45 | + with: |
| 46 | + enable-cache: true |
| 47 | + |
| 48 | + - name: Install dev dependencies |
| 49 | + run: uv sync --frozen |
| 50 | + |
| 51 | + - name: Check formatting |
| 52 | + run: uv run ruff format --check app/ tests/ |
| 53 | + |
| 54 | + - name: Lint |
| 55 | + run: uv run ruff check app/ tests/ |
| 56 | + |
| 57 | + # --------------------------------------------------------------------------- |
| 58 | + # Type check |
| 59 | + # --------------------------------------------------------------------------- |
| 60 | + typecheck: |
| 61 | + name: Type check (ty) |
| 62 | + runs-on: ubuntu-latest |
| 63 | + steps: |
| 64 | + - name: Harden Runner |
| 65 | + uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 |
| 66 | + with: |
| 67 | + egress-policy: audit |
| 68 | + |
| 69 | + - name: Checkout code |
| 70 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 71 | + |
| 72 | + - name: Set up uv |
| 73 | + uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0 |
| 74 | + with: |
| 75 | + enable-cache: true |
| 76 | + |
| 77 | + - name: Install dev dependencies |
| 78 | + run: uv sync --frozen |
| 79 | + |
| 80 | + - name: Type check |
| 81 | + run: uv run ty check app/ |
| 82 | + |
| 83 | + # --------------------------------------------------------------------------- |
| 84 | + # Test matrix – Python 3.13 and 3.14 |
| 85 | + # --------------------------------------------------------------------------- |
| 86 | + test: |
| 87 | + name: Tests (Python ${{ matrix.python-version }}) |
| 88 | + runs-on: ubuntu-latest |
| 89 | + strategy: |
| 90 | + fail-fast: false |
| 91 | + matrix: |
| 92 | + python-version: |
| 93 | + - "3.13" |
| 94 | + - "3.14" |
| 95 | + |
| 96 | + steps: |
| 97 | + - name: Harden Runner |
| 98 | + uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 |
| 99 | + with: |
| 100 | + egress-policy: audit |
| 101 | + |
| 102 | + - name: Checkout code |
| 103 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 104 | + |
| 105 | + - name: Set up uv |
| 106 | + uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0 |
| 107 | + with: |
| 108 | + enable-cache: true |
| 109 | + python-version: ${{ matrix.python-version }} |
| 110 | + |
| 111 | + - name: Install dev dependencies |
| 112 | + run: uv sync --frozen |
| 113 | + |
| 114 | + - name: Run tests |
| 115 | + run: uv run pytest --cov=app --cov-report=xml -v |
| 116 | + |
| 117 | + - name: Upload coverage |
| 118 | + if: matrix.python-version == '3.13' |
| 119 | + uses: codecov/codecov-action@671740ac38dd9b0130fbe1cec585b89eea48d3de # v5.5.2 |
| 120 | + with: |
| 121 | + files: ai-vision-service/face-recognition/coverage.xml |
| 122 | + flags: ai-vision-service/face-recognition |
| 123 | + continue-on-error: true |
| 124 | + |
| 125 | + # --------------------------------------------------------------------------- |
| 126 | + # Docker build verification |
| 127 | + # --------------------------------------------------------------------------- |
| 128 | + docker-build: |
| 129 | + name: Docker build |
| 130 | + runs-on: ubuntu-latest |
| 131 | + steps: |
| 132 | + - name: Harden Runner |
| 133 | + uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 |
| 134 | + with: |
| 135 | + egress-policy: audit |
| 136 | + |
| 137 | + - name: Checkout code |
| 138 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 139 | + |
| 140 | + - name: Set up Docker Buildx |
| 141 | + uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd #v4.0.0 |
| 142 | + |
| 143 | + - name: Build Docker image (no model bake in CI to save time) |
| 144 | + uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0 |
| 145 | + with: |
| 146 | + context: ai-vision-service/face-recognition |
| 147 | + push: false |
| 148 | + load: true |
| 149 | + tags: lychee-ai-vision:ci |
| 150 | + # Override the model-bake step by targeting the builder stage |
| 151 | + # to avoid downloading 300MB of model weights in CI. |
| 152 | + target: builder |
| 153 | + cache-from: type=gha |
| 154 | + cache-to: type=gha,mode=max |
0 commit comments