-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (83 loc) Β· 2.33 KB
/
Copy pathci.yml
File metadata and controls
101 lines (83 loc) Β· 2.33 KB
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
name: CI/CD Pipeline
on:
push:
branches: [ main, 'feature/*' ]
pull_request:
branches: [ main ]
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Cache dependencies
uses: actions/cache@v3
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: Run tests
env:
INITIAL_ADMIN_PASSWORD: testadmin123
SESSION_SECRET: ci-session-secret
run: |
python -m pytest tests/ -v --tb=short
build:
name: Build Docker Image
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: |
docker build -t credify:${{ github.sha }} .
- name: Test Docker image starts correctly
run: |
docker run -d -p 5000:5000 --name test-app \
-e DATABASE_URL=sqlite:////tmp/credify.db \
-e INITIAL_ADMIN_PASSWORD=testadmin123 \
-e SESSION_SECRET=ci-session-secret \
credify:${{ github.sha }}
for i in {1..30}; do
if curl -fsS http://localhost:5000/ > /dev/null; then
break
fi
sleep 2
done
curl -f http://localhost:5000/ || exit 1
docker stop test-app
docker rm test-app
lint:
name: Code Quality Check
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 linting tools
run: |
pip install flake8 black
- name: Run flake8
run: |
flake8 app/ core/ --count --select=E9,F63,F7,F82 --show-source --statistics
continue-on-error: true
- name: Check code formatting
run: |
black --check --target-version py310 app/ core/
continue-on-error: true