Skip to content

Feature/chords logic manual merge #18

Feature/chords logic manual merge

Feature/chords logic manual merge #18

Workflow file for this run

name: CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch: # Add this line to allow manual trigger
jobs:
black-sort-pytest:
name: Formatting, Sorting && Testing
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r backend/requirements.txt
pip install -r backend/requirements-dev.txt
- name: Check imports with isort
run: |
isort --check-only backend/src # Check imports without making changes
- name: Check formatting with Black
run: |
black --check backend/src # Check formatting without making changes
- name: Run tests with coverage
run: |
pytest --cov=backend/src --cov-report=xml backend/src
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
flags: unittests
- name: Run Codacy Analysis CLI
uses: codacy/codacy-analysis-cli-action@master
- name: Run codacy-coverage-reporter
uses: codacy/[email protected]
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./coverage.xml
build_and_push:
name: Docker Build and Push
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and push Docker images
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/songbook:latest -f backend/Dockerfile backend/
docker push ${{ secrets.DOCKER_USERNAME }}/songbook:latest
# - name: Build and push additional services (if any)
# run: |
# docker build -t ${{ secrets.DOCKER_USERNAME }}/songbook:latest -f services/Dockerfile .
# docker push ${{ secrets.DOCKER_USERNAME }}/songbook:latest
test:
name: Docker Test
needs: build_and_push
runs-on: ubuntu-latest
services:
docker:
image: docker:latest
options: --privileged
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Docker Compose
run: |
sudo apt-get update
sudo apt-get install docker-compose
- name: Run Docker Compose tests
run: |
docker-compose -f docker-compose.yaml up --build --detach
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
- name: Wait for FastAPI service to be ready
run: |
until curl -s http://localhost:8000/docs; do
echo "Waiting for FastAPI service..."
sleep 5
done
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r backend/requirements.txt
pip install -r backend/requirements-dev.txt
- name: Run tests
run: |
pytest tests/ --disable-warnings
- name: Stop Docker Compose services
run: |
docker-compose -f docker-compose.yaml down