Skip to content
This repository has been archived by the owner on Oct 14, 2023. It is now read-only.

feat: try to test with a database #8

feat: try to test with a database

feat: try to test with a database #8

Workflow file for this run

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"