-
-
Notifications
You must be signed in to change notification settings - Fork 8
201 lines (193 loc) · 6.7 KB
/
ci-backend.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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
name: 'Backend CI/CD 🚀'
on:
workflow_dispatch:
push:
branches:
- 'feature/**'
- 'fix/**'
pull_request:
branches:
- 'feature/**'
- 'fix/**'
jobs:
build:
name: 'Build 🏗'
strategy:
matrix:
os:
- ubuntu-latest
python-version:
- "3.11"
defaults:
run:
working-directory: backend/
runs-on: ${{ matrix.os }}
steps:
- name: Check repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
code-quality:
name: 'Code-Quality 💎'
needs: build
strategy:
matrix:
os:
- ubuntu-latest
python-version:
- "3.11"
defaults:
run:
working-directory: backend/
runs-on: ${{ matrix.os }}
steps:
- name: Check repository
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dev dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install Dependencies for Linting
run: |
pip install flake8
- name: Lint with Flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# test:
# name: 'Test 🔬'
# needs: build
# strategy:
# matrix:
# os:
# - ubuntu-latest
# python-version:
# - "3.11"
# defaults:
# run:
# working-directory: backend/
# services:
# postgres:
# image: postgres:14.2-alpine
# env:
# POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
# POSTGRES_USER: ${{ secrets.POSTGRES_USERNAME }}
# POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
# ports:
# - 5432:5432
# options: >-
# --health-cmd pg_isready
# --health-interval 10s
# --health-timeout 5s
# --health-retries 5
# env:
# ENVIRONMENT: ${{ secrets.ENVIRONMENT }}
# DEBUG: ${{ secrets.DEBUG }}
# POSTGRES_DB: ${{ secrets.POSTGRES_DB }}
# POSTGRES_HOST: ${{ secrets.POSTGRES_HOST }}
# POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }}
# POSTGRES_PORT: ${{ secrets.POSTGRES_PORT }}
# POSTGRES_SCHEMA: ${{ secrets.POSTGRES_SCHEMA }}
# POSTGRES_USERNAME: ${{ secrets.POSTGRES_USERNAME }}
# BACKEND_SERVER_HOST: ${{ secrets.BACKEND_SERVER_HOST }}
# BACKEND_SERVER_PORT: ${{ secrets.BACKEND_SERVER_PORT }}
# BACKEND_SERVER_WORKERS: ${{ secrets.BACKEND_SERVER_WORKERS }}
# DB_TIMEOUT: ${{ secrets.DB_TIMEOUT }}
# DB_POOL_SIZE: ${{ secrets.DB_POOL_SIZE }}
# DB_MAX_POOL_CON: ${{ secrets.DB_MAX_POOL_CON }}
# DB_POOL_OVERFLOW: ${{ secrets.DB_POOL_OVERFLOW }}
# IS_DB_ECHO_LOG: ${{ secrets.IS_DB_ECHO_LOG }}
# IS_DB_EXPIRE_ON_COMMIT: ${{ secrets.IS_DB_EXPIRE_ON_COMMIT }}
# IS_DB_FORCE_ROLLBACK: ${{ secrets.IS_DB_FORCE_ROLLBACK }}
# IS_ALLOWED_CREDENTIALS: ${{ secrets.IS_ALLOWED_CREDENTIALS }}
# API_TOKEN: ${{ secrets.API_TOKEN }}
# AUTH_TOKEN: ${{ secrets.AUTH_TOKEN }}
# CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
# JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }}
# JWT_SUBJECT: ${{ secrets.JWT_SUBJECT }}
# JWT_TOKEN_PREFIX: ${{ secrets.JWT_TOKEN_PREFIX }}
# JWT_ALGORITHM: ${{ secrets.JWT_ALGORITHM }}
# JWT_MIN: ${{ secrets.JWT_MIN }}
# JWT_HOUR: ${{ secrets.JWT_HOUR }}
# JWT_DAY: ${{ secrets.JWT_DAY }}
# HASHING_ALGORITHM_LAYER_1: ${{ secrets.HASHING_ALGORITHM_LAYER_1 }}
# HASHING_ALGORITHM_LAYER_2: ${{ secrets.HASHING_ALGORITHM_LAYER_2 }}
# HASHING_SALT: ${{ secrets.HASHING_SALT }}
# runs-on: ${{ matrix.os }}
# steps:
# - name: Check repository
# uses: actions/checkout@v3
# - name: Set up Python ${{ matrix.python-version }}
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
# cache: 'pip'
# - name: Display Python version
# run: python -c "import sys; print(sys.version)"
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# - name: Install Dependencies for Testing
# run: |
# pip install pytest pytest-asyncio pytest pytest-xdist
# - name: Test with Pytest-Cov
# run: |
# pytest --cov --cov-report xml .
# - name: Upload coverage to Codecov
# uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# fail_ci_if_error: false
# flags: backend_app_tests
# name: codecov-umbrella
# verbose: true
docker_build:
name: 'Docker Build 🐳'
needs: code-quality
strategy:
matrix:
os:
- ubuntu-latest
defaults:
run:
working-directory: backend/
runs-on: ${{ matrix.os }}
steps:
- name: Check repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Build Docker Image
run: |
docker build -t kirin:latest -f Dockerfile .
# - name: Push Docker Image
# run: |
# echo ${{ secrets.DOCKER_PASSWORD }} | docker login ${{ secrets.DOCKER_REGISTRY }} -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
# docker push ${{ secrets.DOCKER_REGISTRY }}/kirin:latest