Skip to content

fix: wrong UserEntity import #142

fix: wrong UserEntity import

fix: wrong UserEntity import #142

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 }}
MYSQL_ROOT_HOST: "%"
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
run: pip install poetry
- name: Install dependencies
working-directory: backend
run: poetry install --with dev,docs
- name: Start MySQL
run: |
sudo systemctl enable mysql.service
sudo systemctl start mysql.service
- name: Create database
run: mysql -u${{ secrets.KWAI_DB_USER_NAME }} -h127.0.0.1 -p${{ secrets.KWAI_DB_PASSWORD }} -e 'CREATE DATABASE IF NOT EXISTS ${{ secrets.KWAI_DB_NAME }};'
- name: Setup Redis
run: sudo apt-get install -y redis-tools redis-server
- name: Verify that redis is up
run: redis-cli ping
- name: Create Kwai Settings
env:
KWAI_JWT_SECRET: ${{ secrets.KWAI_JWT_SECRET }}
KWAI_EMAIL_HOST: ${{ secrets.KWAI_EMAIL_HOST }}
KWAI_EMAIL_PORT: ${{ secrets.KWAI_EMAIL_PORT }}
KWAI_EMAIL_USER: ${{ secrets.KWAI_EMAIL_USER }}
KWAI_EMAIL_PASSWORD: ${{ secrets.KWAI_EMAIL_PASSWORD }}
run: |
cat <<EOF > .kwai.toml
[frontend]
test = true
path = ""
root_app = "portal"
[frontend.apps.portal]
base="/apps/portal"
base_dev="http://localhost:3000"
entries="/src/index.ts"
[frontend.apps.author]
base="/apps/author"
base_dev="http://localhost:3001"
entries="/src/index.ts"
[frontend.apps.auth]
base="/apps/auth"
base_dev="http://localhost:3002"
entries="/src/index.ts"
[frontend.apps.coach]
base="/apps/coach"
base_dev="http://localhost:3003"
entries="/src/index.ts"
[frontend.apps.club]
base="/apps/club"
base_dev="http://localhost:3004"
entries="/src/index.ts"
[files]
path = "/var/tmp/kwai"
[security]
jwt_secret="$KWAI_JWT_SECRET"
jwt_refresh_secret="$KWAI_JWT_SECRET"
[template]
path="${{ github.workspace }}/backend/templates"
[db]
host="localhost"
name="$KWAI_DB_NAME"
user="$KWAI_DB_USER_NAME"
password="$KWAI_DB_PASSWORD"
[website]
url="http://localhost"
email="[email protected]"
name="Kwai Website"
[email]
host="$KWAI_EMAIL_HOST"
user="$KWAI_EMAIL_USER"
password="$KWAI_EMAIL_PASSWORD"
port=$KWAI_EMAIL_PORT
ssl=false
tls=true
from="[email protected]"
[redis]
host="127.0.0.1"
EOF
cat .kwai.toml
- name: Download dbmate
run: |
curl -fsSL -o ./dbmate https://github.com/amacneil/dbmate/releases/latest/download/dbmate-linux-amd64
sudo chmod +x ./dbmate
- name: Migrate database
env:
DATABASE_URL: mysql://${{secrets.KWAI_DB_USER_NAME}}:${{secrets.KWAI_DB_PASSWORD}}@localhost/${{secrets.KWAI_DB_NAME}}
DBMATE_MIGRATIONS_DIR: "./backend/migrations"
DBMATE_NO_DUMP_SCHEMA: "true"
DBMATE_WAIT: "true"
DBMATE_WAIT_TIMEOUT: "30s"
run: ./dbmate up
- name: Test with pytest
working-directory: backend
env:
KWAI_SETTINGS_FILE: ${{github.workspace}}/.kwai.toml
run: poetry run pytest --cov=kwai --cov-report html
- name: Generate coverage badge
working-directory: backend
run: poetry run coverage-badge -o ./htmlcov/coverage.svg
- name: Remove .gitignore from coverage report
run: rm backend/htmlcov/.gitignore
- name: Deploy coverage to github pages
uses: JamesIves/[email protected]
with:
branch: gh-pages
target-folder: coverage
folder: backend/htmlcov