-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (59 loc) · 1.81 KB
/
ci.yml
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
name: Backend and Frontend CI
on:
push:
branches:
- develop
- main
pull_request:
branches:
- develop
- main
jobs:
build-and-test:
runs-on: ubuntu-latest
env:
SECRET_KEY: ${{ secrets.SECRET_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v3
# Backend steps (Python)
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Install backend dependencies
working-directory: src/backend/app
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Check backend server
working-directory: src/backend/app
run: |
# Inicia o servidor em segundo plano
nohup python app.py &
SERVER_PID=$!
# Aguarda 5 segundos para o servidor subir
sleep 5
# Obtém o código de status da rota /@me
status_code=$(curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:5000/@me)
echo "Status code: $status_code"
# Aceita 401 como resposta válida (pois indica que o servidor está funcionando sem usuário logado)
if [ "$status_code" -ne 401 ]; then
kill $SERVER_PID
exit 1
fi
kill $SERVER_PID
# Frontend steps (React)
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.11.0'
cache: 'npm'
cache-dependency-path: src/frontend/package-lock.json
- name: Install frontend dependencies
working-directory: src/frontend
run: npm install
- name: Build Frontend
working-directory: src/frontend
run: npm run build