-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (58 loc) · 1.71 KB
/
backend_test.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
name: backend test
on:
push:
paths:
- "backend/src/**"
pull_request:
paths:
- "backend/src/**"
workflow_dispatch:
env:
KWAI_DB_NAME: ${{ secrets.KWAI_DB_NAME }}
KWAI_DB_USER_NAME: ${{ secrets.KWAI_DB_USER_NAME }}
KWAI_DB_PASSWORD: ${{ secrets.KWAI_DB_PASSWORD }}
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- uses: snok/install-poetry@v1
- name: Install dependencies
working-directory: backend/src
run: poetry install
- name: Start MySQL
run: sudo systemctl start mysql.service
- name: Create Kwai Settings
env:
KWAI_JWT_SECRET: ${{ secrets.KWAI_JWT_SECRET }}
run: |
cat <<EOF > .kwai.toml
[security]
jwt_secret="$KWAI_JWT_SECRET"
jwt_refresh_secret="$KWAI_JWT_SECRET"
[db]
host="localhost"
name="$KWAI_DB_NAME"
user="$KWAI_DB_USER_NAME"
password="$KWAI_DB_PASSWORD"
EOF
- name: Migrate database
uses: actions/dbmate-action@v1.15
with:
command: 'up'
env:
DATABASE_URL: mysql://localhost/${{secrets.KWAI_DB_NAME}}
DBMATE_MIGRATIONS_DIR: "./backend/migrations"
DBMATE_NO_DUMP_SCHEMA: "true"
DBMATE_WAIT: "true"
DBMATE_WAIT_TIMEOUT: "30s"
- name: Test with pytest
working-directory: backend/src
run: poetry run pytest --cov=kwai -m "not api and not mail and not bus"