This repository has been archived by the owner on Oct 14, 2023. It is now read-only.
feat: add html_summary and html_content #73
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.10"] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Poetry | |
run: pip install poetry | |
- name: Install dependencies | |
working-directory: backend/src | |
run: poetry install | |
- 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 | |
[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="franky.braem@gmail.com" | |
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="franky.braem@gmail.com" | |
[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/src | |
env: | |
KWAI_SETTINGS_FILE: ${{github.workspace}}/.kwai.toml | |
run: poetry run pytest --cov=kwai --cov-report html | |
- name: Generate coverage badge | |
working-directory: backend/src | |
run: poetry run coverage-badge -o ./htmlcov/coverage.svg | |
- name: Remove .gitignore from coverage report | |
run: rm backend/src/htmlcov/.gitignore | |
- name: Deploy coverage to github pages | |
uses: JamesIves/github-pages-deploy-action@4.1.0 | |
with: | |
branch: gh-pages | |
target-folder: coverage | |
folder: backend/src/htmlcov |