|
| 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 |
0 commit comments