Skip to content

Commit 2f1d4c6

Browse files
committed
Publish CI images to GitHub Container Registry
1 parent 52686f6 commit 2f1d4c6

6 files changed

Lines changed: 81 additions & 4 deletions

File tree

.github/workflows/ci.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
quality:
14+
name: Lint and test
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 20
17+
steps:
18+
- name: Check out repository
19+
uses: actions/checkout@v5
20+
21+
- name: Set up Python 3.11
22+
uses: actions/setup-python@v6
23+
with:
24+
python-version: "3.11"
25+
cache: pip
26+
cache-dependency-path: pyproject.toml
27+
28+
- name: Install CI dependencies
29+
run: |
30+
python -m pip install --upgrade pip
31+
python -m pip install --editable ".[ci]"
32+
33+
- name: Run Ruff
34+
run: python -m ruff check src tests scripts spark airflow/dags --select E4,E7,E9,F
35+
36+
- name: Run tests
37+
run: python -m pytest -q
38+
39+
docker:
40+
name: Build Docker image
41+
needs: quality
42+
runs-on: ubuntu-latest
43+
timeout-minutes: 20
44+
permissions:
45+
contents: read
46+
packages: write
47+
steps:
48+
- name: Check out repository
49+
uses: actions/checkout@v5
50+
51+
- name: Set up Docker Buildx
52+
uses: docker/setup-buildx-action@v3
53+
54+
- name: Log in to GitHub Container Registry
55+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
56+
uses: docker/login-action@v4
57+
with:
58+
registry: ghcr.io
59+
username: ${{ github.actor }}
60+
password: ${{ secrets.GITHUB_TOKEN }}
61+
62+
- name: Build API image
63+
uses: docker/build-push-action@v6
64+
with:
65+
context: .
66+
file: ./Dockerfile
67+
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
68+
tags: |
69+
ghcr.io/ekrov/factoryvision-mlops:${{ github.sha }}
70+
ghcr.io/ekrov/factoryvision-mlops:latest
71+
cache-from: type=gha
72+
cache-to: type=gha,mode=max

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# FactoryVision
22

3+
[![CI](https://github.com/ekrov/factoryvision-mlops/actions/workflows/ci.yml/badge.svg)](https://github.com/ekrov/factoryvision-mlops/actions/workflows/ci.yml)
4+
35
## Production-Grade Surface Defect Segmentation & MLOps Platform
46

57
FactoryVision is an end-to-end industrial visual-inspection system for detecting and segmenting manufacturing surface defects. The project covers the complete machine-learning lifecycle:
@@ -204,7 +206,7 @@ clamp_min(
204206

205207
### CI/CD and deployment
206208

207-
- Add a GitHub Actions pipeline for linting, tests, and Docker builds.
209+
- The [GitHub Actions CI workflow](.github/workflows/ci.yml) runs on pushes to `main` and pull requests targeting `main`. It installs Python 3.11, runs Ruff and `pytest`, and builds the API Docker image after the quality checks pass. Successful pushes to `main` are authenticated with the built-in GitHub token and published to `ghcr.io/ekrov/factoryvision-mlops` with both the commit SHA and `latest` tags.
208210
- Push successful images to GitHub Container Registry.
209211
- Deploy the FastAPI container to Azure Container Apps or another simple Azure target.
210212
- Document secrets, environment variables, load-test results, and rollback procedures.

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ dev = [
3838
"jupyter==1.1.1",
3939
"pytest==9.0.3",
4040
]
41+
ci = [
42+
"pytest==9.0.3",
43+
"ruff==0.16.0",
44+
]
4145

4246
[tool.setuptools.packages.find]
4347
where = ["src"]

scripts/register_best_model.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from typing import Any
99

1010
import mlflow
11-
import numpy as np
1211
import torch
1312
from mlflow.models import infer_signature
1413
from mlflow.tracking import MlflowClient

src/factoryvision/training/train.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import cv2
1919
import pandas as pd
2020
import torch
21-
from torch import Tensor, nn
21+
from torch import nn
2222
from torch.optim import Adam
2323
from torch.utils.data import DataLoader, WeightedRandomSampler
2424

tests/test_storage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from sqlalchemy import create_engine
88

9-
from factoryvision.api.inference import InferenceConfig, Prediction
9+
from factoryvision.api.inference import Prediction
1010
from factoryvision.api.schemas import BoundingBox
1111
from factoryvision.storage.database import initialize_database
1212
from factoryvision.storage.repository import PredictionRepository, image_id_from_bytes

0 commit comments

Comments
 (0)