| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- name: CI/CD
- on:
- push:
- branches: [ main, develop ]
- pull_request:
- branches: [ main ]
- jobs:
- test:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- python-version: ['3.11', '3.12']
- steps:
- - uses: actions/checkout@v4
- - name: Set up Python ${{ matrix.python-version }}
- uses: actions/setup-python@v5
- with:
- python-version: ${{ matrix.python-version }}
- - name: Cache dependencies
- uses: actions/cache@v4
- with:
- path: ~/.cache/pip
- key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}
- restore-keys: |
- ${{ runner.os }}-pip-
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install -r requirements.txt
- - name: Lint with ruff
- run: |
- ruff check src/ tests/
- - name: Format check with black
- run: |
- black --check src/ tests/
- - name: Type check with mypy
- run: |
- mypy src/ --ignore-missing-imports
- continue-on-error: true
- - name: Run tests with pytest
- run: |
- pytest tests/ -v --cov=src --cov-report=xml --cov-report=term
- - name: Upload coverage to Codecov
- uses: codecov/codecov-action@v4
- with:
- file: ./coverage.xml
- flags: unittests
- name: codecov-umbrella
- continue-on-error: true
- docker:
- runs-on: ubuntu-latest
- needs: test
- if: github.event_name == 'push' && github.ref == 'refs/heads/main'
- steps:
- - uses: actions/checkout@v4
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v3
- - name: Build Docker image
- run: |
- docker build -t cognio:latest .
- - name: Test Docker image
- run: |
- docker run --rm cognio:latest python -c "import src; print('Docker image OK')"
- - name: Log in to Docker Hub
- if: github.event_name == 'push'
- uses: docker/login-action@v3
- with:
- username: ${{ secrets.DOCKER_USERNAME }}
- password: ${{ secrets.DOCKER_PASSWORD }}
- continue-on-error: true
- - name: Push to Docker Hub
- if: github.event_name == 'push'
- run: |
- docker tag cognio:latest ${{ secrets.DOCKER_USERNAME }}/cognio:latest
- docker push ${{ secrets.DOCKER_USERNAME }}/cognio:latest
- continue-on-error: true
|