-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (115 loc) · 3.92 KB
/
system.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
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