Skip to content

Lab03: Varfolomeeva Anastasia #4

Lab03: Varfolomeeva Anastasia

Lab03: Varfolomeeva Anastasia #4

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main, master ]
paths:
- 'app_python/**'
pull_request:
branches: [ main, master ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'
cache-dependency-path: 'app_python/requirements.txt'
- name: Install dependencies
working-directory: ./app_python
run: |
pip install -r requirements.txt
pip install pytest pytest-cov httpx
- name: Test with pytest
working-directory: ./app_python
run: |
python -m pytest tests/ -v --cov=app --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./app_python/coverage.xml
build:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/lab03'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./app_python
push: true
tags: |
${{ secrets.DOCKERHUB_USERNAME }}/devops-info-service:latest
${{ secrets.DOCKERHUB_USERNAME }}/devops-info-service:${{ github.sha }}